8217877: Dead code in jdk.jlink's TaskHelper
authorsgehwolf
Mon, 28 Jan 2019 14:07:58 +0100
changeset 53548 0a35de73f7a8
parent 53547 9d1a788dea3d
child 53549 ad3438957ff5
8217877: Dead code in jdk.jlink's TaskHelper Reviewed-by: alanb, mchung
src/jdk.jlink/share/classes/jdk/tools/jlink/internal/TaskHelper.java
--- a/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/TaskHelper.java	Tue Jan 29 14:43:05 2019 +0100
+++ b/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/TaskHelper.java	Mon Jan 28 14:07:58 2019 +0100
@@ -24,11 +24,8 @@
  */
 package jdk.tools.jlink.internal;
 
-import java.io.File;
 import java.io.IOException;
 import java.io.PrintWriter;
-import java.lang.module.Configuration;
-import java.lang.module.ModuleFinder;
 import java.nio.file.Files;
 import java.nio.file.Path;
 import java.nio.file.Paths;
@@ -48,17 +45,16 @@
 import java.util.stream.Collectors;
 import java.util.stream.Stream;
 
-import jdk.tools.jlink.internal.plugins.ExcludeJmodSectionPlugin;
-import jdk.tools.jlink.plugin.Plugin;
-import jdk.tools.jlink.plugin.Plugin.Category;
 import jdk.tools.jlink.builder.DefaultImageBuilder;
 import jdk.tools.jlink.builder.ImageBuilder;
-import jdk.tools.jlink.plugin.PluginException;
 import jdk.tools.jlink.internal.Jlink.PluginsConfiguration;
+import jdk.tools.jlink.internal.plugins.DefaultCompressPlugin;
+import jdk.tools.jlink.internal.plugins.ExcludeJmodSectionPlugin;
 import jdk.tools.jlink.internal.plugins.PluginsResourceBundle;
-import jdk.tools.jlink.internal.plugins.DefaultCompressPlugin;
 import jdk.tools.jlink.internal.plugins.StripDebugPlugin;
-import jdk.internal.module.ModulePath;
+import jdk.tools.jlink.plugin.Plugin;
+import jdk.tools.jlink.plugin.Plugin.Category;
+import jdk.tools.jlink.plugin.PluginException;
 
 /**
  *
@@ -240,17 +236,7 @@
         private final List<PluginOption> pluginsOptions = new ArrayList<>();
         private final List<PluginOption> mainOptions = new ArrayList<>();
 
-        private PluginsHelper(String pp) throws BadArgs {
-
-            if (pp != null) {
-                String[] dirs = pp.split(File.pathSeparator);
-                List<Path> paths = new ArrayList<>(dirs.length);
-                for (String dir : dirs) {
-                    paths.add(Paths.get(dir));
-                }
-
-                pluginsLayer = createPluginsLayer(paths);
-            }
+        private PluginsHelper() throws BadArgs {
 
             plugins = PluginRepository.getPlugins(pluginsLayer);
 
@@ -544,7 +530,7 @@
             // Must extract it prior to do any option analysis.
             // Required to interpret custom plugin options.
             // Unit tests can call Task multiple time in same JVM.
-            pluginOptions = new PluginsHelper(null);
+            pluginOptions = new PluginsHelper();
 
             // process options
             for (int i = 0; i < args.length; i++) {
@@ -741,24 +727,6 @@
         return System.getProperty("java.version");
     }
 
-    static ModuleLayer createPluginsLayer(List<Path> paths) {
-
-        Path[] dirs = paths.toArray(new Path[0]);
-        ModuleFinder finder = ModulePath.of(Runtime.version(), true, dirs);
-        Configuration bootConfiguration = ModuleLayer.boot().configuration();
-        try {
-            Configuration cf = bootConfiguration
-                .resolveAndBind(ModuleFinder.of(),
-                                finder,
-                                Collections.emptySet());
-            ClassLoader scl = ClassLoader.getSystemClassLoader();
-            return ModuleLayer.boot().defineModulesWithOneLoader(cf, scl);
-        } catch (Exception ex) {
-            // Malformed plugin modules (e.g.: same package in multiple modules).
-            throw new PluginException("Invalid modules in the plugins path: " + ex);
-        }
-    }
-
     // Display all plugins
     private static boolean showsPlugin(Plugin plugin) {
         return (!Utils.isDisabled(plugin) && plugin.getOption() != null);