32 * @run main ClassFileInstaller sun.hotspot.WhiteBox 33 * sun.hotspot.WhiteBox$WhiteBoxPermission 34 * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI AccessCheckSuper 35 */ 36 37 import static jdk.test.lib.Asserts.*; 38 39 public class AccessCheckSuper { 40 41 // Test that when a class cannot access its super class the message 42 // contains both "superclass" text and module text. 43 public static void main(String args[]) throws Throwable { 44 45 // Get the class loader for AccessCheckSuper and assume it's also used to 46 // load class p2.c2 and class p3.c3. 47 ClassLoader this_cldr = AccessCheckSuper.class.getClassLoader(); 48 49 // Define a module for p2. 50 Object m2x = ModuleHelper.ModuleObject("module_two", this_cldr, new String[] { "p2" }); 51 assertNotNull(m2x, "Module should not be null"); 52 ModuleHelper.DefineModule(m2x, "9.0", "m2x/there", new String[] { "p2" }); 53 54 // Define a module for p3. 55 Object m3x = ModuleHelper.ModuleObject("module_three", this_cldr, new String[] { "p3" }); 56 assertNotNull(m3x, "Module should not be null"); 57 ModuleHelper.DefineModule(m3x, "9.0", "m3x/there", new String[] { "p3" }); 58 59 // Since a readability edge has not been established between module_two 60 // and module_three, p3.c3 cannot read its superclass p2.c2. 61 try { 62 Class p3_c3_class = Class.forName("p3.c3"); 63 throw new RuntimeException("Failed to get IAE (can't read superclass)"); 64 } catch (IllegalAccessError e) { 65 if (!e.getMessage().contains("superclass access check failed") || 66 !e.getMessage().contains("does not read")) { 67 throw new RuntimeException("Wrong message: " + e.getMessage()); 68 } 69 } 70 } 71 } | 32 * @run main ClassFileInstaller sun.hotspot.WhiteBox 33 * sun.hotspot.WhiteBox$WhiteBoxPermission 34 * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI AccessCheckSuper 35 */ 36 37 import static jdk.test.lib.Asserts.*; 38 39 public class AccessCheckSuper { 40 41 // Test that when a class cannot access its super class the message 42 // contains both "superclass" text and module text. 43 public static void main(String args[]) throws Throwable { 44 45 // Get the class loader for AccessCheckSuper and assume it's also used to 46 // load class p2.c2 and class p3.c3. 47 ClassLoader this_cldr = AccessCheckSuper.class.getClassLoader(); 48 49 // Define a module for p2. 50 Object m2x = ModuleHelper.ModuleObject("module_two", this_cldr, new String[] { "p2" }); 51 assertNotNull(m2x, "Module should not be null"); 52 ModuleHelper.DefineModule(m2x, false, "9.0", "m2x/there", new String[] { "p2" }); 53 54 // Define a module for p3. 55 Object m3x = ModuleHelper.ModuleObject("module_three", this_cldr, new String[] { "p3" }); 56 assertNotNull(m3x, "Module should not be null"); 57 ModuleHelper.DefineModule(m3x, false, "9.0", "m3x/there", new String[] { "p3" }); 58 59 // Since a readability edge has not been established between module_two 60 // and module_three, p3.c3 cannot read its superclass p2.c2. 61 try { 62 Class p3_c3_class = Class.forName("p3.c3"); 63 throw new RuntimeException("Failed to get IAE (can't read superclass)"); 64 } catch (IllegalAccessError e) { 65 if (!e.getMessage().contains("superclass access check failed") || 66 !e.getMessage().contains("does not read")) { 67 throw new RuntimeException("Wrong message: " + e.getMessage()); 68 } 69 } 70 } 71 } |