changeset 4077:5df3b79e6526

8175116: jtreg agentvms uses more virtual address space in langtool/test :tier1 runs Summary: Avoiding creation of an unnecessary read edge from jdk.compiler to a newly created unnamed module. Reviewed-by: jlahoda
author redestad
date Fri, 31 Mar 2017 08:59:35 +0200
parents 0f4a3fa6bac0
children 33c818a75ec9
files src/jdk.compiler/share/classes/com/sun/tools/javac/file/BaseFileManager.java
diffstat 1 files changed, 2 insertions(+), 27 deletions(-) [+]
line wrap: on
line diff
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/file/BaseFileManager.java	Thu Mar 30 16:36:48 2017 -0700
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/file/BaseFileManager.java	Fri Mar 31 08:59:35 2017 +0200
@@ -186,37 +186,12 @@
                         Class.forName(classLoaderClass).asSubclass(ClassLoader.class);
                 Class<?>[] constrArgTypes = { URL[].class, ClassLoader.class };
                 Constructor<? extends ClassLoader> constr = loader.getConstructor(constrArgTypes);
-                return ensureReadable(constr.newInstance(urls, thisClassLoader));
+                return constr.newInstance(urls, thisClassLoader);
             } catch (ReflectiveOperationException t) {
                 // ignore errors loading user-provided class loader, fall through
             }
         }
-        return ensureReadable(new URLClassLoader(urls, thisClassLoader));
-    }
-
-    /**
-     * Ensures that the unnamed module of the given classloader is readable to this
-     * module.
-     */
-    private ClassLoader ensureReadable(ClassLoader targetLoader) {
-        try {
-            Method getModuleMethod = Class.class.getMethod("getModule");
-            Object thisModule = getModuleMethod.invoke(this.getClass());
-            Method getUnnamedModuleMethod = ClassLoader.class.getMethod("getUnnamedModule");
-            Object targetModule = getUnnamedModuleMethod.invoke(targetLoader);
-
-            Class<?> moduleClass = getModuleMethod.getReturnType();
-            Method addReadsMethod = moduleClass.getMethod("addReads", moduleClass);
-            addReadsMethod.invoke(thisModule, targetModule);
-        } catch (NoSuchMethodException e) {
-            // ignore
-        } catch (IllegalAccessException
-                | IllegalArgumentException
-                | SecurityException
-                | InvocationTargetException e) {
-            throw new Abort(e);
-        }
-        return targetLoader;
+        return new URLClassLoader(urls, thisClassLoader);
     }
 
     public boolean isDefaultBootClassPath() {