8177530: Module system implementation refresh (4/2017)
authoralanb
Fri, 07 Apr 2017 08:08:42 +0000
changeset 44555 3a7475e3da26
parent 44490 4e9cc32dd61a
child 44556 c792851e0f57
8177530: Module system implementation refresh (4/2017) Reviewed-by: mchung
nashorn/src/jdk.dynalink/share/classes/jdk/dynalink/beans/CallerSensitiveDynamicMethod.java
nashorn/src/jdk.dynalink/share/classes/jdk/dynalink/beans/CheckRestrictedPackage.java
nashorn/src/jdk.dynalink/share/classes/jdk/dynalink/linker/support/Lookup.java
nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/Context.java
nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/NashornLoader.java
nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/ScriptLoader.java
nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/StructureLoader.java
nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/linker/JavaAdapterClassLoader.java
nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/scripts/ModuleGraphManipulator.java
nashorn/test/TEST.ROOT
nashorn/test/src/jdk/nashorn/test/models/Reflector.java
--- a/nashorn/src/jdk.dynalink/share/classes/jdk/dynalink/beans/CallerSensitiveDynamicMethod.java	Thu Apr 06 17:01:05 2017 +0000
+++ b/nashorn/src/jdk.dynalink/share/classes/jdk/dynalink/beans/CallerSensitiveDynamicMethod.java	Fri Apr 07 08:08:42 2017 +0000
@@ -92,7 +92,6 @@
 import java.lang.reflect.Member;
 import java.lang.reflect.Method;
 import java.lang.reflect.Modifier;
-import java.lang.reflect.Module;
 import java.security.AccessControlContext;
 import java.security.AccessController;
 import java.security.PrivilegedAction;
--- a/nashorn/src/jdk.dynalink/share/classes/jdk/dynalink/beans/CheckRestrictedPackage.java	Thu Apr 06 17:01:05 2017 +0000
+++ b/nashorn/src/jdk.dynalink/share/classes/jdk/dynalink/beans/CheckRestrictedPackage.java	Fri Apr 07 08:08:42 2017 +0000
@@ -84,7 +84,6 @@
 package jdk.dynalink.beans;
 
 import java.lang.reflect.Modifier;
-import java.lang.reflect.Module;
 import java.security.AccessControlContext;
 import java.security.AccessController;
 import java.security.PrivilegedAction;
--- a/nashorn/src/jdk.dynalink/share/classes/jdk/dynalink/linker/support/Lookup.java	Thu Apr 06 17:01:05 2017 +0000
+++ b/nashorn/src/jdk.dynalink/share/classes/jdk/dynalink/linker/support/Lookup.java	Fri Apr 07 08:08:42 2017 +0000
@@ -89,7 +89,6 @@
 import java.lang.reflect.Constructor;
 import java.lang.reflect.Executable;
 import java.lang.reflect.Field;
-import java.lang.reflect.Module;
 import java.lang.reflect.Method;
 
 /**
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/Context.java	Thu Apr 06 17:01:05 2017 +0000
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/Context.java	Fri Apr 07 08:08:42 2017 +0000
@@ -51,9 +51,7 @@
 import java.lang.module.ModuleReader;
 import java.lang.module.ModuleReference;
 import java.lang.reflect.Field;
-import java.lang.reflect.Layer;
 import java.lang.reflect.Modifier;
-import java.lang.reflect.Module;
 import java.net.MalformedURLException;
 import java.net.URL;
 import java.nio.file.Path;
@@ -378,7 +376,7 @@
     static final boolean javaSqlFound, javaSqlRowsetFound;
 
     static {
-        final Layer boot = Layer.boot();
+        final ModuleLayer boot = ModuleLayer.boot();
         javaSqlFound = boot.findModule("java.sql").isPresent();
         javaSqlRowsetFound = boot.findModule("java.sql.rowset").isPresent();
     }
@@ -1334,7 +1332,7 @@
      * @return the new Module
      */
     static Module createModuleTrusted(final ModuleDescriptor descriptor, final ClassLoader loader) {
-        return createModuleTrusted(Layer.boot(), descriptor, loader);
+        return createModuleTrusted(ModuleLayer.boot(), descriptor, loader);
     }
 
     /**
@@ -1346,7 +1344,7 @@
      * @param loader the class loader of the module
      * @return the new Module
      */
