From aa5554e69a2d5ee7e557b3cc1f5d68275fd4c1ab Mon Sep 17 00:00:00 2001 From: Marcono1234 Date: Sat, 18 Sep 2021 03:12:47 +0200 Subject: [PATCH] Don't exclude static local classes (#1969) --- gson/src/main/java/com/google/gson/internal/Excluder.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/gson/src/main/java/com/google/gson/internal/Excluder.java b/gson/src/main/java/com/google/gson/internal/Excluder.java index 6b83757e..9e7f3221 100644 --- a/gson/src/main/java/com/google/gson/internal/Excluder.java +++ b/gson/src/main/java/com/google/gson/internal/Excluder.java @@ -173,7 +173,7 @@ public final class Excluder implements TypeAdapterFactory, Cloneable { return true; } - if (isAnonymousOrLocal(field.getType())) { + if (isAnonymousOrNonStaticLocal(field.getType())) { return true; } @@ -199,7 +199,7 @@ public final class Excluder implements TypeAdapterFactory, Cloneable { return true; } - if (isAnonymousOrLocal(clazz)) { + if (isAnonymousOrNonStaticLocal(clazz)) { return true; } @@ -221,8 +221,8 @@ public final class Excluder implements TypeAdapterFactory, Cloneable { return false; } - private boolean isAnonymousOrLocal(Class clazz) { - return !Enum.class.isAssignableFrom(clazz) + private boolean isAnonymousOrNonStaticLocal(Class clazz) { + return !Enum.class.isAssignableFrom(clazz) && !isStatic(clazz) && (clazz.isAnonymousClass() || clazz.isLocalClass()); }