diff --git a/gson/src/main/java/com/google/gson/FieldAttributes.java b/gson/src/main/java/com/google/gson/FieldAttributes.java index 18ceb90a..511c2cbd 100644 --- a/gson/src/main/java/com/google/gson/FieldAttributes.java +++ b/gson/src/main/java/com/google/gson/FieldAttributes.java @@ -55,16 +55,6 @@ public final class FieldAttributes { private Type genericType; private Collection annotations; - FieldAttributes(Class declaringClazz, Field f) { - this.declaringClazz = $Gson$Preconditions.checkNotNull(declaringClazz); - this.name = f.getName(); - this.declaredType = f.getType(); - this.isSynthetic = f.isSynthetic(); - this.modifiers = f.getModifiers(); - this.field = f; - this.resolvedType = getTypeInfoForField(f, declaringClazz); - } - /** * Constructs a Field Attributes object from the {@code f}. * diff --git a/gson/src/test/java/com/google/gson/DisjunctionExclusionStrategyTest.java b/gson/src/test/java/com/google/gson/DisjunctionExclusionStrategyTest.java index ad3dbe70..5dfd9630 100644 --- a/gson/src/test/java/com/google/gson/DisjunctionExclusionStrategyTest.java +++ b/gson/src/test/java/com/google/gson/DisjunctionExclusionStrategyTest.java @@ -34,7 +34,8 @@ public class DisjunctionExclusionStrategyTest extends TestCase { new MockExclusionStrategy(true, true); private static final Class CLAZZ = String.class; - private static final FieldAttributes FIELD = new FieldAttributes(CLAZZ, CLAZZ.getFields()[0]); + private static final FieldAttributes FIELD = + new FieldAttributes(CLAZZ, CLAZZ.getFields()[0], CLAZZ); public void testBadInstantiation() throws Exception { try { diff --git a/gson/src/test/java/com/google/gson/ExposeAnnotationExclusionStrategyTest.java b/gson/src/test/java/com/google/gson/ExposeAnnotationExclusionStrategyTest.java index b915b058..0dcfedf4 100644 --- a/gson/src/test/java/com/google/gson/ExposeAnnotationExclusionStrategyTest.java +++ b/gson/src/test/java/com/google/gson/ExposeAnnotationExclusionStrategyTest.java @@ -75,7 +75,7 @@ public class ExposeAnnotationExclusionStrategyTest extends TestCase { private static FieldAttributes createFieldAttributes(String fieldName) throws Exception { Field f = MockObject.class.getField(fieldName); - return new FieldAttributes(MockObject.class, f); + return new FieldAttributes(MockObject.class, f, MockObject.class); } @SuppressWarnings("unused") diff --git a/gson/src/test/java/com/google/gson/FieldAttributesTest.java b/gson/src/test/java/com/google/gson/FieldAttributesTest.java index af03f314..9e29f0db 100644 --- a/gson/src/test/java/com/google/gson/FieldAttributesTest.java +++ b/gson/src/test/java/com/google/gson/FieldAttributesTest.java @@ -36,12 +36,12 @@ public class FieldAttributesTest extends TestCase { @Override protected void setUp() throws Exception { super.setUp(); - fieldAttributes = new FieldAttributes(Foo.class, Foo.class.getField("bar")); + fieldAttributes = new FieldAttributes(Foo.class, Foo.class.getField("bar"), Foo.class); } public void testNullField() throws Exception { try { - new FieldAttributes(Foo.class, null); + new FieldAttributes(Foo.class, null, Foo.class); fail("Field parameter can not be null"); } catch (NullPointerException expected) { } } diff --git a/gson/src/test/java/com/google/gson/FieldNamingStrategy2AdapterTest.java b/gson/src/test/java/com/google/gson/FieldNamingStrategy2AdapterTest.java index 821bc91f..99f175e7 100644 --- a/gson/src/test/java/com/google/gson/FieldNamingStrategy2AdapterTest.java +++ b/gson/src/test/java/com/google/gson/FieldNamingStrategy2AdapterTest.java @@ -34,7 +34,7 @@ public class FieldNamingStrategy2AdapterTest extends TestCase { FieldNamingStrategy2 adapter = new FieldNamingStrategy2Adapter(new UpperCaseNamingStrategy()); assertEquals(expectedFieldName, adapter.translateName( - new FieldAttributes(String.class, field))); + new FieldAttributes(String.class, field, String.class))); } @SuppressWarnings("deprecation") diff --git a/gson/src/test/java/com/google/gson/InnerClassExclusionStrategyTest.java b/gson/src/test/java/com/google/gson/InnerClassExclusionStrategyTest.java index d5e8a2bc..1ba8f51e 100644 --- a/gson/src/test/java/com/google/gson/InnerClassExclusionStrategyTest.java +++ b/gson/src/test/java/com/google/gson/InnerClassExclusionStrategyTest.java @@ -46,7 +46,7 @@ public class InnerClassExclusionStrategyTest extends TestCase { public void testExcludeInnerClassField() throws Exception { Field f = getClass().getField("innerClass"); - assertTrue(strategy.shouldSkipField(new FieldAttributes(getClass(), f))); + assertTrue(strategy.shouldSkipField(new FieldAttributes(getClass(), f, getClass()))); } public void testIncludeStaticNestedClassObject() throws Exception { @@ -56,7 +56,7 @@ public class InnerClassExclusionStrategyTest extends TestCase { public void testIncludeStaticNestedClassField() throws Exception { Field f = getClass().getField("staticNestedClass"); - assertFalse(strategy.shouldSkipField(new FieldAttributes(getClass(), f))); + assertFalse(strategy.shouldSkipField(new FieldAttributes(getClass(), f, getClass()))); } class InnerClass { diff --git a/gson/src/test/java/com/google/gson/JavaFieldNamingPolicyTest.java b/gson/src/test/java/com/google/gson/JavaFieldNamingPolicyTest.java index db19ed0e..7c91e2cd 100644 --- a/gson/src/test/java/com/google/gson/JavaFieldNamingPolicyTest.java +++ b/gson/src/test/java/com/google/gson/JavaFieldNamingPolicyTest.java @@ -34,7 +34,7 @@ public class JavaFieldNamingPolicyTest extends TestCase { } public void testFieldNamingPolicy() throws Exception { - FieldAttributes f = new FieldAttributes(String.class, String.class.getFields()[0]); + FieldAttributes f = new FieldAttributes(String.class, String.class.getFields()[0], String.class); assertEquals(f.getName(), namingPolicy.translateName(f)); } diff --git a/gson/src/test/java/com/google/gson/NullExclusionStrategyTest.java b/gson/src/test/java/com/google/gson/NullExclusionStrategyTest.java index 7710db19..c0d486cf 100644 --- a/gson/src/test/java/com/google/gson/NullExclusionStrategyTest.java +++ b/gson/src/test/java/com/google/gson/NullExclusionStrategyTest.java @@ -38,6 +38,6 @@ public class NullExclusionStrategyTest extends TestCase { public void testNeverSkipsField() throws Exception { assertFalse(strategy.shouldSkipField( - new FieldAttributes(String.class, String.class.getFields()[0]))); + new FieldAttributes(String.class, String.class.getFields()[0], String.class))); } } diff --git a/gson/src/test/java/com/google/gson/SerializedNameAnnotationInterceptingNamingPolicyTest.java b/gson/src/test/java/com/google/gson/SerializedNameAnnotationInterceptingNamingPolicyTest.java index 57711028..e73655a4 100644 --- a/gson/src/test/java/com/google/gson/SerializedNameAnnotationInterceptingNamingPolicyTest.java +++ b/gson/src/test/java/com/google/gson/SerializedNameAnnotationInterceptingNamingPolicyTest.java @@ -39,7 +39,7 @@ public class SerializedNameAnnotationInterceptingNamingPolicyTest extends TestCa public void testFieldWithAnnotation() throws Exception { String fieldName = "fieldWithAnnotation"; FieldAttributes f = new FieldAttributes( - SomeObject.class, SomeObject.class.getField(fieldName)); + SomeObject.class, SomeObject.class.getField(fieldName), SomeObject.class); assertFalse(ANNOTATED_FIELD_NAME.equals(fieldName)); assertEquals(ANNOTATED_FIELD_NAME, policy.translateName(f)); @@ -48,7 +48,7 @@ public class SerializedNameAnnotationInterceptingNamingPolicyTest extends TestCa public void testFieldWithoutAnnotation() throws Exception { String fieldName = "fieldWithoutAnnotation"; FieldAttributes f = new FieldAttributes( - SomeObject.class, SomeObject.class.getField(fieldName)); + SomeObject.class, SomeObject.class.getField(fieldName), SomeObject.class); assertEquals(fieldName, policy.translateName(f)); } diff --git a/gson/src/test/java/com/google/gson/VersionExclusionStrategyTest.java b/gson/src/test/java/com/google/gson/VersionExclusionStrategyTest.java index e0844d87..95f9e381 100644 --- a/gson/src/test/java/com/google/gson/VersionExclusionStrategyTest.java +++ b/gson/src/test/java/com/google/gson/VersionExclusionStrategyTest.java @@ -43,7 +43,7 @@ public class VersionExclusionStrategyTest extends TestCase { VersionExclusionStrategy strategy = new VersionExclusionStrategy(VERSION); assertFalse(strategy.shouldSkipClass(clazz)); - FieldAttributes fieldAttributes = new FieldAttributes(clazz, f); + FieldAttributes fieldAttributes = new FieldAttributes(clazz, f, clazz); assertFalse(strategy.shouldSkipField(fieldAttributes)); } @@ -53,7 +53,7 @@ public class VersionExclusionStrategyTest extends TestCase { VersionExclusionStrategy strategy = new VersionExclusionStrategy(VERSION + 1); assertFalse(strategy.shouldSkipClass(clazz)); - FieldAttributes fieldAttributes = new FieldAttributes(clazz, f); + FieldAttributes fieldAttributes = new FieldAttributes(clazz, f, clazz); assertFalse(strategy.shouldSkipField(fieldAttributes)); } @@ -63,7 +63,7 @@ public class VersionExclusionStrategyTest extends TestCase { VersionExclusionStrategy strategy = new VersionExclusionStrategy(VERSION - 1); assertTrue(strategy.shouldSkipClass(clazz)); - FieldAttributes fieldAttributes = new FieldAttributes(clazz, f); + FieldAttributes fieldAttributes = new FieldAttributes(clazz, f, clazz); assertTrue(strategy.shouldSkipField(fieldAttributes)); }