Skip to content

Commit

Permalink
Don't exclude static local classes
Browse files Browse the repository at this point in the history
  • Loading branch information
Marcono1234 committed Sep 18, 2021
1 parent b82c767 commit 0408b31
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions gson/src/main/java/com/google/gson/internal/Excluder.java
Expand Up @@ -173,7 +173,7 @@ public boolean excludeField(Field field, boolean serialize) {
return true;
}

if (isAnonymousOrLocal(field.getType())) {
if (isAnonymousOrNonStaticLocal(field.getType())) {
return true;
}

Expand All @@ -199,7 +199,7 @@ private boolean excludeClassChecks(Class<?> clazz) {
return true;
}

if (isAnonymousOrLocal(clazz)) {
if (isAnonymousOrNonStaticLocal(clazz)) {
return true;
}

Expand All @@ -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());
}

Expand Down

0 comments on commit 0408b31

Please sign in to comment.