Don't exclude static local classes (#1969)

This commit is contained in:
Marcono1234 2021-09-18 03:12:47 +02:00 committed by GitHub
parent 6a5e775362
commit aa5554e69a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -173,7 +173,7 @@ public final class Excluder implements TypeAdapterFactory, Cloneable {
return true; return true;
} }
if (isAnonymousOrLocal(field.getType())) { if (isAnonymousOrNonStaticLocal(field.getType())) {
return true; return true;
} }
@ -199,7 +199,7 @@ public final class Excluder implements TypeAdapterFactory, Cloneable {
return true; return true;
} }
if (isAnonymousOrLocal(clazz)) { if (isAnonymousOrNonStaticLocal(clazz)) {
return true; return true;
} }
@ -221,8 +221,8 @@ public final class Excluder implements TypeAdapterFactory, Cloneable {
return false; return false;
} }
private boolean isAnonymousOrLocal(Class<?> clazz) { private boolean isAnonymousOrNonStaticLocal(Class<?> clazz) {
return !Enum.class.isAssignableFrom(clazz) return !Enum.class.isAssignableFrom(clazz) && !isStatic(clazz)
&& (clazz.isAnonymousClass() || clazz.isLocalClass()); && (clazz.isAnonymousClass() || clazz.isLocalClass());
} }