From 0c5a1bea3ffa7c4b6b1503733e33911cbfcb3e80 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Fri, 17 Jun 2016 08:54:19 -0700 Subject: [PATCH] altoslib: Stop reflective JSON class walk at Object instead of null Android has classes above Object which are all tied together which cause the object walking to fail in pretty spectacular ways. As Object has no interesting fields, that serves as a fine barrier to the super class walk and works on both android and real java. Signed-off-by: Keith Packard --- altoslib/AltosJson.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/altoslib/AltosJson.java b/altoslib/AltosJson.java index 346144d9..67f3a00a 100644 --- a/altoslib/AltosJson.java +++ b/altoslib/AltosJson.java @@ -1063,7 +1063,7 @@ public class AltosJson extends JsonUtil { } else { object = c.newInstance(); } - for (; c != null; c = c.getSuperclass()) { + for (; c != Object.class; c = c.getSuperclass()) { for (Field field : c.getDeclaredFields()) { String fieldName = field.getName(); Class fieldClass = field.getType(); @@ -1208,7 +1208,7 @@ public class AltosJson extends JsonUtil { } } else { assert_hash(true); - for (Class c = object.getClass(); c != null; c = c.getSuperclass()) { + for (Class c = object.getClass(); c != Object.class; c = c.getSuperclass()) { for (Field field : c.getDeclaredFields()) { String fieldName = field.getName(); -- 2.30.2