29 * @build sun.hotspot.WhiteBox
30 * @compile/module=java.base java/lang/ModuleHelper.java
31 * @run main ClassFileInstaller sun.hotspot.WhiteBox
32 * sun.hotspot.WhiteBox$WhiteBoxPermission
33 * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI AccessCheckJavaBase
34 */
35
36 import static jdk.test.lib.Asserts.*;
37
38 public class AccessCheckJavaBase {
39
40 // Test that a class defined to module_two always can read java.base.
41 public static void main(String args[]) throws Throwable {
42 // Get the class loader for AccessCheckJavaBase and assume it's also used to
43 // load class p2.c2.
44 ClassLoader this_cldr = AccessCheckJavaBase.class.getClassLoader();
45
46 // Define a module for p2.
47 Object m2x = ModuleHelper.ModuleObject("module_two", this_cldr, new String[] { "p2" });
48 assertNotNull(m2x, "Module should not be null");
49 ModuleHelper.DefineModule(m2x, "9.0", "m2x/there", new String[] { "p2" });
50
51 // p2.c2 can read its superclass java.lang.Object defined within java.base
52 try {
53 Class p2_c2_class = Class.forName("p2.c2");
54 } catch (IllegalAccessError e) {
55 throw new RuntimeException("Test Failed" + e.getMessage());
56 }
57 }
58 }
|
29 * @build sun.hotspot.WhiteBox
30 * @compile/module=java.base java/lang/ModuleHelper.java
31 * @run main ClassFileInstaller sun.hotspot.WhiteBox
32 * sun.hotspot.WhiteBox$WhiteBoxPermission
33 * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI AccessCheckJavaBase
34 */
35
36 import static jdk.test.lib.Asserts.*;
37
38 public class AccessCheckJavaBase {
39
40 // Test that a class defined to module_two always can read java.base.
41 public static void main(String args[]) throws Throwable {
42 // Get the class loader for AccessCheckJavaBase and assume it's also used to
43 // load class p2.c2.
44 ClassLoader this_cldr = AccessCheckJavaBase.class.getClassLoader();
45
46 // Define a module for p2.
47 Object m2x = ModuleHelper.ModuleObject("module_two", this_cldr, new String[] { "p2" });
48 assertNotNull(m2x, "Module should not be null");
49 ModuleHelper.DefineModule(m2x, false, "9.0", "m2x/there", new String[] { "p2" });
50
51 // p2.c2 can read its superclass java.lang.Object defined within java.base
52 try {
53 Class p2_c2_class = Class.forName("p2.c2");
54 } catch (IllegalAccessError e) {
55 throw new RuntimeException("Test Failed" + e.getMessage());
56 }
57 }
58 }
|