changeset 5255:6bd9089ebe96

7151434: java -jar -XX crashes java launcher Reviewed-by: mchung, darcy, jjh, dholmes
author ksrini
date Thu, 16 Aug 2012 08:29:30 -0700
parents 8cd543d7959d
children ced39ad6e1cf
files src/share/bin/java.c test/tools/launcher/Arrrghs.java
diffstat 2 files changed, 16 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/bin/java.c	Thu Aug 16 07:39:10 2012 -0700
+++ b/src/share/bin/java.c	Thu Aug 16 08:29:30 2012 -0700
@@ -693,6 +693,13 @@
     char *def;
     const char *orig = s;
     static const char format[] = "-Djava.class.path=%s";
+    /*
+     * usually we should not get a null pointer, but there are cases where
+     * we might just get one, in which case we simply ignore it, and let the
+     * caller deal with it
+     */
+    if (s == NULL)
+        return;
     s = JLI_WildcardExpandClasspath(s);
     def = JLI_MemAlloc(sizeof(format)
                        - 2 /* strlen("%s") */
--- a/test/tools/launcher/Arrrghs.java	Thu Aug 16 07:39:10 2012 -0700
+++ b/test/tools/launcher/Arrrghs.java	Thu Aug 16 08:29:30 2012 -0700
@@ -24,7 +24,7 @@
 /**
  * @test
  * @bug 5030233 6214916 6356475 6571029 6684582 6742159 4459600 6758881 6753938
- *      6894719 6968053
+ *      6894719 6968053 7151434
  * @summary Argument parsing validation.
  * @compile -XDignore.symbol.file Arrrghs.java
  * @run main Arrrghs
@@ -573,6 +573,14 @@
         tr.isNotZeroOutput();
         if (!tr.testStatus)
             System.out.println(tr);
+
+        // 7151434, test for non-negative exit value for an incorrectly formed
+        // command line, '% java -jar -W', note the bogus -W
+        tr = doExec(javaCmd, "-jar", "-W");
+        tr.checkNegative();
+        tr.contains("Unrecognized option: -W");
+        if (!tr.testStatus)
+            System.out.println(tr);
     }
 
     /*