< prev index next >

test/hotspot/jtreg/vmTestbase/nsk/stress/except/except004.java

Print this page
rev 50608 : imported patch jep181-rev5

*** 209,227 **** // 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; try { - abraPrivateField = Abra.class.getDeclaredField("DONT_TOUCH_ME"); abraIntegerField = Abra.class.getDeclaredField("MAIN_CYR_NUMBER"); abraBooleanField = Abra.class.getDeclaredField("NOT_AN_INTEGER"); } catch (NoSuchFieldException nsfe) { ! out.println("Test initialisation failed: field not found in class Abra"); return 2; } Abra abra = new Abra("via public constructor"); Abra.Cadabra cadabra = new Abra.Cadabra(); --- 209,227 ---- // 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 abraIntegerField; Field abraBooleanField; + Field extPrivateField; try { 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: " + nsfe.getMessage()); return 2; } Abra abra = new Abra("via public constructor"); Abra.Cadabra cadabra = new Abra.Cadabra();
*** 367,377 **** } // 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; --- 367,376 ----
*** 381,392 **** skipped++; } // Check IllegalAccessException (negative): try { ! // int junkIt = abraIntegerField.getInt(null); // legal - should pass ! int junkIt = abraPrivateField.getInt(null); // illegal - should fail log[messages++] = "Failure: IllegalAccessException (negative)"; exitCode = 2; // FAILED } catch (IllegalAccessException iae) { if (TRACE_ON) log[messages++] = "Success: IllegalAccessException (negative)"; --- 380,390 ---- skipped++; } // Check IllegalAccessException (negative): try { ! 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,520 **** // JCK-like exit status. } /** * This class should be used to check <code>CloneNotSupportedException</code>, ! * <code>IllegalAccessException</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 { /** --- 508,518 ---- // JCK-like exit status. } /** * This class should be used to check <code>CloneNotSupportedException</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,538 **** } /** * 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; --- 523,532 ----
*** 549,553 **** --- 543,555 ---- */ 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 >