changeset 14816:a4d427c2c81b

Fix for 8145264, jlink NPE when providing --class-optim-log-file option without --class-optim option
author jfdenise
date Wed, 23 Dec 2015 09:13:05 +0100
parents 8ca2c23fb8b4
children fcafe96a3cda
files src/jdk.jlink/share/classes/jdk/tools/jlink/internal/TaskHelper.java src/jdk.jlink/share/classes/jdk/tools/jlink/resources/plugins.properties
diffstat 2 files changed, 16 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/TaskHelper.java	Mon Dec 21 11:47:11 2015 -0400
+++ b/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/TaskHelper.java	Wed Dec 23 09:13:05 2015 +0100
@@ -279,7 +279,7 @@
         }
 
         private PluginsConfiguration getPluginsConfig(Path output,
-                boolean genbom) throws IOException {
+                boolean genbom) throws IOException, BadArgs {
             if (output != null) {
                 if (Files.exists(output)) {
                     throw new PluginException(PluginsResourceBundle.
@@ -290,9 +290,18 @@
             List<Plugin> pluginsList = new ArrayList<>();
             for (Entry<Plugin, Map<PluginOption, String>> entry : plugins.entrySet()) {
                 Plugin plugin = entry.getKey();
-
+                Map<PluginOption, String> options = entry.getValue();
+                PluginOption option = plugin.getOption();
+                if (!Utils.isAutoEnabled(plugin)) {
+                    if (option != null) {
+                        if (!options.containsKey(option)) {
+                            throw newBadArgs("err.plugin.option.not.set",
+                                    option.getName()).showUsage(true);
+                        }
+                    }
+                }
                 Map<PluginOption, String> config = new HashMap<>();
-                config.putAll(entry.getValue());
+                config.putAll(options);
                 plugin.configure(config);
                 if (!Utils.isDisabled(plugin)) {
                     pluginsList.add(plugin);
@@ -662,7 +671,8 @@
                 + bundleHelper.getMessage(key, args));
     }
 
-    public PluginsConfiguration getPluginsConfig(Path output, boolean genbom) throws IOException {
+    public PluginsConfiguration getPluginsConfig(Path output, boolean genbom)
+            throws IOException, BadArgs {
         return pluginOptions.getPluginsConfig(output, genbom);
     }
 
--- a/src/jdk.jlink/share/classes/jdk/tools/jlink/resources/plugins.properties	Mon Dec 21 11:47:11 2015 -0400
+++ b/src/jdk.jlink/share/classes/jdk/tools/jlink/resources/plugins.properties	Wed Dec 23 09:13:05 2015 +0100
@@ -124,6 +124,8 @@
 
 err.invalid.index=invalid index for option {0}
 
+err.plugin.option.not.set=Option {0} must be set.
+
 warn.thirdparty.plugins=\
 Enabling third party plugins can lead to unusable generated image.