hotspot/test/runtime/modules/AccessCheckExp.java
changeset 46404 ae62ba99a1a7
parent 44520 0553e129e0ec
equal deleted inserted replaced
46403:f2b91b928476 46404:ae62ba99a1a7
    53         ClassLoader this_cldr = AccessCheckExp.class.getClassLoader();
    53         ClassLoader this_cldr = AccessCheckExp.class.getClassLoader();
    54 
    54 
    55         // Define a module for p1.
    55         // Define a module for p1.
    56         m1x = ModuleHelper.ModuleObject("module_one", this_cldr, new String[] { "p1" });
    56         m1x = ModuleHelper.ModuleObject("module_one", this_cldr, new String[] { "p1" });
    57         assertNotNull(m1x, "Module should not be null");
    57         assertNotNull(m1x, "Module should not be null");
    58         ModuleHelper.DefineModule(m1x, "9.0", "m1x/here", new String[] { "p1" });
    58         ModuleHelper.DefineModule(m1x, false, "9.0", "m1x/here", new String[] { "p1" });
    59         ModuleHelper.AddReadsModule(m1x, jlObject_jlM);
    59         ModuleHelper.AddReadsModule(m1x, jlObject_jlM);
    60 
    60 
    61         // Define a module for p2.
    61         // Define a module for p2.
    62         m2x = ModuleHelper.ModuleObject("module_two", this_cldr, new String[] { "p2" });
    62         m2x = ModuleHelper.ModuleObject("module_two", this_cldr, new String[] { "p2" });
    63         assertNotNull(m2x, "Module should not be null");
    63         assertNotNull(m2x, "Module should not be null");
    64         ModuleHelper.DefineModule(m2x, "9.0", "m2x/there", new String[] { "p2" });
    64         ModuleHelper.DefineModule(m2x, false, "9.0", "m2x/there", new String[] { "p2" });
    65         ModuleHelper.AddReadsModule(m2x, jlObject_jlM);
    65         ModuleHelper.AddReadsModule(m2x, jlObject_jlM);
    66 
    66 
    67         // Make package p1 in m1x visible to everyone.
    67         // Make package p1 in m1x visible to everyone.
    68         ModuleHelper.AddModuleExportsToAll(m1x, "p1");
    68         ModuleHelper.AddModuleExportsToAll(m1x, "p1");
    69 
    69 
    72         ModuleHelper.AddReadsModule(m1x, m2x);
    72         ModuleHelper.AddReadsModule(m1x, m2x);
    73 
    73 
    74         Class p1_c1_class = Class.forName("p1.c1");
    74         Class p1_c1_class = Class.forName("p1.c1");
    75         try {
    75         try {
    76             p1_c1_class.newInstance();
    76             p1_c1_class.newInstance();
    77             throw new RuntimeException("Failed to get IAE (p2 in m2x is not exported");
    77             throw new RuntimeException("Failed to get IAE (p2 in m2x is not exported)");
    78         } catch (IllegalAccessError f) {
    78         } catch (IllegalAccessError f) {
    79             System.out.println(f.getMessage());
    79             System.out.println(f.getMessage());
    80             if (!f.getMessage().contains("does not export")) {
    80             if (!f.getMessage().contains("does not export")) {
    81                 throw new RuntimeException("Wrong message: " + f.getMessage());
    81                 throw new RuntimeException("Wrong message: " + f.getMessage());
    82             }
    82             }