< prev index next >
test/hotspot/jtreg/vmTestbase/nsk/stress/except/except004.java
Print this page
rev 50608 : imported patch jep181-rev5
@@ -209,19 +209,19 @@
// Prepare some items, which will be used by the test:
Object stringArray[] = new String[1];
Object integerValue = new Integer(0);
Object doubleValue = new Double(0);
Object trash = null;
- Field abraPrivateField;
Field abraIntegerField;
Field abraBooleanField;
+ Field extPrivateField;
try {
- abraPrivateField = Abra.class.getDeclaredField("DONT_TOUCH_ME");
abraIntegerField = Abra.class.getDeclaredField("MAIN_CYR_NUMBER");
abraBooleanField = Abra.class.getDeclaredField("NOT_AN_INTEGER");
+ extPrivateField = Ext.class.getDeclaredField("DONT_TOUCH_ME");
} catch (NoSuchFieldException nsfe) {
- out.println("Test initialisation failed: field not found in class Abra");
+ out.println("Test initialisation failed: field not found: " + nsfe.getMessage());
return 2;
}
Abra abra = new Abra("via public constructor");
Abra.Cadabra cadabra = new Abra.Cadabra();
@@ -367,11 +367,10 @@
}
// Check IllegalAccessException (positive):
try {
int junkIt = abraIntegerField.getInt(null); // legal - should pass
-// int junkIt = abraPrivateField.getInt(null); // illegal - should fail
if (TRACE_ON)
log[messages++] = "Success: IllegalAccessException (positive)";
} catch (IllegalAccessException iae) {
log[messages++] = "Failure: IllegalAccessException (positive)";
exitCode = 2;
@@ -381,12 +380,11 @@
skipped++;
}
// Check IllegalAccessException (negative):
try {
-// int junkIt = abraIntegerField.getInt(null); // legal - should pass
- int junkIt = abraPrivateField.getInt(null); // illegal - should fail
+ int junkIt = extPrivateField.getInt(null); // illegal - should fail
log[messages++] = "Failure: IllegalAccessException (negative)";
exitCode = 2; // FAILED
} catch (IllegalAccessException iae) {
if (TRACE_ON)
log[messages++] = "Success: IllegalAccessException (negative)";
@@ -510,11 +508,11 @@
// JCK-like exit status.
}
/**
* This class should be used to check <code>CloneNotSupportedException</code>,
- * <code>IllegalAccessException</code>, and <code>IllegalArgumentException</code>.
+ * and <code>IllegalArgumentException</code>.
* The class extends <code>except004</code> in order that its (protected)
* method <code>clone()</code> be available from <code>except004</code>.
*/
private static class Abra extends except004 {
/**
@@ -525,14 +523,10 @@
}
/**
* Will try to incorrectly access to this field from outside this class.
*/
- private static final int DONT_TOUCH_ME = 666;
- /**
- * Will try to incorrectly access to this field from outside this class.
- */
public static final int MAIN_CYR_NUMBER = 47;
/**
* Will try to get this field like <code>int<code> zero.
*/
public static final boolean NOT_AN_INTEGER = false;
@@ -549,5 +543,13 @@
*/
public Abra(String nothingSpecial) {
}
}
}
+
+/* Package accessible class that has non-accessible private member */
+class Ext {
+ /**
+ * Will try to incorrectly access to this field from outside this class.
+ */
+ private static final int DONT_TOUCH_ME = 666;
+}
< prev index next >