changeset 4942:db23fdcb8244

7151434: java -jar -XX crashes java launcher Reviewed-by: mchung, darcy, jjh, dholmes
author andrew
date Wed, 12 Jun 2013 11:46:50 +0100
parents 27e8f5644011
children 649b424bb842
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	Wed Jun 12 15:18:06 2013 +0100
+++ b/src/share/bin/java.c	Wed Jun 12 11:46:50 2013 +0100
@@ -714,6 +714,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	Wed Jun 12 15:18:06 2013 +0100
+++ b/test/tools/launcher/Arrrghs.java	Wed Jun 12 11:46:50 2013 +0100
@@ -24,7 +24,7 @@
 /**
  * @test
  * @bug 5030233 6214916 6356475 6571029 6684582 6742159 4459600 6758881 6753938
- *      6894719 6968053 7067922
+ *      6894719 6968053 7067922 7151434
  * @summary Argument parsing validation.
  * @compile -XDignore.symbol.file Arrrghs.java TestHelper.java
  * @run main Arrrghs
@@ -238,6 +238,14 @@
         tr.checkNegative();
         tr.isNotZeroOutput();
         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 = TestHelper.doExec(TestHelper.javaCmd, "-jar", "-W");
+        tr.checkNegative();
+        tr.contains("Unrecognized option: -W");
+        if (!tr.testStatus)
+            System.out.println(tr);
     }
 
     /*