Extend test 064.
Extend to test direct access to fields and more exhaustively check field
modifiers for reflection.
Change-Id: I173e6e12b74e0c73d8d1001540560fd4923a9f86
diff --git a/test/064-field-access/src/Main.java b/test/064-field-access/src/Main.java
index cbf6b71..3b9a475 100644
--- a/test/064-field-access/src/Main.java
+++ b/test/064-field-access/src/Main.java
@@ -14,306 +14,647 @@
* limitations under the License.
*/
-import other.OtherPackage;
-
+import other.PublicClass;
import java.lang.reflect.Field;
/*
* Test field access through reflection.
*/
public class Main {
- public static void main(String[] args) {
- SubOther.main(null);
+ public static void main(String[] args) {
+ SubClass.main(null);
- try {
- GetNonexistent.main(null);
- System.err.println("Not expected to succeed");
- } catch (VerifyError fe) {
- // dalvik
- System.out.println("Got expected failure");
- } catch (NoSuchFieldError nsfe) {
- // reference
- System.out.println("Got expected failure");
+ try {
+ GetNonexistent.main(null);
+ System.err.println("Not expected to succeed");
+ } catch (VerifyError fe) {
+ // dalvik
+ System.out.println("Got expected failure");
+ } catch (NoSuchFieldError nsfe) {
+ // reference
+ System.out.println("Got expected failure");
+ }
+ }
+
+ /*
+ * Get the field specified by "field" from "obj".
+ *
+ * "type" determines which "get" call is made, e.g. 'B' turns into
+ * field.getByte().
+ *
+ * The "expectedException" must match the class of the exception thrown,
+ * or be null if no exception was expected.
+ *
+ * On success, the boxed value retrieved is returned.
+ */
+ public Object getValue(Field field, Object obj, char type,
+ Class expectedException) {
+ Object result = null;
+ try {
+ switch (type) {
+ case 'Z':
+ result = field.getBoolean(obj);
+ break;
+ case 'B':
+ result = field.getByte(obj);
+ break;
+ case 'S':
+ result = field.getShort(obj);
+ break;
+ case 'C':
+ result = field.getChar(obj);
+ break;
+ case 'I':
+ result = field.getInt(obj);
+ break;
+ case 'J':
+ result = field.getLong(obj);
+ break;
+ case 'F':
+ result = field.getFloat(obj);
+ break;
+ case 'D':
+ result = field.getDouble(obj);
+ break;
+ case 'L':
+ result = field.get(obj);
+ break;
+ default:
+ throw new RuntimeException("bad type '" + type + "'");
+ }
+
+ /* success; expected? */
+ if (expectedException != null) {
+ System.err.println("ERROR: call succeeded for field " + field +
+ " with a read of type '" + type +
+ "', was expecting " + expectedException);
+ Thread.dumpStack();
+ }
+ } catch (Exception ex) {
+ if (expectedException == null) {
+ System.err.println("ERROR: call failed unexpectedly: "
+ + ex.getClass());
+ ex.printStackTrace();
+ } else {
+ if (!expectedException.equals(ex.getClass())) {
+ System.err.println("ERROR: incorrect exception: wanted "
+ + expectedException.getName() + ", got "
+ + ex.getClass());
+ ex.printStackTrace();
}
+ }
}
- /*
- * Get the field specified by "field" from "obj".
- *
- * "type" determines which "get" call is made, e.g. 'B' turns into
- * field.getByte().
- *
- * The "expectedException" must match the class of the exception thrown,
- * or be null if no exception was expected.
- *
- * On success, the boxed value retrieved is returned.
- */
- public Object getValue(Field field, Object obj, char type,
- Class expectedException) {
-
- Object result = null;
- try {
- switch (type) {
- case 'Z':
- result = new Boolean(field.getBoolean(obj));
- break;
- case 'B':
- result = new Byte(field.getByte(obj));
- break;
- case 'S':
- result = new Short(field.getShort(obj));
- break;
- case 'C':
- result = new Character(field.getChar(obj));
- break;
- case 'I':
- result = new Integer(field.getInt(obj));
- break;
- case 'J':
- result = new Long(field.getLong(obj));
- break;
- case 'F':
- result = new Float(field.getFloat(obj));
- break;
- case 'D':
- result = new Double(field.getDouble(obj));
- break;
- case 'L':
- result = field.get(obj);
- break;
- default:
- throw new RuntimeException("bad type '" + type + "'");
- }
-
- /* success; expected? */
- if (expectedException != null) {
- Throwable th = new Throwable();
- System.err.println("ERROR: call succeeded, was expecting "
- + expectedException);
- th.printStackTrace();
- }
- } catch (Exception ex) {
- if (expectedException == null) {
- System.err.println("ERROR: call failed unexpectedly: "
- + ex.getClass());
- ex.printStackTrace();
- } else {
- if (!expectedException.equals(ex.getClass())) {
- System.err.println("ERROR: incorrect exception: wanted "
- + expectedException.getName() + ", got "
- + ex.getClass());
- ex.printStackTrace();
- }
- }
- }
-
- return result;
- }
+ return result;
+ }
}
/*
* Local class with some fields.
*/
class SamePackage {
- public byte pubByteField;
+ public boolean samePackagePublicBooleanInstanceField = true;
+ public byte samePackagePublicByteInstanceField = 2;
+ public char samePackagePublicCharInstanceField = 3;
+ public short samePackagePublicShortInstanceField = 4;
+ public int samePackagePublicIntInstanceField = 5;
+ public long samePackagePublicLongInstanceField = 6;
+ public float samePackagePublicFloatInstanceField = 7.0f;
+ public double samePackagePublicDoubleInstanceField = 8.0;
+ public Object samePackagePublicObjectInstanceField = "9";
- protected byte protByteField;
- protected Object protObjectField;
+ protected boolean samePackageProtectedBooleanInstanceField = true;
+ protected byte samePackageProtectedByteInstanceField = 10;
+ protected char samePackageProtectedCharInstanceField = 11;
+ protected short samePackageProtectedShortInstanceField = 12;
+ protected int samePackageProtectedIntInstanceField = 13;
+ protected long samePackageProtectedLongInstanceField = 14;
+ protected float samePackageProtectedFloatInstanceField = 15.0f;
+ protected double samePackageProtectedDoubleInstanceField = 16.0;
+ protected Object samePackageProtectedObjectInstanceField = "17";
- private float privFloatField;
+ private boolean samePackagePrivateBooleanInstanceField = true;
+ private byte samePackagePrivateByteInstanceField = 18;
+ private char samePackagePrivateCharInstanceField = 19;
+ private short samePackagePrivateShortInstanceField = 20;
+ private int samePackagePrivateIntInstanceField = 21;
+ private long samePackagePrivateLongInstanceField = 22;
+ private float samePackagePrivateFloatInstanceField = 23.0f;
+ private double samePackagePrivateDoubleInstanceField = 24.0;
+ private Object samePackagePrivateObjectInstanceField = "25";
+
+ /* package */ boolean samePackagePackageBooleanInstanceField = true;
+ /* package */ byte samePackagePackageByteInstanceField = 26;
+ /* package */ char samePackagePackageCharInstanceField = 27;
+ /* package */ short samePackagePackageShortInstanceField = 28;
+ /* package */ int samePackagePackageIntInstanceField = 29;
+ /* package */ long samePackagePackageLongInstanceField = 30;
+ /* package */ float samePackagePackageFloatInstanceField = 31.0f;
+ /* package */ double samePackagePackageDoubleInstanceField = 32.0;
+ /* package */ Object samePackagePackageObjectInstanceField = "33";
+
+ public static boolean samePackagePublicBooleanStaticField = true;
+ public static byte samePackagePublicByteStaticField = 34;
+ public static char samePackagePublicCharStaticField = 35;
+ public static short samePackagePublicShortStaticField = 36;
+ public static int samePackagePublicIntStaticField = 37;
+ public static long samePackagePublicLongStaticField = 38;
+ public static float samePackagePublicFloatStaticField = 39.0f;
+ public static double samePackagePublicDoubleStaticField = 40.0;
+ public static Object samePackagePublicObjectStaticField = "41";
+
+ protected static boolean samePackageProtectedBooleanStaticField = true;
+ protected static byte samePackageProtectedByteStaticField = 42;
+ protected static char samePackageProtectedCharStaticField = 43;
+ protected static short samePackageProtectedShortStaticField = 44;
+ protected static int samePackageProtectedIntStaticField = 45;
+ protected static long samePackageProtectedLongStaticField = 46;
+ protected static float samePackageProtectedFloatStaticField = 47.0f;
+ protected static double samePackageProtectedDoubleStaticField = 48.0;
+ protected static Object samePackageProtectedObjectStaticField = "49";
+
+ private static boolean samePackagePrivateBooleanStaticField = true;
+ private static byte samePackagePrivateByteStaticField = 50;
+ private static char samePackagePrivateCharStaticField = 51;
+ private static short samePackagePrivateShortStaticField = 52;
+ private static int samePackagePrivateIntStaticField = 53;
+ private static long samePackagePrivateLongStaticField = 54;
+ private static float samePackagePrivateFloatStaticField = 55.0f;
+ private static double samePackagePrivateDoubleStaticField = 56.0;
+ private static Object samePackagePrivateObjectStaticField = "57";
+
+ /* package */ static boolean samePackagePackageBooleanStaticField = true;
+ /* package */ static byte samePackagePackageByteStaticField = 58;
+ /* package */ static char samePackagePackageCharStaticField = 59;
+ /* package */ static short samePackagePackageShortStaticField = 60;
+ /* package */ static int samePackagePackageIntStaticField = 61;
+ /* package */ static long samePackagePackageLongStaticField = 62;
+ /* package */ static float samePackagePackageFloatStaticField = 63.0f;
+ /* package */ static double samePackagePackageDoubleStaticField = 64.0;
+ /* package */ static Object samePackagePackageObjectStaticField = "65";
}
/*
- * This is a sub-class of OtherPackage, which should be allowed to access
- * the various protected fields.
+ * This is a sub-class of other.PublicClass, which should be allowed to access
+ * the various protected fields declared by other.PublicClass and its parent
+ * other.ProtectedClass.
*/
-class SubOther extends OtherPackage {
+class SubClass extends PublicClass {
+ /*
+ * Perform the various tests.
+ *
+ * localInst.getValue() is performed using an instance of Main as the
+ * source of the reflection call. otherInst.getValue() uses a subclass
+ * of OtherPackage as the source.
+ */
+ public static void main(String[] args) {
+ SubClass subOther = new SubClass();
+ subOther.doDirectTests();
+ subOther.doReflectionTests();
+ }
- protected long protLongField = 0x1122334455667788L;
-
- /*
- * Perform the various tests.
- *
- * localInst.getValue() is performed using an instance of Main as the
- * source of the reflection call. otherInst.getValue() uses a subclass
- * of OtherPackage as the source.
- */
- public static void main(String[] args) {
- SubOther subOther = new SubOther();
- subOther.doTests();
+ private static void check(boolean b) {
+ if (!b) {
+ throw new Error("Test failed");
}
+ }
- public void doTests() {
- Class localClass = SamePackage.class;
- Class otherClass = OtherPackage.class;
- Field localPubByteField, localProtByteField, localProtObjectField,
- localPrivFloatField;
- Field otherPubCharField, otherProtShortField, otherProtObjectField,
- otherPkgDoubleField;
- Field subProtLongField;
- Main localInst = new Main();
- SamePackage samePkgInst = new SamePackage();
- OtherPackage otherPkgInst = new OtherPackage();
- Object plainObj = new Object();
+ public void doDirectTests() {
+ check(otherProtectedClassPublicBooleanInstanceField == true);
+ check(otherProtectedClassPublicByteInstanceField == 2);
+ check(otherProtectedClassPublicCharInstanceField == 3);
+ check(otherProtectedClassPublicShortInstanceField == 4);
+ check(otherProtectedClassPublicIntInstanceField == 5);
+ check(otherProtectedClassPublicLongInstanceField == 6);
+ check(otherProtectedClassPublicFloatInstanceField == 7.0f);
+ check(otherProtectedClassPublicDoubleInstanceField == 8.0);
+ check(otherProtectedClassPublicObjectInstanceField == "9");
- /*
- * Locate the various fields.
- */
- try {
- localPubByteField = localClass.getDeclaredField("pubByteField");
- localProtByteField = localClass.getDeclaredField("protByteField");
- localProtObjectField = localClass.getDeclaredField("protObjectField");
- localPrivFloatField = localClass.getDeclaredField("privFloatField");
+ check(otherProtectedClassProtectedBooleanInstanceField == true);
+ check(otherProtectedClassProtectedByteInstanceField == 10);
+ check(otherProtectedClassProtectedCharInstanceField == 11);
+ check(otherProtectedClassProtectedShortInstanceField == 12);
+ check(otherProtectedClassProtectedIntInstanceField == 13);
+ check(otherProtectedClassProtectedLongInstanceField == 14);
+ check(otherProtectedClassProtectedFloatInstanceField == 15.0f);
+ check(otherProtectedClassProtectedDoubleInstanceField == 16.0);
+ check(otherProtectedClassProtectedObjectInstanceField == "17");
- otherPubCharField = otherClass.getDeclaredField("pubCharField");
- otherProtShortField = otherClass.getDeclaredField("protShortField");
- otherProtObjectField = otherClass.getDeclaredField("protObjectField");
- otherPkgDoubleField = otherClass.getDeclaredField("pkgDoubleField");
+ // check(otherProtectedClassPrivateBooleanInstanceField == true);
+ // check(otherProtectedClassPrivateByteInstanceField == 18);
+ // check(otherProtectedClassPrivateCharInstanceField == 19);
+ // check(otherProtectedClassPrivateShortInstanceField == 20);
+ // check(otherProtectedClassPrivateIntInstanceField == 21);
+ // check(otherProtectedClassPrivateLongInstanceField == 22);
+ // check(otherProtectedClassPrivateFloatInstanceField == 23.0f);
+ // check(otherProtectedClassPrivateDoubleInstanceField == 24.0);
+ // check(otherProtectedClassPrivateObjectInstanceField == "25");
- subProtLongField = getClass().getDeclaredField("protLongField");
- } catch (NoSuchFieldException nsfe) {
- throw new RuntimeException(nsfe);
+ // check(otherProtectedClassPackageBooleanInstanceField == true);
+ // check(otherProtectedClassPackageByteInstanceField == 26);
+ // check(otherProtectedClassPackageCharInstanceField == 27);
+ // check(otherProtectedClassPackageShortInstanceField == 28);
+ // check(otherProtectedClassPackageIntInstanceField == 29);
+ // check(otherProtectedClassPackageLongInstanceField == 30);
+ // check(otherProtectedClassPackageFloatInstanceField == 31.0f);
+ // check(otherProtectedClassPackageDoubleInstanceField == 32.0);
+ // check(otherProtectedClassPackageObjectInstanceField == "33");
+
+ check(otherProtectedClassPublicBooleanStaticField == true);
+ check(otherProtectedClassPublicByteStaticField == 34);
+ check(otherProtectedClassPublicCharStaticField == 35);
+ check(otherProtectedClassPublicShortStaticField == 36);
+ check(otherProtectedClassPublicIntStaticField == 37);
+ check(otherProtectedClassPublicLongStaticField == 38);
+ check(otherProtectedClassPublicFloatStaticField == 39.0f);
+ check(otherProtectedClassPublicDoubleStaticField == 40.0);
+ check(otherProtectedClassPublicObjectStaticField == "41");
+
+ check(otherProtectedClassProtectedBooleanStaticField == true);
+ check(otherProtectedClassProtectedByteStaticField == 42);
+ check(otherProtectedClassProtectedCharStaticField == 43);
+ check(otherProtectedClassProtectedShortStaticField == 44);
+ check(otherProtectedClassProtectedIntStaticField == 45);
+ check(otherProtectedClassProtectedLongStaticField == 46);
+ check(otherProtectedClassProtectedFloatStaticField == 47.0f);
+ check(otherProtectedClassProtectedDoubleStaticField == 48.0);
+ check(otherProtectedClassProtectedObjectStaticField == "49");
+
+ // check(otherProtectedClassPrivateBooleanStaticField == true);
+ // check(otherProtectedClassPrivateByteStaticField == 50);
+ // check(otherProtectedClassPrivateCharStaticField == 51);
+ // check(otherProtectedClassPrivateShortStaticField == 52);
+ // check(otherProtectedClassPrivateIntStaticField == 53);
+ // check(otherProtectedClassPrivateLongStaticField == 54);
+ // check(otherProtectedClassPrivateFloatStaticField == 55.0f);
+ // check(otherProtectedClassPrivateDoubleStaticField == 56.0);
+ // check(otherProtectedClassPrivateObjectStaticField == "57");
+
+ // check(otherProtectedClassPackageBooleanStaticField == true);
+ // check(otherProtectedClassPackageByteStaticField == 58);
+ // check(otherProtectedClassPackageCharStaticField == 59);
+ // check(otherProtectedClassPackageShortStaticField == 60);
+ // check(otherProtectedClassPackageIntStaticField == 61);
+ // check(otherProtectedClassPackageLongStaticField == 62);
+ // check(otherProtectedClassPackageFloatStaticField == 63.0f);
+ // check(otherProtectedClassPackageDoubleStaticField == 64.0);
+ // check(otherProtectedClassPackageObjectStaticField == "65");
+
+ check(otherPublicClassPublicBooleanInstanceField == true);
+ check(otherPublicClassPublicByteInstanceField == -2);
+ check(otherPublicClassPublicCharInstanceField == (char)-3);
+ check(otherPublicClassPublicShortInstanceField == -4);
+ check(otherPublicClassPublicIntInstanceField == -5);
+ check(otherPublicClassPublicLongInstanceField == -6);
+ check(otherPublicClassPublicFloatInstanceField == -7.0f);
+ check(otherPublicClassPublicDoubleInstanceField == -8.0);
+ check(otherPublicClassPublicObjectInstanceField == "-9");
+
+ check(otherPublicClassProtectedBooleanInstanceField == true);
+ check(otherPublicClassProtectedByteInstanceField == -10);
+ check(otherPublicClassProtectedCharInstanceField == (char)-11);
+ check(otherPublicClassProtectedShortInstanceField == -12);
+ check(otherPublicClassProtectedIntInstanceField == -13);
+ check(otherPublicClassProtectedLongInstanceField == -14);
+ check(otherPublicClassProtectedFloatInstanceField == -15.0f);
+ check(otherPublicClassProtectedDoubleInstanceField == -16.0);
+ check(otherPublicClassProtectedObjectInstanceField == "-17");
+
+ // check(otherPublicClassPrivateBooleanInstanceField == true);
+ // check(otherPublicClassPrivateByteInstanceField == -18);
+ // check(otherPublicClassPrivateCharInstanceField == (char)-19);
+ // check(otherPublicClassPrivateShortInstanceField == -20);
+ // check(otherPublicClassPrivateIntInstanceField == -21);
+ // check(otherPublicClassPrivateLongInstanceField == -22);
+ // check(otherPublicClassPrivateFloatInstanceField == -23.0f);
+ // check(otherPublicClassPrivateDoubleInstanceField == -24.0);
+ // check(otherPublicClassPrivateObjectInstanceField == "-25");
+
+ // check(otherPublicClassPackageBooleanInstanceField == true);
+ // check(otherPublicClassPackageByteInstanceField == -26);
+ // check(otherPublicClassPackageCharInstanceField == (char)-27);
+ // check(otherPublicClassPackageShortInstanceField == -28);
+ // check(otherPublicClassPackageIntInstanceField == -29);
+ // check(otherPublicClassPackageLongInstanceField == -30);
+ // check(otherPublicClassPackageFloatInstanceField == -31.0f);
+ // check(otherPublicClassPackageDoubleInstanceField == -32.0);
+ // check(otherPublicClassPackageObjectInstanceField == "-33");
+
+ check(otherPublicClassPublicBooleanStaticField == true);
+ check(otherPublicClassPublicByteStaticField == -34);
+ check(otherPublicClassPublicCharStaticField == (char)-35);
+ check(otherPublicClassPublicShortStaticField == -36);
+ check(otherPublicClassPublicIntStaticField == -37);
+ check(otherPublicClassPublicLongStaticField == -38);
+ check(otherPublicClassPublicFloatStaticField == -39.0f);
+ check(otherPublicClassPublicDoubleStaticField == -40.0);
+ check(otherPublicClassPublicObjectStaticField == "-41");
+
+ check(otherPublicClassProtectedBooleanStaticField == true);
+ check(otherPublicClassProtectedByteStaticField == -42);
+ check(otherPublicClassProtectedCharStaticField == (char)-43);
+ check(otherPublicClassProtectedShortStaticField == -44);
+ check(otherPublicClassProtectedIntStaticField == -45);
+ check(otherPublicClassProtectedLongStaticField == -46);
+ check(otherPublicClassProtectedFloatStaticField == -47.0f);
+ check(otherPublicClassProtectedDoubleStaticField == -48.0);
+ check(otherPublicClassProtectedObjectStaticField == "-49");
+
+ // check(otherPublicClassPrivateBooleanStaticField == true);
+ // check(otherPublicClassPrivateByteStaticField == -50);
+ // check(otherPublicClassPrivateCharStaticField == (char)-51);
+ // check(otherPublicClassPrivateShortStaticField == -52);
+ // check(otherPublicClassPrivateIntStaticField == -53);
+ // check(otherPublicClassPrivateLongStaticField == -54);
+ // check(otherPublicClassPrivateFloatStaticField == -55.0f);
+ // check(otherPublicClassPrivateDoubleStaticField == -56.0);
+ // check(otherPublicClassPrivateObjectStaticField == "-57");
+
+ // check(otherPublicClassPackageBooleanStaticField == true);
+ // check(otherPublicClassPackageByteStaticField == -58);
+ // check(otherPublicClassPackageCharStaticField == (char)-59);
+ // check(otherPublicClassPackageShortStaticField == -60);
+ // check(otherPublicClassPackageIntStaticField == -61);
+ // check(otherPublicClassPackageLongStaticField == -62);
+ // check(otherPublicClassPackageFloatStaticField == -63.0f);
+ // check(otherPublicClassPackageDoubleStaticField == -64.0);
+ // check(otherPublicClassPackageObjectStaticField == "-65");
+
+ SamePackage s = new SamePackage();
+ check(s.samePackagePublicBooleanInstanceField == true);
+ check(s.samePackagePublicByteInstanceField == 2);
+ check(s.samePackagePublicCharInstanceField == 3);
+ check(s.samePackagePublicShortInstanceField == 4);
+ check(s.samePackagePublicIntInstanceField == 5);
+ check(s.samePackagePublicLongInstanceField == 6);
+ check(s.samePackagePublicFloatInstanceField == 7.0f);
+ check(s.samePackagePublicDoubleInstanceField == 8.0);
+ check(s.samePackagePublicObjectInstanceField == "9");
+
+ check(s.samePackageProtectedBooleanInstanceField == true);
+ check(s.samePackageProtectedByteInstanceField == 10);
+ check(s.samePackageProtectedCharInstanceField == 11);
+ check(s.samePackageProtectedShortInstanceField == 12);
+ check(s.samePackageProtectedIntInstanceField == 13);
+ check(s.samePackageProtectedLongInstanceField == 14);
+ check(s.samePackageProtectedFloatInstanceField == 15.0f);
+ check(s.samePackageProtectedDoubleInstanceField == 16.0);
+ check(s.samePackageProtectedObjectInstanceField == "17");
+
+ // check(s.samePackagePrivateBooleanInstanceField == true);
+ // check(s.samePackagePrivateByteInstanceField == 18);
+ // check(s.samePackagePrivateCharInstanceField == 19);
+ // check(s.samePackagePrivateShortInstanceField == 20);
+ // check(s.samePackagePrivateIntInstanceField == 21);
+ // check(s.samePackagePrivateLongInstanceField == 22);
+ // check(s.samePackagePrivateFloatInstanceField == 23.0f);
+ // check(s.samePackagePrivateDoubleInstanceField == 24.0);
+ // check(s.samePackagePrivateObjectInstanceField == "25");
+
+ check(s.samePackagePackageBooleanInstanceField == true);
+ check(s.samePackagePackageByteInstanceField == 26);
+ check(s.samePackagePackageCharInstanceField == 27);
+ check(s.samePackagePackageShortInstanceField == 28);
+ check(s.samePackagePackageIntInstanceField == 29);
+ check(s.samePackagePackageLongInstanceField == 30);
+ check(s.samePackagePackageFloatInstanceField == 31.0f);
+ check(s.samePackagePackageDoubleInstanceField == 32.0);
+ check(s.samePackagePackageObjectInstanceField == "33");
+
+ check(SamePackage.samePackagePublicBooleanStaticField == true);
+ check(SamePackage.samePackagePublicByteStaticField == 34);
+ check(SamePackage.samePackagePublicCharStaticField == 35);
+ check(SamePackage.samePackagePublicShortStaticField == 36);
+ check(SamePackage.samePackagePublicIntStaticField == 37);
+ check(SamePackage.samePackagePublicLongStaticField == 38);
+ check(SamePackage.samePackagePublicFloatStaticField == 39.0f);
+ check(SamePackage.samePackagePublicDoubleStaticField == 40.0);
+ check(SamePackage.samePackagePublicObjectStaticField == "41");
+
+ check(SamePackage.samePackageProtectedBooleanStaticField == true);
+ check(SamePackage.samePackageProtectedByteStaticField == 42);
+ check(SamePackage.samePackageProtectedCharStaticField == 43);
+ check(SamePackage.samePackageProtectedShortStaticField == 44);
+ check(SamePackage.samePackageProtectedIntStaticField == 45);
+ check(SamePackage.samePackageProtectedLongStaticField == 46);
+ check(SamePackage.samePackageProtectedFloatStaticField == 47.0f);
+ check(SamePackage.samePackageProtectedDoubleStaticField == 48.0);
+ check(SamePackage.samePackageProtectedObjectStaticField == "49");
+
+ // check(SamePackage.samePackagePrivateBooleanStaticField == true);
+ // check(SamePackage.samePackagePrivateByteStaticField == 50);
+ // check(SamePackage.samePackagePrivateCharStaticField == 51);
+ // check(SamePackage.samePackagePrivateShortStaticField == 52);
+ // check(SamePackage.samePackagePrivateIntStaticField == 53);
+ // check(SamePackage.samePackagePrivateLongStaticField == 54);
+ // check(SamePackage.samePackagePrivateFloatStaticField == 55.0f);
+ // check(SamePackage.samePackagePrivateDoubleStaticField == 56.0);
+ // check(SamePackage.samePackagePrivateObjectStaticField == "57");
+
+ check(SamePackage.samePackagePackageBooleanStaticField == true);
+ check(SamePackage.samePackagePackageByteStaticField == 58);
+ check(SamePackage.samePackagePackageCharStaticField == 59);
+ check(SamePackage.samePackagePackageShortStaticField == 60);
+ check(SamePackage.samePackagePackageIntStaticField == 61);
+ check(SamePackage.samePackagePackageLongStaticField == 62);
+ check(SamePackage.samePackagePackageFloatStaticField == 63.0f);
+ check(SamePackage.samePackagePackageDoubleStaticField == 64.0);
+ check(SamePackage.samePackagePackageObjectStaticField == "65");
+ }
+
+ private static boolean compatibleTypes(char srcType, char dstType) {
+ switch (dstType) {
+ case 'Z':
+ case 'C':
+ case 'B':
+ return srcType == dstType;
+ case 'S':
+ return srcType == 'B' || srcType == 'S';
+ case 'I':
+ return srcType == 'B' || srcType == 'C' || srcType == 'S' || srcType == 'I';
+ case 'J':
+ return srcType == 'B' || srcType == 'C' || srcType == 'S' || srcType == 'I' ||
+ srcType == 'J';
+ case 'F':
+ return srcType == 'B' || srcType == 'C' || srcType == 'S' || srcType == 'I' ||
+ srcType == 'J' || srcType == 'F';
+ case 'D':
+ return srcType == 'B' || srcType == 'C' || srcType == 'S' || srcType == 'I' ||
+ srcType == 'J' || srcType == 'F' || srcType == 'D';
+ case 'L':
+ return true;
+ default:
+ throw new Error("Unexpected type char " + dstType);
+ }
+ }
+
+ public void doReflectionTests() {
+ String typeChars = "ZBCSIJFDL";
+ String fieldNameForTypeChar[] = {
+ "Boolean",
+ "Byte",
+ "Char",
+ "Short",
+ "Int",
+ "Long",
+ "Float",
+ "Double",
+ "Object"
+ };
+
+ Main localInst = new Main();
+ SamePackage samePkgInst = new SamePackage();
+ PublicClass otherPkgInst = new PublicClass();
+ Object plainObj = new Object();
+
+ for (int round = 0; round < 3; round++) {
+ Object validInst;
+ Field[] fields;
+ boolean same_package = false;
+ switch (round) {
+ case 0:
+ validInst = new SamePackage();
+ fields = SamePackage.class.getDeclaredFields();
+ check(fields.length == 72);
+ same_package = true;
+ break;
+ case 1:
+ validInst = new PublicClass();
+ fields = PublicClass.class.getDeclaredFields();
+ check(fields.length == 72);
+ break;
+ default:
+ validInst = new PublicClass();
+ fields = PublicClass.class.getSuperclass().getDeclaredFields();
+ check(fields.length == 72);
+ break;
+ }
+ for (Field f : fields) {
+ char typeChar = '?';
+ for (int i = 0; i < fieldNameForTypeChar.length; i++) {
+ if (f.getName().contains(fieldNameForTypeChar[i])) {
+ typeChar = typeChars.charAt(i);
+ break;
+ }
+ }
+ // Check access or lack of to field.
+ Class<?> subClassAccessExceptionClass = null;
+ if (f.getName().contains("Private") ||
+ (!same_package && f.getName().contains("Package"))) {
+ // ART deliberately doesn't throw IllegalAccessException.
+ // subClassAccessExceptionClass = IllegalAccessException.class;
+ }
+ Class<?> mainClassAccessExceptionClass = null;
+ if (f.getName().contains("Private") ||
+ (!same_package && f.getName().contains("Package")) ||
+ (!same_package && f.getName().contains("Protected"))) {
+ // ART deliberately doesn't throw IllegalAccessException.
+ // mainClassAccessExceptionClass = IllegalAccessException.class;
}
- Class<?> accessExceptionClass = null; // art deliberately doesn't throw IllegalAccessException.
+ this.getValue(f, validInst, typeChar, subClassAccessExceptionClass);
+ localInst.getValue(f, validInst, typeChar, mainClassAccessExceptionClass);
- /*
- * Get a public field from a class in the same package.
- */
- localInst.getValue(localPubByteField, samePkgInst, 'B', null);
+ // Check things that can get beyond the IllegalAccessException.
+ if (subClassAccessExceptionClass == null) {
+ // Check NPE.
+ Class<?> npeClass = null;
+ if (!f.getName().contains("Static")) {
+ npeClass = NullPointerException.class;
+ }
- /*
- * Get a protected field from a class in the same package.
- */
- this.getValue(localProtByteField, samePkgInst, 'B', null);
+ this.getValue(f, null, typeChar, npeClass);
+ if (mainClassAccessExceptionClass == null) {
+ localInst.getValue(f, null, typeChar, npeClass);
+ }
- /*
- * Get a private field from a class in the same package.
- */
- this.getValue(localPrivFloatField, samePkgInst, 'F', accessExceptionClass);
-
- /*
- * Get a protected field from otherInst's superclass.
- *
- * We can get at "this.protShortField" but not
- * "otherPkgInst.protShortField" because we can only access
- * protected fields in instances of our class -- being a subclass
- * of OtherPackage does not allow us to modify protected fields in
- * all other subclasses of OtherPackage.
- */
- this.getValue(otherProtShortField, this, 'S', null);
- this.getValue(otherProtShortField, otherPkgInst, 'S', accessExceptionClass);
- this.getValue(otherPkgDoubleField, otherPkgInst, 'D', accessExceptionClass);
-
- /*
- * Null object.
- */
- localInst.getValue(localPubByteField, null, 'B', NullPointerException.class);
-
- this.getValue(subProtLongField, null, 'J', NullPointerException.class);
-
- this.getValue(localPrivFloatField, null, 'F', NullPointerException.class);
-
- localInst.getValue(otherProtShortField, null, 'S', NullPointerException.class);
- this.getValue(otherProtShortField, null, 'S', NullPointerException.class);
- this.getValue(otherPkgDoubleField, null, 'D', NullPointerException.class);
-
- localInst.getValue(otherProtShortField, null, 'Z', NullPointerException.class);
- this.getValue(subProtLongField, null, 'Z', NullPointerException.class);
-
- /*
- * Valid object, wrong field type.
- */
- this.getValue(subProtLongField, this, 'J', null);
- this.getValue(localProtByteField, samePkgInst, 'Z', IllegalArgumentException.class);
- this.getValue(subProtLongField, this, 'Z', IllegalArgumentException.class);
- this.getValue(localPrivFloatField, this, 'Z', IllegalArgumentException.class);
- this.getValue(localPrivFloatField, this, 'Z', IllegalArgumentException.class);
- localInst.getValue(otherProtShortField, otherPkgInst, 'Z', IllegalArgumentException.class);
- this.getValue(otherProtShortField, otherPkgInst, 'Z', IllegalArgumentException.class);
-
- /*
- * Wrong object.
- */
- this.getValue(subProtLongField, plainObj, 'J', IllegalArgumentException.class);
-
- /* wrong object + private field */
- this.getValue(localPrivFloatField, plainObj, 'F', IllegalArgumentException.class);
-
- /* wrong object + wrong field type */
- this.getValue(subProtLongField, plainObj, 'Z', IllegalArgumentException.class);
-
- /* wrong object + invalid access */
- localInst.getValue(otherProtShortField, plainObj, 'S', IllegalArgumentException.class);
- this.getValue(otherProtShortField, plainObj, 'S', IllegalArgumentException.class);
-
- System.out.println("good");
- }
-
- /*
- * [this is a clone of Main.getValue() -- the class issuing the
- * reflection call is significant]
- */
- public Object getValue(Field field, Object obj, char type,
- Class expectedException) {
-
- Object result = null;
- try {
- switch (type) {
- case 'Z':
- result = new Boolean(field.getBoolean(obj));
- break;
- case 'B':
- result = new Byte(field.getByte(obj));
- break;
- case 'S':
- result = new Short(field.getShort(obj));
- break;
- case 'C':
- result = new Character(field.getChar(obj));
- break;
- case 'I':
- result = new Integer(field.getInt(obj));
- break;
- case 'J':
- result = new Long(field.getLong(obj));
- break;
- case 'F':
- result = new Float(field.getFloat(obj));
- break;
- case 'D':
- result = new Double(field.getDouble(obj));
- break;
- case 'L':
- result = field.get(obj);
- break;
- default:
- throw new RuntimeException("bad type '" + type + "'");
+ // Check access of wrong field type for valid instance.
+ for (int i = 0; i < typeChars.length(); i++) {
+ char otherChar = typeChars.charAt(i);
+ Class<?> illArgClass = compatibleTypes(typeChar, otherChar) ?
+ null : IllegalArgumentException.class;
+ this.getValue(f, validInst, otherChar, illArgClass);
+ if (mainClassAccessExceptionClass == null) {
+ localInst.getValue(f, validInst, otherChar, illArgClass);
}
+ }
- /* success; expected? */
- if (expectedException != null) {
- Throwable th = new Throwable();
- System.err.println("ERROR: call succeeded, was expecting "
- + expectedException);
- th.printStackTrace();
+ if (!f.getName().contains("Static")) {
+ // Wrong object.
+ this.getValue(f, plainObj, typeChar, IllegalArgumentException.class);
+ if (mainClassAccessExceptionClass == null) {
+ localInst.getValue(f, plainObj, typeChar, IllegalArgumentException.class);
}
- } catch (Exception ex) {
- if (expectedException == null) {
- System.err.println("ERROR: call failed unexpectedly: "
- + ex.getClass());
- ex.printStackTrace();
- } else {
- if (!expectedException.equals(ex.getClass())) {
- System.err.println("ERROR: incorrect exception: wanted "
- + expectedException.getName() + ", got "
- + ex.getClass());
- ex.printStackTrace();
- }
- }
+ }
}
+ }
+ }
+ System.out.println("good");
+ }
- return result;
+ /*
+ * [this is a clone of Main.getValue() -- the class issuing the
+ * reflection call is significant]
+ */
+ public Object getValue(Field field, Object obj, char type,
+ Class expectedException) {
+
+ Object result = null;
+ try {
+ switch (type) {
+ case 'Z':
+ result = field.getBoolean(obj);
+ break;
+ case 'B':
+ result = field.getByte(obj);
+ break;
+ case 'S':
+ result = field.getShort(obj);
+ break;
+ case 'C':
+ result = field.getChar(obj);
+ break;
+ case 'I':
+ result = field.getInt(obj);
+ break;
+ case 'J':
+ result = field.getLong(obj);
+ break;
+ case 'F':
+ result = field.getFloat(obj);
+ break;
+ case 'D':
+ result = field.getDouble(obj);
+ break;
+ case 'L':
+ result = field.get(obj);
+ break;
+ default:
+ throw new RuntimeException("bad type '" + type + "'");
+ }
+
+ /* success; expected? */
+ if (expectedException != null) {
+ System.err.println("ERROR: call succeeded for field " + field +
+ " with a read of type '" + type +
+ "', was expecting " + expectedException);
+ Thread.dumpStack();
+ }
+ } catch (Exception ex) {
+ if (expectedException == null) {
+ System.err.println("ERROR: call failed unexpectedly: "
+ + ex.getClass());
+ ex.printStackTrace();
+ } else {
+ if (!expectedException.equals(ex.getClass())) {
+ System.err.println("ERROR: incorrect exception: wanted "
+ + expectedException.getName() + ", got "
+ + ex.getClass());
+ ex.printStackTrace();
+ }
+ }
}
+ return result;
+ }
}
diff --git a/test/064-field-access/src/other/OtherPackage.java b/test/064-field-access/src/other/OtherPackage.java
deleted file mode 100644
index 5d12fc8..0000000
--- a/test/064-field-access/src/other/OtherPackage.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * Copyright (C) 2008 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package other;
-
-/*
- * Declare a few fields to reflect upon.
- */
-public class OtherPackage {
- public char pubCharField = 0x8765;
-
- protected short protShortField = 0x1234;
- protected Object protObjectField = "blah";
-
- double pkgDoubleField = 3.141592654;
-}
diff --git a/test/064-field-access/src/other/ProtectedClass.java b/test/064-field-access/src/other/ProtectedClass.java
new file mode 100644
index 0000000..779aa1d
--- /dev/null
+++ b/test/064-field-access/src/other/ProtectedClass.java
@@ -0,0 +1,100 @@
+/*
+ * Copyright (C) 2012 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package other;
+
+// Class that cannot be accessed outside of this package.
+class ProtectedClass {
+ public boolean otherProtectedClassPublicBooleanInstanceField = true;
+ public byte otherProtectedClassPublicByteInstanceField = 2;
+ public char otherProtectedClassPublicCharInstanceField = 3;
+ public short otherProtectedClassPublicShortInstanceField = 4;
+ public int otherProtectedClassPublicIntInstanceField = 5;
+ public long otherProtectedClassPublicLongInstanceField = 6;
+ public float otherProtectedClassPublicFloatInstanceField = 7.0f;
+ public double otherProtectedClassPublicDoubleInstanceField = 8.0;
+ public Object otherProtectedClassPublicObjectInstanceField = "9";
+
+ protected boolean otherProtectedClassProtectedBooleanInstanceField = true;
+ protected byte otherProtectedClassProtectedByteInstanceField = 10;
+ protected char otherProtectedClassProtectedCharInstanceField = 11;
+ protected short otherProtectedClassProtectedShortInstanceField = 12;
+ protected int otherProtectedClassProtectedIntInstanceField = 13;
+ protected long otherProtectedClassProtectedLongInstanceField = 14;
+ protected float otherProtectedClassProtectedFloatInstanceField = 15.0f;
+ protected double otherProtectedClassProtectedDoubleInstanceField = 16.0;
+ protected Object otherProtectedClassProtectedObjectInstanceField = "17";
+
+ private boolean otherProtectedClassPrivateBooleanInstanceField = true;
+ private byte otherProtectedClassPrivateByteInstanceField = 18;
+ private char otherProtectedClassPrivateCharInstanceField = 19;
+ private short otherProtectedClassPrivateShortInstanceField = 20;
+ private int otherProtectedClassPrivateIntInstanceField = 21;
+ private long otherProtectedClassPrivateLongInstanceField = 22;
+ private float otherProtectedClassPrivateFloatInstanceField = 23.0f;
+ private double otherProtectedClassPrivateDoubleInstanceField = 24.0;
+ private Object otherProtectedClassPrivateObjectInstanceField = "25";
+
+ /* package */ boolean otherProtectedClassPackageBooleanInstanceField = true;
+ /* package */ byte otherProtectedClassPackageByteInstanceField = 26;
+ /* package */ char otherProtectedClassPackageCharInstanceField = 27;
+ /* package */ short otherProtectedClassPackageShortInstanceField = 28;
+ /* package */ int otherProtectedClassPackageIntInstanceField = 29;
+ /* package */ long otherProtectedClassPackageLongInstanceField = 30;
+ /* package */ float otherProtectedClassPackageFloatInstanceField = 31.0f;
+ /* package */ double otherProtectedClassPackageDoubleInstanceField = 32.0;
+ /* package */ Object otherProtectedClassPackageObjectInstanceField = "33";
+
+ public static boolean otherProtectedClassPublicBooleanStaticField = true;
+ public static byte otherProtectedClassPublicByteStaticField = 34;
+ public static char otherProtectedClassPublicCharStaticField = 35;
+ public static short otherProtectedClassPublicShortStaticField = 36;
+ public static int otherProtectedClassPublicIntStaticField = 37;
+ public static long otherProtectedClassPublicLongStaticField = 38;
+ public static float otherProtectedClassPublicFloatStaticField = 39.0f;
+ public static double otherProtectedClassPublicDoubleStaticField = 40.0;
+ public static Object otherProtectedClassPublicObjectStaticField = "41";
+
+ protected static boolean otherProtectedClassProtectedBooleanStaticField = true;
+ protected static byte otherProtectedClassProtectedByteStaticField = 42;
+ protected static char otherProtectedClassProtectedCharStaticField = 43;
+ protected static short otherProtectedClassProtectedShortStaticField = 44;
+ protected static int otherProtectedClassProtectedIntStaticField = 45;
+ protected static long otherProtectedClassProtectedLongStaticField = 46;
+ protected static float otherProtectedClassProtectedFloatStaticField = 47.0f;
+ protected static double otherProtectedClassProtectedDoubleStaticField = 48.0;
+ protected static Object otherProtectedClassProtectedObjectStaticField = "49";
+
+ private static boolean otherProtectedClassPrivateBooleanStaticField = true;
+ private static byte otherProtectedClassPrivateByteStaticField = 50;
+ private static char otherProtectedClassPrivateCharStaticField = 51;
+ private static short otherProtectedClassPrivateShortStaticField = 52;
+ private static int otherProtectedClassPrivateIntStaticField = 53;
+ private static long otherProtectedClassPrivateLongStaticField = 54;
+ private static float otherProtectedClassPrivateFloatStaticField = 55.0f;
+ private static double otherProtectedClassPrivateDoubleStaticField = 56.0;
+ private static Object otherProtectedClassPrivateObjectStaticField = "57";
+
+ /* package */ static boolean otherProtectedClassPackageBooleanStaticField = true;
+ /* package */ static byte otherProtectedClassPackageByteStaticField = 58;
+ /* package */ static char otherProtectedClassPackageCharStaticField = 59;
+ /* package */ static short otherProtectedClassPackageShortStaticField = 60;
+ /* package */ static int otherProtectedClassPackageIntStaticField = 61;
+ /* package */ static long otherProtectedClassPackageLongStaticField = 62;
+ /* package */ static float otherProtectedClassPackageFloatStaticField = 63.0f;
+ /* package */ static double otherProtectedClassPackageDoubleStaticField = 64.0;
+ /* package */ static Object otherProtectedClassPackageObjectStaticField = "65";
+}
diff --git a/test/064-field-access/src/other/PublicClass.java b/test/064-field-access/src/other/PublicClass.java
new file mode 100644
index 0000000..1653973
--- /dev/null
+++ b/test/064-field-access/src/other/PublicClass.java
@@ -0,0 +1,100 @@
+/*
+ * Copyright (C) 2012 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package other;
+
+// Class that makes the ProtectedClass sub-classable by classes outside of package other.
+public class PublicClass extends ProtectedClass {
+ public boolean otherPublicClassPublicBooleanInstanceField = true;
+ public byte otherPublicClassPublicByteInstanceField = -2;
+ public char otherPublicClassPublicCharInstanceField = (char)-3;
+ public short otherPublicClassPublicShortInstanceField = -4;
+ public int otherPublicClassPublicIntInstanceField = -5;
+ public long otherPublicClassPublicLongInstanceField = -6;
+ public float otherPublicClassPublicFloatInstanceField = -7.0f;
+ public double otherPublicClassPublicDoubleInstanceField = -8.0;
+ public Object otherPublicClassPublicObjectInstanceField = "-9";
+
+ protected boolean otherPublicClassProtectedBooleanInstanceField = true;
+ protected byte otherPublicClassProtectedByteInstanceField = -10;
+ protected char otherPublicClassProtectedCharInstanceField = (char)-11;
+ protected short otherPublicClassProtectedShortInstanceField = -12;
+ protected int otherPublicClassProtectedIntInstanceField = -13;
+ protected long otherPublicClassProtectedLongInstanceField = -14;
+ protected float otherPublicClassProtectedFloatInstanceField = -15.0f;
+ protected double otherPublicClassProtectedDoubleInstanceField = -16.0;
+ protected Object otherPublicClassProtectedObjectInstanceField = "-17";
+
+ private boolean otherPublicClassPrivateBooleanInstanceField = true;
+ private byte otherPublicClassPrivateByteInstanceField = -18;
+ private char otherPublicClassPrivateCharInstanceField = (char)-19;
+ private short otherPublicClassPrivateShortInstanceField = -20;
+ private int otherPublicClassPrivateIntInstanceField = -21;
+ private long otherPublicClassPrivateLongInstanceField = -22;
+ private float otherPublicClassPrivateFloatInstanceField = -23.0f;
+ private double otherPublicClassPrivateDoubleInstanceField = -24.0;
+ private Object otherPublicClassPrivateObjectInstanceField = "-25";
+
+ /* package */ boolean otherPublicClassPackageBooleanInstanceField = true;
+ /* package */ byte otherPublicClassPackageByteInstanceField = -26;
+ /* package */ char otherPublicClassPackageCharInstanceField = (char)-27;
+ /* package */ short otherPublicClassPackageShortInstanceField = -28;
+ /* package */ int otherPublicClassPackageIntInstanceField = -29;
+ /* package */ long otherPublicClassPackageLongInstanceField = -30;
+ /* package */ float otherPublicClassPackageFloatInstanceField = -31.0f;
+ /* package */ double otherPublicClassPackageDoubleInstanceField = -32.0;
+ /* package */ Object otherPublicClassPackageObjectInstanceField = "-33";
+
+ public static boolean otherPublicClassPublicBooleanStaticField = true;
+ public static byte otherPublicClassPublicByteStaticField = -34;
+ public static char otherPublicClassPublicCharStaticField = (char)-35;
+ public static short otherPublicClassPublicShortStaticField = -36;
+ public static int otherPublicClassPublicIntStaticField = -37;
+ public static long otherPublicClassPublicLongStaticField = -38;
+ public static float otherPublicClassPublicFloatStaticField = -39.0f;
+ public static double otherPublicClassPublicDoubleStaticField = -40.0;
+ public static Object otherPublicClassPublicObjectStaticField = "-41";
+
+ protected static boolean otherPublicClassProtectedBooleanStaticField = true;
+ protected static byte otherPublicClassProtectedByteStaticField = -42;
+ protected static char otherPublicClassProtectedCharStaticField = (char)-43;
+ protected static short otherPublicClassProtectedShortStaticField = -44;
+ protected static int otherPublicClassProtectedIntStaticField = -45;
+ protected static long otherPublicClassProtectedLongStaticField = -46;
+ protected static float otherPublicClassProtectedFloatStaticField = -47.0f;
+ protected static double otherPublicClassProtectedDoubleStaticField = -48.0;
+ protected static Object otherPublicClassProtectedObjectStaticField = "-49";
+
+ private static boolean otherPublicClassPrivateBooleanStaticField = true;
+ private static byte otherPublicClassPrivateByteStaticField = -50;
+ private static char otherPublicClassPrivateCharStaticField = (char)-51;
+ private static short otherPublicClassPrivateShortStaticField = -52;
+ private static int otherPublicClassPrivateIntStaticField = -53;
+ private static long otherPublicClassPrivateLongStaticField = -54;
+ private static float otherPublicClassPrivateFloatStaticField = -55.0f;
+ private static double otherPublicClassPrivateDoubleStaticField = -56.0;
+ private static Object otherPublicClassPrivateObjectStaticField = "-57";
+
+ /* package */ static boolean otherPublicClassPackageBooleanStaticField = true;
+ /* package */ static byte otherPublicClassPackageByteStaticField = -58;
+ /* package */ static char otherPublicClassPackageCharStaticField = (char)-59;
+ /* package */ static short otherPublicClassPackageShortStaticField = -60;
+ /* package */ static int otherPublicClassPackageIntStaticField = -61;
+ /* package */ static long otherPublicClassPackageLongStaticField = -62;
+ /* package */ static float otherPublicClassPackageFloatStaticField = -63.0f;
+ /* package */ static double otherPublicClassPackageDoubleStaticField = -64.0;
+ /* package */ static Object otherPublicClassPackageObjectStaticField = "-65";
+}