Merge pull request #245 from NightlyNexus/eric/platform-fields

Fix isPlatformType
This commit is contained in:
Jesse Wilson
2017-02-02 09:10:45 -05:00
committed by GitHub

View File

@@ -46,7 +46,7 @@ final class ClassJsonAdapter<T> extends JsonAdapter<T> {
Type type, Set<? extends Annotation> annotations, Moshi moshi) { Type type, Set<? extends Annotation> annotations, Moshi moshi) {
Class<?> rawType = Types.getRawType(type); Class<?> rawType = Types.getRawType(type);
if (rawType.isInterface() || rawType.isEnum()) return null; if (rawType.isInterface() || rawType.isEnum()) return null;
if (isPlatformType(rawType)) { if (isPlatformType(rawType) && !Types.isAllowedPlatformType(rawType)) {
throw new IllegalArgumentException("Platform " throw new IllegalArgumentException("Platform "
+ type + type
+ " annotated " + " annotated "
@@ -111,11 +111,11 @@ final class ClassJsonAdapter<T> extends JsonAdapter<T> {
*/ */
private boolean isPlatformType(Class<?> rawType) { private boolean isPlatformType(Class<?> rawType) {
String name = rawType.getName(); String name = rawType.getName();
return (name.startsWith("android.") return name.startsWith("android.")
|| name.startsWith("java.") || name.startsWith("java.")
|| name.startsWith("javax.") || name.startsWith("javax.")
|| name.startsWith("kotlin.") || name.startsWith("kotlin.")
|| name.startsWith("scala.")) && !Types.isAllowedPlatformType(rawType); || name.startsWith("scala.");
} }
/** Returns true if fields with {@code modifiers} are included in the emitted JSON. */ /** Returns true if fields with {@code modifiers} are included in the emitted JSON. */