From fb007fd75c20f88c7510d831826dff14811eb72a Mon Sep 17 00:00:00 2001 From: HelloOO7 Date: Tue, 3 Sep 2024 19:30:04 +0200 Subject: [PATCH] android-record: Adapt generic types returned by Android reflection to follow Java behavior. --- .../module/androidrecord/AndroidRecordModule.java | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/android-record/src/main/java/com/fasterxml/jackson/module/androidrecord/AndroidRecordModule.java b/android-record/src/main/java/com/fasterxml/jackson/module/androidrecord/AndroidRecordModule.java index 92ee6dba..4ac5c872 100644 --- a/android-record/src/main/java/com/fasterxml/jackson/module/androidrecord/AndroidRecordModule.java +++ b/android-record/src/main/java/com/fasterxml/jackson/module/androidrecord/AndroidRecordModule.java @@ -154,20 +154,21 @@ static Class arrayTypeCompat(Class componentType) { static Type fixAndroidGenericType(Type type) { if (type instanceof GenericArrayType) { - //recurse into component type Type componentType = fixAndroidGenericType(((GenericArrayType) type).getGenericComponentType()); - if (componentType instanceof Class) { //if it isn't generic, return the raw array type + if (componentType instanceof Class) { return arrayTypeCompat((Class) componentType); } } else if (type instanceof ParameterizedType) { //if the parameterized type is not actually parameterized, deduce the raw type ParameterizedType parameterizedType = (ParameterizedType) type; - Type rawType = parameterizedType.getRawType(); - if (rawType instanceof Class) { - Class rawComponentClass = (Class) rawType; - if (rawComponentClass.getTypeParameters().length == 0) { - return rawComponentClass; + if (parameterizedType.getOwnerType() == null) { + Type rawType = parameterizedType.getRawType(); + if (rawType instanceof Class) { + Class rawComponentClass = (Class) rawType; + if (rawComponentClass.getTypeParameters().length == 0) { + return rawComponentClass; + } } } }