Don't call setAccessible(true) on fields we won't be setting or getting.

Fixes bug 191.
This commit is contained in:
Jesse Wilson 2011-12-29 07:11:43 +00:00
parent 8d5de3136c
commit 740d03ef0e

View File

@ -108,13 +108,13 @@ public final class ReflectiveTypeAdapterFactory implements TypeAdapterFactory {
Type declaredType = type.getType();
while (raw != Object.class) {
Field[] fields = raw.getDeclaredFields();
AccessibleObject.setAccessible(fields, true);
for (Field field : fields) {
boolean serialize = excludeField(field, true);
boolean deserialize = excludeField(field, false);
if (!serialize && !deserialize) {
continue;
}
field.setAccessible(true);
Type fieldType = $Gson$Types.resolve(type.getType(), raw, field.getGenericType());
BoundField boundField = createBoundField(context, field, getFieldName(field),
TypeToken.get(fieldType), serialize, deserialize);