RFR: 8237878: Improve ModuleLoaderMap datastructures

Claes Redestad claes.redestad at oracle.com
Mon Feb 10 11:43:43 UTC 2020



On 2020-02-10 12:34, Alan Bateman wrote:
> On 10/02/2020 09:04, Claes Redestad wrote:
>> :
>>
>> So how about:
>> http://cr.openjdk.java.net/~redestad/8237878/open.02/
> 
> Thanks for restoring the use of Function<String, ClassLoader>. Changing 
> Module::defineClass to invoke a method on ModuleLoaderMap is okay but 
> the method needs to something like "isBuiltinMapper" because it tests if 
> the function is a built-in mapper used for the boot layer (or child 
> layers created when we need to dynamically augment the set of platform 
> modules).
> 
> Minor nit but I think the comment on the Mapper constructor would say 
> that it creates a Mapper to map the modules in the given Configuration 
> to the built-in class loaders.
> 
> The rest looks good to me.

Thanks!

I'll run a few tests and push with this addendum, then:

diff -r 43b98c0e075d src/java.base/share/classes/java/lang/Module.java
--- a/src/java.base/share/classes/java/lang/Module.java	Mon Feb 10 
12:40:49 2020 +0100
+++ b/src/java.base/share/classes/java/lang/Module.java	Mon Feb 10 
12:42:43 2020 +0100
@@ -1094,7 +1094,7 @@

          // map each module to a class loader
          ClassLoader pcl = ClassLoaders.platformClassLoader();
-        boolean isModuleLoaderMapper = 
ModuleLoaderMap.isModuleLoaderMapper(clf);
+        boolean isModuleLoaderMapper = 
ModuleLoaderMap.isBuiltinMapper(clf);

          for (int index = 0; index < numModules; index++) {
              String name = resolvedModules[index].name();
diff -r 43b98c0e075d 
src/java.base/share/classes/jdk/internal/module/ModuleLoaderMap.java
--- 
a/src/java.base/share/classes/jdk/internal/module/ModuleLoaderMap.java 
Mon Feb 10 12:40:49 2020 +0100
+++ 
b/src/java.base/share/classes/jdk/internal/module/ModuleLoaderMap.java 
Mon Feb 10 12:42:43 2020 +0100
@@ -61,7 +61,8 @@
          private final Map<String, Integer> map;

          /**
-         * Maps module names to the corresponding built-in classloader.
+         * Creates a Mapper to map module names in the given 
Configuration to
+         * built-in classloaders.
           *
           * As a proxy for the actual classloader, we store an easily 
archiveable
           * index value in the internal map. The index is stored as a 
boxed value
@@ -132,7 +133,7 @@
       * to the boot or platform classloader if the ClassLoader mapping 
function
       * originate from here.
       */
-    public static boolean isModuleLoaderMapper(Function<String, 
ClassLoader> clf) {
+    public static boolean isBuiltinMapper(Function<String, ClassLoader> 
clf) {
          return clf instanceof Mapper;
      }
  }

/Claes


More information about the core-libs-dev mailing list