Don't call setAccessible(true) on fields we won't be setting or getting.
Fixes bug 191.
This commit is contained in:
parent
8d5de3136c
commit
740d03ef0e
@ -108,13 +108,13 @@ public final class ReflectiveTypeAdapterFactory implements TypeAdapterFactory {
|
|||||||
Type declaredType = type.getType();
|
Type declaredType = type.getType();
|
||||||
while (raw != Object.class) {
|
while (raw != Object.class) {
|
||||||
Field[] fields = raw.getDeclaredFields();
|
Field[] fields = raw.getDeclaredFields();
|
||||||
AccessibleObject.setAccessible(fields, true);
|
|
||||||
for (Field field : fields) {
|
for (Field field : fields) {
|
||||||
boolean serialize = excludeField(field, true);
|
boolean serialize = excludeField(field, true);
|
||||||
boolean deserialize = excludeField(field, false);
|
boolean deserialize = excludeField(field, false);
|
||||||
if (!serialize && !deserialize) {
|
if (!serialize && !deserialize) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
field.setAccessible(true);
|
||||||
Type fieldType = $Gson$Types.resolve(type.getType(), raw, field.getGenericType());
|
Type fieldType = $Gson$Types.resolve(type.getType(), raw, field.getGenericType());
|
||||||
BoundField boundField = createBoundField(context, field, getFieldName(field),
|
BoundField boundField = createBoundField(context, field, getFieldName(field),
|
||||||
TypeToken.get(fieldType), serialize, deserialize);
|
TypeToken.get(fieldType), serialize, deserialize);
|
||||||
|
Loading…
Reference in New Issue
Block a user