hotspot/test/runtime/modules/AccessCheck/Umod_ExpQualOther.java
changeset 43665 4bb003cad9b9
parent 42307 cefc81dc1d52
child 44520 0553e129e0ec
--- a/hotspot/test/runtime/modules/AccessCheck/Umod_ExpQualOther.java	Thu Feb 09 17:21:46 2017 +0000
+++ b/hotspot/test/runtime/modules/AccessCheck/Umod_ExpQualOther.java	Fri Feb 10 09:03:55 2017 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -25,8 +25,8 @@
 
 /*
  * @test
- * @summary Test that if package p2 in module m2 is exported to module m3,
- *          then class p1.c1 in an unnamed module can not read p2.c2 in module m2.
+ * @summary Test that if package p2 in module m2x is exported to module m3x,
+ *          then class p1.c1 in an unnamed module can not read p2.c2 in module m2x.
  * @modules java.base/jdk.internal.misc
  * @library /test/lib
  * @compile myloaders/MySameClassLoader.java
@@ -47,15 +47,15 @@
 import myloaders.MySameClassLoader;
 
 //
-// ClassLoader1 --> defines m1 --> no packages
-//                  defines m2 --> packages p2
-//                  defines m3 --> packages p3
+// ClassLoader1 --> defines m1x --> no packages
+//                  defines m2x --> packages p2
+//                  defines m3x --> packages p3
 //
-// m1 can read m2
-// package p2 in m2 is exported to m3
+// m1x can read m2x
+// package p2 in m2x is exported to m3x
 //
-// class p1.c1 defined in m1 tries to access p2.c2 defined in m2
-// Access denied since although m1 can read m2, p2 is exported only to m3.
+// class p1.c1 defined in m1x tries to access p2.c2 defined in m2x
+// Access denied since although m1x can read m2x, p2 is exported only to m3x.
 //
 public class Umod_ExpQualOther {
 
@@ -64,63 +64,63 @@
     // publically defined classes within packages of those modules.
     public void createLayerOnBoot() throws Throwable {
 
-        // Define module:     m1 (need to define m1 to establish the Layer successfully)
-        // Can read:          java.base, m2, m3
+        // Define module:     m1x (need to define m1x to establish the Layer successfully)
+        // Can read:          java.base, m2x, m3x
         // Packages:          none
         // Packages exported: none
-        ModuleDescriptor descriptor_m1 =
-                ModuleDescriptor.module("m1")
+        ModuleDescriptor descriptor_m1x =
+                ModuleDescriptor.newModule("m1x")
                         .requires("java.base")
-                        .requires("m2")
-                        .requires("m3")
+                        .requires("m2x")
+                        .requires("m3x")
                         .build();
 
-        // Define module:     m2
+        // Define module:     m2x
         // Can read:          java.base
         // Packages:          p2
-        // Packages exported: p2 is exported to m3
-        ModuleDescriptor descriptor_m2 =
-                ModuleDescriptor.module("m2")
+        // Packages exported: p2 is exported to m3x
+        ModuleDescriptor descriptor_m2x =
+                ModuleDescriptor.newModule("m2x")
                         .requires("java.base")
-                        .exports("p2", Set.of("m3"))
+                        .exports("p2", Set.of("m3x"))
                         .build();
 
-        // Define module:     m3
+        // Define module:     m3x
         // Can read:          java.base
         // Packages:          p3
         // Packages exported: none
-        ModuleDescriptor descriptor_m3 =
-                ModuleDescriptor.module("m3")
+        ModuleDescriptor descriptor_m3x =
+                ModuleDescriptor.newModule("m3x")
                         .requires("java.base")
                         .build();
 
         // Set up a ModuleFinder containing all modules for this layer.
-        ModuleFinder finder = ModuleLibrary.of(descriptor_m1, descriptor_m2, descriptor_m3);
+        ModuleFinder finder = ModuleLibrary.of(descriptor_m1x, descriptor_m2x, descriptor_m3x);
 
-        // Resolves "m1"
+        // Resolves "m1x"
         Configuration cf = Layer.boot()
                 .configuration()
-                .resolveRequires(finder, ModuleFinder.of(), Set.of("m1"));
+                .resolve(finder, ModuleFinder.of(), Set.of("m1x"));
 
         // map each module to differing class loaders for this test
         Map<String, ClassLoader> map = new HashMap<>();
-        map.put("m1", MySameClassLoader.loader1);
-        map.put("m2", MySameClassLoader.loader1);
-        map.put("m3", MySameClassLoader.loader1);
+        map.put("m1x", MySameClassLoader.loader1);
+        map.put("m2x", MySameClassLoader.loader1);
+        map.put("m3x", MySameClassLoader.loader1);
 
-        // Create Layer that contains m1, m2 and m3
+        // Create Layer that contains m1x, m2x and m3x
         Layer layer = Layer.boot().defineModules(cf, map::get);
 
-        assertTrue(layer.findLoader("m1") == MySameClassLoader.loader1);
-        assertTrue(layer.findLoader("m2") == MySameClassLoader.loader1);
-        assertTrue(layer.findLoader("m3") == MySameClassLoader.loader1);
+        assertTrue(layer.findLoader("m1x") == MySameClassLoader.loader1);
+        assertTrue(layer.findLoader("m2x") == MySameClassLoader.loader1);
+        assertTrue(layer.findLoader("m3x") == MySameClassLoader.loader1);
         assertTrue(layer.findLoader("java.base") == null);
 
         // now use the same loader to load class p1.c1
         Class p1_c1_class = MySameClassLoader.loader1.loadClass("p1.c1");
         try {
             p1_c1_class.newInstance();
-            throw new RuntimeException("Failed to get IAE (p2 in m2 is exported to m3, not unqualifiedly to everyone)");
+            throw new RuntimeException("Failed to get IAE (p2 in m2x is exported to m3x, not unqualifiedly to everyone)");
         } catch (IllegalAccessError e) {
             System.out.println(e.getMessage());
             if (!e.getMessage().contains("does not export")) {