Skip to content

Commit fb007fd

Browse files
committed
android-record: Adapt generic types returned by Android reflection to follow Java behavior.
1 parent 032b52e commit fb007fd

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

android-record/src/main/java/com/fasterxml/jackson/module/androidrecord/AndroidRecordModule.java

+8-7
Original file line numberDiff line numberDiff line change
@@ -154,20 +154,21 @@ static Class<?> arrayTypeCompat(Class<?> componentType) {
154154

155155
static Type fixAndroidGenericType(Type type) {
156156
if (type instanceof GenericArrayType) {
157-
//recurse into component type
158157
Type componentType = fixAndroidGenericType(((GenericArrayType) type).getGenericComponentType());
159-
if (componentType instanceof Class<?>) { //if it isn't generic, return the raw array type
158+
if (componentType instanceof Class<?>) {
160159
return arrayTypeCompat((Class<?>) componentType);
161160
}
162161
}
163162
else if (type instanceof ParameterizedType) {
164163
//if the parameterized type is not actually parameterized, deduce the raw type
165164
ParameterizedType parameterizedType = (ParameterizedType) type;
166-
Type rawType = parameterizedType.getRawType();
167-
if (rawType instanceof Class<?>) {
168-
Class<?> rawComponentClass = (Class<?>) rawType;
169-
if (rawComponentClass.getTypeParameters().length == 0) {
170-
return rawComponentClass;
165+
if (parameterizedType.getOwnerType() == null) {
166+
Type rawType = parameterizedType.getRawType();
167+
if (rawType instanceof Class<?>) {
168+
Class<?> rawComponentClass = (Class<?>) rawType;
169+
if (rawComponentClass.getTypeParameters().length == 0) {
170+
return rawComponentClass;
171+
}
171172
}
172173
}
173174
}

0 commit comments

Comments
 (0)