From 0408b310ca2248928c87c86cd31e8d1e9c05608c Mon Sep 17 00:00:00 2001 From: Marcono1234 Date: Fri, 17 Sep 2021 14:56:58 +0200 Subject: [PATCH] Don't exclude static local classes --- 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 6b83757edb..9e7f322114 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 boolean excludeField(Field field, boolean serialize) { return true; } - if (isAnonymousOrLocal(field.getType())) { + if (isAnonymousOrNonStaticLocal(field.getType())) { return true; } @@ -199,7 +199,7 @@ private boolean excludeClassChecks(Class clazz) { return true; } - if (isAnonymousOrLocal(clazz)) { + if (isAnonymousOrNonStaticLocal(clazz)) { return true; } @@ -221,8 +221,8 @@ private boolean excludeClassInStrategy(Class clazz, boolean serialize) { 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()); }