changeset 48693:60c19c384333

8196310: jlink --suggest-providers fails with missing resource if --output specified Reviewed-by: alanb, lancea, sundar
author mchung
date Wed, 31 Jan 2018 15:15:09 -0800
parents 554cb38e0caf
children a2d550f08617
files src/jdk.jlink/share/classes/jdk/tools/jlink/internal/JlinkTask.java src/jdk.jlink/share/classes/jdk/tools/jlink/resources/jlink.properties
diffstat 2 files changed, 10 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/JlinkTask.java	Wed Jan 31 14:21:52 2018 -0800
+++ b/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/JlinkTask.java	Wed Jan 31 15:15:09 2018 -0800
@@ -43,8 +43,6 @@
 import java.nio.file.Paths;
 import java.util.ArrayList;
 import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
 import java.util.Comparator;
 import java.util.Date;
 import java.util.HashMap;
@@ -231,7 +229,8 @@
         try {
             List<String> remaining = optionsHelper.handleOptions(this, args);
             if (remaining.size() > 0 && !options.suggestProviders) {
-                throw taskHelper.newBadArgs("err.orphan.arguments", toString(remaining))
+                throw taskHelper.newBadArgs("err.orphan.arguments",
+                                            remaining.stream().collect(Collectors.joining(" ")))
                                 .showUsage(true);
             }
             if (options.help) {
@@ -659,9 +658,12 @@
         throws BadArgs
     {
         if (args.size() > 1) {
-            throw taskHelper.newBadArgs("err.orphan.argument",
-                                        toString(args.subList(1, args.size())))
-                            .showUsage(true);
+            List<String> arguments = args.get(0).startsWith("-")
+                                        ? args
+                                        : args.subList(1, args.size());
+            throw taskHelper.newBadArgs("err.invalid.arg.for.option",
+                                        "--suggest-providers",
+                                        arguments.stream().collect(Collectors.joining(" ")));
         }
 
         if (options.bindServices) {
@@ -714,7 +716,7 @@
                  .forEach(names::remove);
             if (!names.isEmpty()) {
                 log.println(taskHelper.getMessage("warn.provider.notfound",
-                                                  toString(names)));
+                    names.stream().sorted().collect(Collectors.joining(","))));
             }
 
             String msg = String.format("%n%s:", taskHelper.getMessage("suggested.providers.header"));
@@ -722,11 +724,6 @@
         }
     }
 
-    private static String toString(Collection<String> collection) {
-        return collection.stream().sorted()
-                         .collect(Collectors.joining(","));
-    }
-
     private String getSaveOpts() {
         StringBuilder sb = new StringBuilder();
         sb.append('#').append(new Date()).append("\n");
--- a/src/jdk.jlink/share/classes/jdk/tools/jlink/resources/jlink.properties	Wed Jan 31 14:21:52 2018 -0800
+++ b/src/jdk.jlink/share/classes/jdk/tools/jlink/resources/jlink.properties	Wed Jan 31 15:15:09 2018 -0800
@@ -128,7 +128,7 @@
 err.unknown.option=unknown option: {0}
 err.missing.arg=no value given for {0}
 err.internal.error=internal error: {0} {1} {2}
-err.invalid.arg.for.option=invalid argument for option: {0}
+err.invalid.arg.for.option={0} does not accept \"{1}\" argument
 err.option.after.class=option must be specified before classes: {0}
 err.option.unsupported={0} not supported: {1}
 err.orphan.arguments=invalid argument: {0}