changeset 16272:56cd93afdc15

better error message when mistaking a boolean option for a non-boolean option or vice versa
author Doug Simon <doug.simon@oracle.com>
date Fri, 27 Jun 2014 22:11:08 +0200
parents e589c26c2eb8
children d6ffc6164830
files graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotOptions.java
diffstat 1 files changed, 16 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotOptions.java	Fri Jun 27 22:10:23 2014 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotOptions.java	Fri Jun 27 22:11:08 2014 +0200
@@ -202,13 +202,22 @@
     }
 
     protected static void printNoMatchMessage(String optionName) {
-        System.err.println("Could not find option " + optionName + " (use -G:+PrintFlags to see Graal options)");
-        List<OptionDescriptor> matches = fuzzyMatch(optionName);
-        if (!matches.isEmpty()) {
-            System.err.println("Did you mean one of the following?");
-            for (OptionDescriptor match : matches) {
-                boolean isBoolean = match.getType() == boolean.class || match.getType() == Boolean.class;
-                System.err.println(String.format("    %s%s%s", isBoolean ? "(+/-)" : "", match.getName(), isBoolean ? "" : "=<value>"));
+        OptionDescriptor desc = options.get(optionName);
+        if (desc != null) {
+            if (desc.getType() == Boolean.class) {
+                System.err.println("Boolean option " + optionName + " must be prefixed with '+' or '-'");
+            } else {
+                System.err.println(desc.getType().getSimpleName() + " option " + optionName + " must not be prefixed with '+' or '-'");
+            }
+        } else {
+            System.err.println("Could not find option " + optionName + " (use -G:+PrintFlags to see Graal options)");
+            List<OptionDescriptor> matches = fuzzyMatch(optionName);
+            if (!matches.isEmpty()) {
+                System.err.println("Did you mean one of the following?");
+                for (OptionDescriptor match : matches) {
+                    boolean isBoolean = match.getType() == Boolean.class;
+                    System.err.println(String.format("    %s%s%s", isBoolean ? "(+/-)" : "", match.getName(), isBoolean ? "" : "=<value>"));
+                }
             }
         }
     }