-    static Module createModuleTrusted(final Layer parent, final ModuleDescriptor descriptor, final ClassLoader loader) {
+    static Module createModuleTrusted(final ModuleLayer parent, final ModuleDescriptor descriptor, final ClassLoader loader) {
         final String mn = descriptor.name();
 
         final ModuleReference mref = new ModuleReference(descriptor, null) {
@@ -1374,8 +1372,8 @@
         final Configuration cf = parent.configuration()
                 .resolve(finder, ModuleFinder.of(), Set.of(mn));
 
-        final PrivilegedAction<Layer> pa = () -> parent.defineModules(cf, name -> loader);
-        final Layer layer = AccessController.doPrivileged(pa, GET_LOADER_ACC_CTXT);
+        final PrivilegedAction<ModuleLayer> pa = () -> parent.defineModules(cf, name -> loader);
+        final ModuleLayer layer = AccessController.doPrivileged(pa, GET_LOADER_ACC_CTXT);
 
         final Module m = layer.findModule(mn).get();
         assert m.getLayer() == layer;
@@ -1796,7 +1794,7 @@
                 collect(Collectors.toSet());
         }
 
-        final Layer boot = Layer.boot();
+        final ModuleLayer boot = ModuleLayer.boot();
         final Configuration conf = boot.configuration().
             resolve(mf, ModuleFinder.of(), rootMods);
         final String firstMod = rootMods.iterator().next();
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/NashornLoader.java	Thu Apr 06 17:01:05 2017 +0000
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/NashornLoader.java	Fri Apr 07 08:08:42 2017 +0000
@@ -34,7 +34,6 @@
 import java.net.MalformedURLException;
 import java.net.URL;
 import java.net.URLClassLoader;
-import java.lang.reflect.Module;
 import java.security.AccessController;
 import java.security.CodeSource;
 import java.security.Permission;
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/ScriptLoader.java	Thu Apr 06 17:01:05 2017 +0000
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/ScriptLoader.java	Fri Apr 07 08:08:42 2017 +0000
@@ -27,7 +27,6 @@
 
 import java.lang.module.ModuleDescriptor;
 import java.lang.module.ModuleDescriptor.Modifier;
-import java.lang.reflect.Module;
 import java.security.CodeSource;
 import java.util.Objects;
 import java.util.Set;
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/StructureLoader.java	Thu Apr 06 17:01:05 2017 +0000
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/StructureLoader.java	Fri Apr 07 08:08:42 2017 +0000
@@ -32,7 +32,6 @@
 
 import java.lang.module.ModuleDescriptor;
 import java.lang.module.ModuleDescriptor.Modifier;
-import java.lang.reflect.Module;
 import java.security.ProtectionDomain;
 import java.util.Set;
 import jdk.nashorn.internal.codegen.ObjectClassGenerator;
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/linker/JavaAdapterClassLoader.java	Thu Apr 06 17:01:05 2017 +0000
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/linker/JavaAdapterClassLoader.java	Fri Apr 07 08:08:42 2017 +0000
@@ -27,7 +27,6 @@
 
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
-import java.lang.reflect.Module;
 import java.security.AccessControlContext;
 import java.security.AccessController;
 import java.security.PrivilegedAction;
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/scripts/ModuleGraphManipulator.java	Thu Apr 06 17:01:05 2017 +0000
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/scripts/ModuleGraphManipulator.java	Fri Apr 07 08:08:42 2017 +0000
@@ -25,7 +25,6 @@
 
 package jdk.nashorn.internal.scripts;
 
-import java.lang.reflect.Module;
 import jdk.nashorn.api.scripting.JSObject;
 
 /**
--- a/nashorn/test/TEST.ROOT	Thu Apr 06 17:01:05 2017 +0000
+++ b/nashorn/test/TEST.ROOT	Fri Apr 07 08:08:42 2017 +0000
@@ -8,7 +8,7 @@
 groups=TEST.groups
 
 # Minimum jtreg version
-requiredVersion=4.2 b04
+requiredVersion=4.2 b07
 
 # Use new module options
 useNewOptions=true
--- a/nashorn/test/src/jdk/nashorn/test/models/Reflector.java	Thu Apr 06 17:01:05 2017 +0000
+++ b/nashorn/test/src/jdk/nashorn/test/models/Reflector.java	Fri Apr 07 08:08:42 2017 +0000
@@ -29,7 +29,6 @@
 import java.lang.reflect.Executable;
 import java.lang.reflect.Field;
 import java.lang.reflect.Method;
-import java.lang.reflect.Module;
 import jdk.nashorn.internal.runtime.Context;
 
 /**