8177530: Module system implementation refresh (4/2017)
authoralanb
Fri, 07 Apr 2017 08:05:40 +0000
changeset 44558 2ee2259a06e2
parent 44495 fabbf846ef49
child 44559 f16b63292ca0
child 44612 c76b4f1a6ac8
child 44679 7638b8c03875
8177530: Module system implementation refresh (4/2017) Reviewed-by: mchung
jaxp/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/compiler/Constants.java
jaxp/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/trax/TemplatesImpl.java
jaxp/test/TEST.ROOT
jaxp/test/javax/xml/jaxp/module/ServiceProviderTest/DefaultFactoryWrapperTest.java
jaxp/test/javax/xml/jaxp/module/ServiceProviderTest/LayerModularXMLParserTest.java
jaxp/test/javax/xml/jaxp/module/ServiceProviderTest/src/unnamed/Main.java
--- a/jaxp/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/compiler/Constants.java	Thu Apr 06 17:01:02 2017 +0000
+++ b/jaxp/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/compiler/Constants.java	Fri Apr 07 08:05:40 2017 +0000
@@ -99,7 +99,7 @@
         = com.sun.org.apache.bcel.internal.Constants.ACC_STATIC;
 
     public static final String MODULE_SIG
-        = "Ljava/lang/reflect/Module;";
+        = "Ljava/lang/Module;";
     public static final String CLASS_SIG
         = "Ljava/lang/Class;";
     public static final String STRING_SIG
@@ -255,7 +255,7 @@
     public static final String CLASS_CLASS
         = "java.lang.Class";
     public static final String MODULE_CLASS
-        = "java.lang.reflect.Module";
+        = "java.lang.Module";
     public static final String STRING_CLASS
         = "java.lang.String";
     public static final String OBJECT_CLASS
--- a/jaxp/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/trax/TemplatesImpl.java	Thu Apr 06 17:01:02 2017 +0000
+++ b/jaxp/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/trax/TemplatesImpl.java	Fri Apr 07 08:05:40 2017 +0000
@@ -43,8 +43,6 @@
 import java.lang.module.ModuleFinder;
 import java.lang.module.ModuleReference;
 import java.lang.module.ModuleReader;
-import java.lang.reflect.Layer;
-import java.lang.reflect.Module;
 import java.security.AccessController;
 import java.security.CodeSigner;
 import java.security.CodeSource;
@@ -435,13 +433,13 @@
             }
         };
 
-        Layer bootLayer = Layer.boot();
+        ModuleLayer bootLayer = ModuleLayer.boot();
 
         Configuration cf = bootLayer.configuration()
                 .resolve(finder, ModuleFinder.of(), Set.of(mn));
 
-        PrivilegedAction<Layer> pa = () -> bootLayer.defineModules(cf, name -> loader);
-        Layer layer = AccessController.doPrivileged(pa);
+        PrivilegedAction<ModuleLayer> pa = () -> bootLayer.defineModules(cf, name -> loader);
+        ModuleLayer layer = AccessController.doPrivileged(pa);
 
         Module m = layer.findModule(mn).get();
         assert m.getLayer() == layer;
--- a/jaxp/test/TEST.ROOT	Thu Apr 06 17:01:02 2017 +0000
+++ b/jaxp/test/TEST.ROOT	Fri Apr 07 08:05:40 2017 +0000
@@ -23,7 +23,7 @@
 groups=TEST.groups
 
 # Minimum jtreg version
-requiredVersion=4.2 b04
+requiredVersion=4.2 b07
 
 # Use new module options
 useNewOptions=true
--- a/jaxp/test/javax/xml/jaxp/module/ServiceProviderTest/DefaultFactoryWrapperTest.java	Thu Apr 06 17:01:02 2017 +0000
+++ b/jaxp/test/javax/xml/jaxp/module/ServiceProviderTest/DefaultFactoryWrapperTest.java	Fri Apr 07 08:05:40 2017 +0000
@@ -27,8 +27,6 @@
 
 import java.io.StringReader;
 import java.io.StringWriter;
