United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
Bug ID: JDK-7123582 (launcher) display the -version and -XshowSettings
JDK-7123582 : (launcher) display the -version and -XshowSettings

Details
Type:
Bug
Submit Date:
2011-12-21
Status:
Closed
Updated Date:
2012-04-21
Project Name:
JDK
Resolved Date:
2012-04-21
Component:
tools
OS:
generic
Sub-Component:
launcher
CPU:
generic
Priority:
P4
Resolution:
Fixed
Affected Versions:
7
Fixed Versions:

Related Reports
Backport:

Sub Tasks

Description
The launcher is not capable of showing the version info, when used in conjunction
with -XshowSettings, for ex: java -XshowSettings -version, in this case
it should show both the information and exit with a 0 value.

                                    

Comments
EVALUATION

Yes this is useful to quickly see the settings and version info. and
needs to be done. The fix is simply a question of altering the sequence
of how these are called internally.
                                     
2011-12-21
SUGGESTED FIX

as suggested by Sean.
v245-sus $hg diff bin/java.c
diff --git a/src/share/bin/java.c b/src/share/bin/java.c
--- a/src/share/bin/java.c
+++ b/src/share/bin/java.c
@@ -382,6 +382,11 @@ JavaMain(void * _args)
         exit(1);
     }

+    if (showSettings != NULL) {
+        ShowSettings(env, showSettings);
+        CHECK_EXCEPTION_LEAVE(1);
+    }
+
     if (printVersion || showVersion) {
         PrintJavaVersion(env, showVersion);
         CHECK_EXCEPTION_LEAVE(0);
@@ -390,10 +395,6 @@ JavaMain(void * _args)
         }
     }

-    if (showSettings != NULL) {
-        ShowSettings(env, showSettings);
-        CHECK_EXCEPTION_LEAVE(1);
-    }
     /* If the user specified neither a class name nor a JAR file */
     if (printXUsage || printUsage || what == 0 || mode == LM_UNKNOWN) {
         PrintUsage(env, printXUsage);
v245-sus $ 

For the test as suggested by ksrini
iff --git a/test/tools/launcher/Settings.java b/test/tools/launcher/Settings.java
--- a/test/tools/launcher/Settings.java
+++ b/test/tools/launcher/Settings.java
@@ -25,7 +25,7 @@ import java.io.IOException;
 
 /*
  * @test
- * @bug 6994753
+ * @bug 6994753 #SEANSCR#
  * @summary tests -XshowSettings options
  * @compile -XDignore.symbol.file Settings.java TestHelper.java
  * @run main Settings
@@ -129,6 +129,17 @@ public class Settings {
         checkNoContains(tr, LOCALE_SETTINGS);
         checkContains(tr, "Unrecognized option: -XshowSettingsBadOption");
     }
+
+    static void runTest#SEANSCR#() throws IOException {
+        TestHelper.TestResult tr = null;
+        tr = TestHelper.doExec(TestHelper.javaCmd, "-XshowSettings", "-version");
+        if (!tr.isOK()) {
+            System.out.println(tr.status);
+            throw new RuntimeException("test fails");
+        }
+        containsAllOptions(tr);
+    }
+
     public static void main(String... args) {
         try {
             runTestOptionAll();
@@ -137,6 +148,7 @@ public class Settings {
             runTestOptionProperty();
             runTestOptionLocale();
             runTestBadOptions();
+            runTest#SEANSCR#();
         } catch (IOException ioe) {
             throw new RuntimeException(ioe);
         }
                                     
2011-12-21



Hardware and Software, Engineered to Work Together