提交 9342f2b4 编写于 作者: K ksrini

7151434: java -jar -XX crashes java launcher

Reviewed-by: mchung, darcy
上级 f9451ebf
...@@ -695,6 +695,13 @@ SetClassPath(const char *s) ...@@ -695,6 +695,13 @@ SetClassPath(const char *s)
char *def; char *def;
const char *orig = s; const char *orig = s;
static const char format[] = "-Djava.class.path=%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); s = JLI_WildcardExpandClasspath(s);
def = JLI_MemAlloc(sizeof(format) def = JLI_MemAlloc(sizeof(format)
- 2 /* strlen("%s") */ - 2 /* strlen("%s") */
......
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
/** /**
* @test * @test
* @bug 5030233 6214916 6356475 6571029 6684582 6742159 4459600 6758881 6753938 * @bug 5030233 6214916 6356475 6571029 6684582 6742159 4459600 6758881 6753938
* 6894719 6968053 * 6894719 6968053 7151314
* @summary Argument parsing validation. * @summary Argument parsing validation.
* @compile -XDignore.symbol.file Arrrghs.java * @compile -XDignore.symbol.file Arrrghs.java
* @run main Arrrghs * @run main Arrrghs
...@@ -237,6 +237,13 @@ public class Arrrghs extends TestHelper { ...@@ -237,6 +237,13 @@ public class Arrrghs extends TestHelper {
tr.checkNegative(); tr.checkNegative();
tr.isNotZeroOutput(); tr.isNotZeroOutput();
System.out.println(tr); System.out.println(tr);
// 7151314, 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");
System.out.println(tr);
} }
/* /*
......
...@@ -21,6 +21,8 @@ ...@@ -21,6 +21,8 @@
* questions. * questions.
*/ */
import java.io.StringWriter;
import java.io.PrintWriter;
import java.io.BufferedReader; import java.io.BufferedReader;
import java.io.File; import java.io.File;
import java.io.FileFilter; import java.io.FileFilter;
...@@ -87,6 +89,7 @@ public class TestHelper { ...@@ -87,6 +89,7 @@ public class TestHelper {
static final String EXE_FILE_EXT = ".exe"; static final String EXE_FILE_EXT = ".exe";
static final String JLDEBUG_KEY = "_JAVA_LAUNCHER_DEBUG"; static final String JLDEBUG_KEY = "_JAVA_LAUNCHER_DEBUG";
static final String EXPECTED_MARKER = "TRACER_MARKER:About to EXEC"; static final String EXPECTED_MARKER = "TRACER_MARKER:About to EXEC";
static final String TEST_PREFIX = "###TestError###: ";
static int testExitValue = 0; static int testExitValue = 0;
...@@ -376,7 +379,8 @@ public class TestHelper { ...@@ -376,7 +379,8 @@ public class TestHelper {
* of use methods to check the test results. * of use methods to check the test results.
*/ */
static class TestResult { static class TestResult {
StringBuilder status; PrintWriter status;
StringWriter sw;
int exitValue; int exitValue;
List<String> testOutput; List<String> testOutput;
Map<String, String> env; Map<String, String> env;
...@@ -384,27 +388,33 @@ public class TestHelper { ...@@ -384,27 +388,33 @@ public class TestHelper {
public TestResult(String str, int rv, List<String> oList, public TestResult(String str, int rv, List<String> oList,
Map<String, String> env, Throwable t) { Map<String, String> env, Throwable t) {
status = new StringBuilder("Executed command: " + str + "\n"); sw = new StringWriter();
status = new PrintWriter(sw);
status.println("Executed command: " + str + "\n");
exitValue = rv; exitValue = rv;
testOutput = oList; testOutput = oList;
this.env = env; this.env = env;
this.t = t; this.t = t;
} }
void appendStatus(String x) { void appendError(String x) {
status = status.append(" " + x + "\n"); status.println(TEST_PREFIX + x);
}
void indentStatus(String x) {
status.println(" " + x);
} }
void checkNegative() { void checkNegative() {
if (exitValue == 0) { if (exitValue == 0) {
appendStatus("Error: test must not return 0 exit value"); appendError("test must not return 0 exit value");
testExitValue++; testExitValue++;
} }
} }
void checkPositive() { void checkPositive() {
if (exitValue != 0) { if (exitValue != 0) {
appendStatus("Error: test did not return 0 exit value"); appendError("test did not return 0 exit value");
testExitValue++; testExitValue++;
} }
} }
...@@ -415,7 +425,7 @@ public class TestHelper { ...@@ -415,7 +425,7 @@ public class TestHelper {
boolean isZeroOutput() { boolean isZeroOutput() {
if (!testOutput.isEmpty()) { if (!testOutput.isEmpty()) {
appendStatus("Error: No message from cmd please"); appendError("No message from cmd please");
testExitValue++; testExitValue++;
return false; return false;
} }
...@@ -424,7 +434,7 @@ public class TestHelper { ...@@ -424,7 +434,7 @@ public class TestHelper {
boolean isNotZeroOutput() { boolean isNotZeroOutput() {
if (testOutput.isEmpty()) { if (testOutput.isEmpty()) {
appendStatus("Error: Missing message"); appendError("Missing message");
testExitValue++; testExitValue++;
return false; return false;
} }
...@@ -433,22 +443,25 @@ public class TestHelper { ...@@ -433,22 +443,25 @@ public class TestHelper {
@Override @Override
public String toString() { public String toString() {
status.append("++++Begin Test Info++++\n"); status.println("++++Begin Test Info++++");
status.append("++++Test Environment++++\n"); status.println("++++Test Environment++++");
for (String x : env.keySet()) { for (String x : env.keySet()) {
status.append(x).append("=").append(env.get(x)).append("\n"); indentStatus(x + "=" + env.get(x));
} }
status.append("++++Test Output++++\n"); status.println("++++Test Output++++");
for (String x : testOutput) { for (String x : testOutput) {
appendStatus(x); indentStatus(x);
} }
status.append("++++Test Stack Trace++++\n"); status.println("++++Test Stack Trace++++");
status.append(t.toString()); status.println(t.toString());
for (StackTraceElement e : t.getStackTrace()) { for (StackTraceElement e : t.getStackTrace()) {
status.append(e.toString()); indentStatus(e.toString());
} }
status.append("++++End of Test Info++++\n"); status.println("++++End of Test Info++++");
return status.toString(); status.flush();
String out = sw.toString();
status.close();
return out;
} }
boolean contains(String str) { boolean contains(String str) {
...@@ -457,7 +470,7 @@ public class TestHelper { ...@@ -457,7 +470,7 @@ public class TestHelper {
return true; return true;
} }
} }
appendStatus("Error: string <" + str + "> not found"); appendError("string <" + str + "> not found");
testExitValue++; testExitValue++;
return false; return false;
} }
...@@ -468,7 +481,7 @@ public class TestHelper { ...@@ -468,7 +481,7 @@ public class TestHelper {
return true; return true;
} }
} }
appendStatus("Error: string <" + stringToMatch + "> not found"); appendError("string <" + stringToMatch + "> not found");
testExitValue++; testExitValue++;
return false; return false;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册