-import java.lang.reflect.Layer;
-import java.lang.reflect.Module;
 
 import javax.xml.datatype.DatatypeFactory;
 import javax.xml.parsers.DocumentBuilderFactory;
@@ -52,7 +50,7 @@
  * @summary test customized provider wraps the built-in system-default implementation of JAXP factories
  */
 public class DefaultFactoryWrapperTest {
-    private static final Module XML_MODULE = Layer.boot().findModule("java.xml").get();
+    private static final Module XML_MODULE = ModuleLayer.boot().findModule("java.xml").get();
 
     private static final String PROVIDER_PACKAGE = "xwp";
 
--- a/jaxp/test/javax/xml/jaxp/module/ServiceProviderTest/LayerModularXMLParserTest.java	Thu Apr 06 17:01:02 2017 +0000
+++ b/jaxp/test/javax/xml/jaxp/module/ServiceProviderTest/LayerModularXMLParserTest.java	Fri Apr 07 08:05:40 2017 +0000
@@ -29,9 +29,7 @@
 import java.lang.System;
 import java.lang.module.Configuration;
 import java.lang.module.ModuleFinder;
-import java.lang.reflect.Layer;
 import java.lang.reflect.Method;
-import java.lang.reflect.Module;
 import java.nio.file.Paths;
 import java.nio.file.Path;
 import java.util.Collections;
@@ -95,23 +93,23 @@
      */
     public void testOneLayer() throws Exception {
         ModuleFinder finder1 = ModuleFinder.of(MOD_DIR1);
-        Configuration cf1 = Layer.boot().configuration()
+        Configuration cf1 = ModuleLayer.boot().configuration()
                 .resolveAndBind(finder1, ModuleFinder.of(), Set.of("test"));
         ClassLoader scl = ClassLoader.getSystemClassLoader();
-        Layer layer1 = Layer.boot().defineModulesWithManyLoaders(cf1, scl);
+        ModuleLayer layer1 = ModuleLayer.boot().defineModulesWithManyLoaders(cf1, scl);
         ClassLoader cl1 = layer1.findLoader("test");
 
         Method m = cl1.loadClass("test.XMLFactoryHelper").getMethod("instantiateXMLService", String.class);
         for (String service : services1) {
             Object o = m.invoke(null, service);
-            Layer providerLayer = o.getClass().getModule().getLayer();
+            ModuleLayer providerLayer = o.getClass().getModule().getLayer();
             assertSame(providerLayer, layer1);
         }
 
         for (String service : services2) {
             Object o = m.invoke(null, service);
-            Layer providerLayer = o.getClass().getModule().getLayer();
-            assertSame(providerLayer, Layer.boot());
+            ModuleLayer providerLayer = o.getClass().getModule().getLayer();
+            assertSame(providerLayer, ModuleLayer.boot());
         }
 
     }
@@ -125,26 +123,26 @@
      */
     public void testTwoLayer() throws Exception {
         ModuleFinder finder1 = ModuleFinder.of(MOD_DIR1);
-        Configuration cf1 = Layer.boot().configuration()
+        Configuration cf1 = ModuleLayer.boot().configuration()
                 .resolveAndBind(finder1, ModuleFinder.of(), Set.of("test"));
         ClassLoader scl = ClassLoader.getSystemClassLoader();
-        Layer layer1 = Layer.boot().defineModulesWithManyLoaders(cf1, scl);
+        ModuleLayer layer1 = ModuleLayer.boot().defineModulesWithManyLoaders(cf1, scl);
 
         ModuleFinder finder2 = ModuleFinder.of(MOD_DIR2);
         Configuration cf2 = cf1.resolveAndBind(finder2, ModuleFinder.of(), Set.of("test"));
-        Layer layer2 = layer1.defineModulesWithOneLoader(cf2, layer1.findLoader("test"));
+        ModuleLayer layer2 = layer1.defineModulesWithOneLoader(cf2, layer1.findLoader("test"));
         ClassLoader cl2 = layer2.findLoader("test");
 
         Method m = cl2.loadClass("test.XMLFactoryHelper").getMethod("instantiateXMLService", String.class);
         for (String service : services1) {
             Object o = m.invoke(null, service);
-            Layer providerLayer = o.getClass().getModule().getLayer();
+            ModuleLayer providerLayer = o.getClass().getModule().getLayer();
             assertSame(providerLayer, layer1);
         }
 
         for (String service : services2) {
             Object o = m.invoke(null, service);
-            Layer providerLayer = o.getClass().getModule().getLayer();
+            ModuleLayer providerLayer = o.getClass().getModule().getLayer();
             assertSame(providerLayer, layer2);
         }
 
@@ -159,26 +157,26 @@
      */
     public void testTwoLayerWithDuplicate() throws Exception {
         ModuleFinder finder1 = ModuleFinder.of(MOD_DIR1, MOD_DIR2);
-        Configuration cf1 = Layer.boot().configuration()
+        Configuration cf1 = ModuleLayer.boot().configuration()
                 .resolveAndBind(finder1, ModuleFinder.of(), Set.of("test"));
         ClassLoader scl = ClassLoader.getSystemClassLoader();
-        Layer layer1 = Layer.boot().defineModulesWithManyLoaders(cf1, scl);
+        ModuleLayer layer1 = ModuleLayer.boot().defineModulesWithManyLoaders(cf1, scl);
 
         ModuleFinder finder2 = ModuleFinder.of(MOD_DIR2);
         Configuration cf2 = cf1.resolveAndBind(finder2, ModuleFinder.of(), Set.of("test"));
-        Layer layer2 = layer1.defineModulesWithOneLoader(cf2, layer1.findLoader("test"));
+        ModuleLayer layer2 = layer1.defineModulesWithOneLoader(cf2, layer1.findLoader("test"));
         ClassLoader cl2 = layer2.findLoader("test");
 
         Method m = cl2.loadClass("test.XMLFactoryHelper").getMethod("instantiateXMLService", String.class);
         for (String service : services1) {
             Object o = m.invoke(null, service);
-            Layer providerLayer = o.getClass().getModule().getLayer();
+            ModuleLayer providerLayer = o.getClass().getModule().getLayer();
             assertSame(providerLayer, layer1);
         }
 
         for (String service : services2) {
             Object o = m.invoke(null, service);
-            Layer providerLayer = o.getClass().getModule().getLayer();
+            ModuleLayer providerLayer = o.getClass().getModule().getLayer();
             assertSame(providerLayer, layer2);
         }
 
--- a/jaxp/test/javax/xml/jaxp/module/ServiceProviderTest/src/unnamed/Main.java	Thu Apr 06 17:01:02 2017 +0000
+++ b/jaxp/test/javax/xml/jaxp/module/ServiceProviderTest/src/unnamed/Main.java	Fri Apr 07 08:05:40 2017 +0000
@@ -24,8 +24,6 @@
 import static javax.xml.XMLConstants.W3C_XML_SCHEMA_NS_URI;
 
 import java.lang.module.ModuleDescriptor.Provides;
-import java.lang.reflect.Layer;
-import java.lang.reflect.Module;
 import java.util.Arrays;
 import java.util.HashSet;
 import java.util.Set;
@@ -38,7 +36,7 @@
      * @param args, the names of provider modules, which have been loaded
      */
     public static void main(String[] args) throws Exception {
-        Module xml = Layer.boot().findModule("java.xml").get();
+        Module xml = ModuleLayer.boot().findModule("java.xml").get();
 
         Set<String> allServices = new HashSet<>(Arrays.asList(expectedAllServices));
         if (!allServices.equals(xml.getDescriptor().uses()))
@@ -46,7 +44,7 @@
                     + xml.getDescriptor().uses());
 
         long violationCount = Stream.of(args)
-                .map(xmlProviderName -> Layer.boot().findModule(xmlProviderName).get())
+                .map(xmlProviderName -> ModuleLayer.boot().findModule(xmlProviderName).get())
                 .mapToLong(
                         // services provided by the implementation in provider module
                         provider -> provider.getDescriptor().provides().stream()