Skip to content

Commit 0ede935

Browse files
committed
Fix #3412 (Android compat issue)
1 parent 5ad71e9 commit 0ede935

File tree

7 files changed

+17
-6
lines changed

7 files changed

+17
-6
lines changed

release-notes/CREDITS-2.x

+5
Original file line numberDiff line numberDiff line change
@@ -1423,3 +1423,8 @@ Krishna Ghimire (Krishnaghimir@github)
14231423
Christoph Dreis (dreis2211@github)
14241424
* Suggested #3293: Use Method.getParameterCount() where possible
14251425
(2.13.2)
1426+
1427+
Matthieu Finiasz (finiasz@github)
1428+
* Reported #3412: Version 2.13.2 uses `Method.getParameterCount()` which is not
1429+
supported on Android before API 26
1430+
(2.13.2)

release-notes/VERSION-2.x

+6
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@ Project: jackson-databind
44
=== Releases ===
55
------------------------------------------------------------------------
66

7+
2.13.3 (not yet released)
8+
9+
#3412: Version 2.13.2 uses `Method.getParameterCount()` which is not
10+
supported on Android before API 26
11+
(reported by Matthew F)
12+
713
2.13.2 (06-Mar-2022)
814

915
#3293: Use Method.getParameterCount() where possible

src/main/java/com/fasterxml/jackson/databind/deser/BeanDeserializerBase.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -961,8 +961,8 @@ protected SettableBeanProperty _resolveInnerClassValuedProperty(DeserializationC
961961
// and is inner class of the bean class...
962962
if ((enclosing != null) && (enclosing == _beanType.getRawClass())) {
963963
for (Constructor<?> ctor : valueClass.getConstructors()) {
964-
if (ctor.getParameterCount() == 1) {
965-
Class<?>[] paramTypes = ctor.getParameterTypes();
964+
Class<?>[] paramTypes = ctor.getParameterTypes();
965+
if (paramTypes.length == 1) {
966966
if (enclosing.equals(paramTypes[0])) {
967967
if (ctxt.canOverrideAccessModifiers()) {
968968
ClassUtil.checkAndFixAccess(ctor, ctxt.isEnabled(MapperFeature.OVERRIDE_PUBLIC_ACCESS_MODIFIERS));

src/main/java/com/fasterxml/jackson/databind/introspect/AnnotatedConstructor.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ public Object getValue(Object pojo)
169169

170170
@Override
171171
public String toString() {
172-
final int argCount = _constructor.getParameterCount();
172+
final int argCount = _constructor.getParameterTypes().length;
173173
return String.format("[constructor for %s (%d arg%s), annotations: %s",
174174
ClassUtil.nameOf(_constructor.getDeclaringClass()), argCount,
175175
(argCount == 1) ? "" : "s", _annotations);

src/main/java/com/fasterxml/jackson/databind/introspect/AnnotatedCreatorCollector.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,7 @@ protected AnnotatedConstructor constructNonDefaultConstructor(ClassUtil.Ctor cto
352352
protected AnnotatedMethod constructFactoryCreator(Method m,
353353
TypeResolutionContext typeResCtxt, Method mixin)
354354
{
355-
final int paramCount = m.getParameterCount();
355+
final int paramCount = m.getParameterTypes().length;
356356
if (_intr == null) { // when annotation processing is disabled
357357
return new AnnotatedMethod(typeResCtxt, m, _emptyAnnotationMap(),
358358
_emptyAnnotationMaps(paramCount));

src/main/java/com/fasterxml/jackson/databind/introspect/AnnotatedMethodCollector.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ private static boolean _isIncludableMemberMethod(Method m)
184184
}
185185
// also, for now we have no use for methods with more than 2 arguments:
186186
// (2 argument methods for "any setter", fwtw)
187-
return (m.getParameterCount() <= 2);
187+
return (m.getParameterTypes().length <= 2);
188188
}
189189

190190
private final static class MethodBuilder {

src/main/java/com/fasterxml/jackson/databind/util/ClassUtil.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -1448,7 +1448,7 @@ public Constructor<?> getConstructor() {
14481448
public int getParamCount() {
14491449
int c = _paramCount;
14501450
if (c < 0) {
1451-
c = _ctor.getParameterCount();
1451+
c = _ctor.getParameterTypes().length;
14521452
_paramCount = c;
14531453
}
14541454
return c;

0 commit comments

Comments
 (0)