8154470: defines.h confused about PROGNAME and JAVA_ARGS
Summary: Fiddle with const_progname initializations
Reviewed-by: ksrini, alanb
--- a/jdk/src/java.base/share/native/launcher/defines.h Tue Apr 19 14:39:35 2016 +0200
+++ b/jdk/src/java.base/share/native/launcher/defines.h Mon Apr 18 09:38:38 2016 -0700
@@ -45,7 +45,11 @@
#ifdef JAVA_ARGS
#define HAS_JAVA_ARGS JNI_TRUE
-static const char* const_progname = "java";
+#ifdef PROGNAME
+static const char* const_progname = PROGNAME;
+#else
+static char* const_progname = NULL;
+#endif
static const char* const_jargs[] = JAVA_ARGS;
/*
* ApplicationHome is prepended to each of these entries; the resulting
@@ -59,11 +63,7 @@
#endif /* APP_CLASSPATH */
#else /* !JAVA_ARGS */
#define HAS_JAVA_ARGS JNI_FALSE
-#ifdef PROGNAME
-static const char* const_progname = PROGNAME;
-#else
-static char* const_progname = NULL;
-#endif
+static const char* const_progname = "java";
static const char** const_jargs = NULL;
static const char* const_appclasspath[] = { NULL };
#endif /* JAVA_ARGS */
--- a/jdk/test/tools/launcher/Arrrghs.java Tue Apr 19 14:39:35 2016 +0200
+++ b/jdk/test/tools/launcher/Arrrghs.java Mon Apr 18 09:38:38 2016 -0700
@@ -489,7 +489,7 @@
return;
}
- TestResult tr = null;
+ TestResult tr;
// a missing class
createJar("MIA", new File("some.jar"), new File("Foo"),
@@ -592,7 +592,7 @@
if (!isEnglishLocale()) { // only english version
return;
}
- TestResult tr = null;
+ TestResult tr;
// a missing class
createJar("MIA", new File("some.jar"), new File("Foo"),
(String[])null);
--- a/jdk/test/tools/launcher/DefaultLocaleTestRun.java Tue Apr 19 14:39:35 2016 +0200
+++ b/jdk/test/tools/launcher/DefaultLocaleTestRun.java Mon Apr 18 09:38:38 2016 -0700
@@ -41,7 +41,7 @@
System.out.println("Test passes vacuously on non-windows");
return;
}
- TestResult tr = null;
+ TestResult tr;
tr = doExec(javaCmd,
"-cp", TEST_CLASSES_DIR.getAbsolutePath(),
"DefaultLocaleTest", "-w", "x.out");
--- a/jdk/test/tools/launcher/ExecutionEnvironment.java Tue Apr 19 14:39:35 2016 +0200
+++ b/jdk/test/tools/launcher/ExecutionEnvironment.java Mon Apr 18 09:38:38 2016 -0700
@@ -120,15 +120,14 @@
*/
@Test
void testEcoFriendly() {
- TestResult tr = null;
-
Map<String, String> env = new HashMap<>();
for (String x : LD_PATH_STRINGS) {
String pairs[] = x.split("=");
env.put(pairs[0], pairs[1]);
}
- tr = doExec(env, javaCmd, "-jar", testJarFile.getAbsolutePath());
+ TestResult tr =
+ doExec(env, javaCmd, "-jar", testJarFile.getAbsolutePath());
if (!tr.isNotZeroOutput()) {
flagError(tr, "Error: No output at all. Did the test execute ?");
@@ -180,7 +179,7 @@
*/
@Test
void testJavaLibraryPath() {
- TestResult tr = null;
+ TestResult tr;
Map<String, String> env = new HashMap<>();
@@ -240,17 +239,14 @@
*/
@Test
void testVmSelection() {
-
- TestResult tr = null;
-
if (haveClientVM) {
- tr = doExec(javaCmd, "-client", "-version");
+ TestResult tr = doExec(javaCmd, "-client", "-version");
if (!tr.matches(".*Client VM.*")) {
flagError(tr, "the expected vm -client did not launch");
}
}
if (haveServerVM) {
- tr = doExec(javaCmd, "-server", "-version");
+ TestResult tr = doExec(javaCmd, "-server", "-version");
if (!tr.matches(".*Server VM.*")) {
flagError(tr, "the expected vm -server did not launch");
}
--- a/jdk/test/tools/launcher/FXLauncherTest.java Tue Apr 19 14:39:35 2016 +0200
+++ b/jdk/test/tools/launcher/FXLauncherTest.java Mon Apr 18 09:38:38 2016 -0700
@@ -239,7 +239,7 @@
createFile(ManifestFile, createManifestContents(StdMainClass, fxMC));
createJar(FXtestJar, ManifestFile);
String sTestJar = FXtestJar.getAbsolutePath();
- TestResult tr;
+ final TestResult tr;
if (useCP) {
tr = doExec(javaCmd, "-cp", sTestJar, StdMainClass, APP_PARMS[0], APP_PARMS[1]);
} else {
@@ -290,7 +290,7 @@
createFile(ManifestFile, createManifestContents(ExtMainClass, fxMC));
createJar(FXtestJar, ManifestFile);
String sTestJar = FXtestJar.getAbsolutePath();
- TestResult tr;
+ final TestResult tr;
if (useCP) {
tr = doExec(javaCmd, "-cp", sTestJar, ExtMainClass, APP_PARMS[0], APP_PARMS[1]);
} else {
@@ -359,7 +359,7 @@
createFile(ManifestFile, createManifestContents(NonFXMainClass, null));
createJar(FXtestJar, ManifestFile);
String sTestJar = FXtestJar.getAbsolutePath();
- TestResult tr;
+ final TestResult tr;
if (useCP) {
tr = doExec(javaCmd, "-verbose:class", "-cp", sTestJar, NonFXMainClass, APP_PARMS[0], APP_PARMS[1]);
--- a/jdk/test/tools/launcher/I18NTest.java Tue Apr 19 14:39:35 2016 +0200
+++ b/jdk/test/tools/launcher/I18NTest.java Mon Apr 18 09:38:38 2016 -0700
@@ -60,7 +60,7 @@
// compile the generate code using the javac compiler vs. the api, to
// as a bonus point to see if the argument is passed correctly
- TestResult tr = null;
+ TestResult tr;
tr = doExec(javacCmd, fileName + JAVA_FILE_EXT);
if (!tr.isOK()) {
System.out.println(tr);
--- a/jdk/test/tools/launcher/MiscTests.java Tue Apr 19 14:39:35 2016 +0200
+++ b/jdk/test/tools/launcher/MiscTests.java Mon Apr 18 09:38:38 2016 -0700
@@ -23,7 +23,7 @@
/*
* @test
- * @bug 6856415 8154212
+ * @bug 6856415 8154212 8154470
* @summary Miscellaneous tests, Exceptions
* @compile -XDignore.symbol.file MiscTests.java
* @run main MiscTests
@@ -95,30 +95,34 @@
TestResult tr = doExec(javaCmd,
"-Djava.security.manager", "-jar", testJar.getName(), "foo.bak");
- for (String s : tr.testOutput) {
- System.out.println(s);
- }
if (!tr.contains("java.security.AccessControlException:" +
" access denied (\"java.lang.RuntimePermission\"" +
" \"accessClassInPackage.sun.security.pkcs11\")")) {
- System.out.println(tr.status);
+ System.out.println(tr);
}
}
- static void testJLDEnvWithTool() {
- final Map<String, String> envMap = new HashMap<>();
- envMap.put("_JAVA_LAUNCHER_DEBUG", "true");
- TestResult tr = doExec(envMap, javacCmd, "-version");
- tr.checkPositive();
- if (!tr.isOK()) {
- System.out.println(tr);
+ static void testJLDEnv() {
+ final Map<String, String> envToSet = new HashMap<>();
+ envToSet.put("_JAVA_LAUNCHER_DEBUG", "true");
+ for (String cmd : new String[] { javaCmd, javacCmd }) {
+ TestResult tr = doExec(envToSet, cmd, "-version");
+ tr.checkPositive();
+ String javargs = cmd.equals(javacCmd) ? "on" : "off";
+ String progname = cmd.equals(javacCmd) ? "javac" : "java";
+ if (!tr.isOK()
+ || !tr.matches("\\s*debug:on$")
+ || !tr.matches("\\s*javargs:" + javargs + "$")
+ || !tr.matches("\\s*program name:" + progname + "$")) {
+ System.out.println(tr);
+ }
}
}
public static void main(String... args) throws IOException {
testWithClassPathSetViaProperty();
test6856415();
- testJLDEnvWithTool();
+ testJLDEnv();
if (testExitValue != 0) {
throw new Error(testExitValue + " tests failed");
}
--- a/jdk/test/tools/launcher/Settings.java Tue Apr 19 14:39:35 2016 +0200
+++ b/jdk/test/tools/launcher/Settings.java Mon Apr 18 09:38:38 2016 -0700
@@ -55,9 +55,9 @@
}
}
- static void checkNoContains(TestResult tr, String str) {
- if (tr.contains(str)) {
- System.out.println(tr.status);
+ static void checkNotContains(TestResult tr, String str) {
+ if (!tr.notContains(str)) {
+ System.out.println(tr);
throw new RuntimeException(str + " found");
}
}
@@ -77,84 +77,77 @@
if (getArch().equals("ppc64") || getArch().equals("ppc64le")) {
stackSize = "800";
}
- TestResult tr = null;
+ TestResult tr;
tr = doExec(javaCmd, "-Xms64m", "-Xmx512m",
"-Xss" + stackSize + "k", "-XshowSettings", "-jar", testJar.getAbsolutePath());
containsAllOptions(tr);
if (!tr.isOK()) {
- System.out.println(tr.status);
+ System.out.println(tr);
throw new RuntimeException("test fails");
}
tr = doExec(javaCmd, "-Xms65536k", "-Xmx712m",
"-Xss" + stackSize + "000", "-XshowSettings", "-jar", testJar.getAbsolutePath());
containsAllOptions(tr);
if (!tr.isOK()) {
- System.out.println(tr.status);
+ System.out.println(tr);
throw new RuntimeException("test fails");
}
}
static void runTestOptionAll() throws IOException {
init();
- TestResult tr = null;
- tr = doExec(javaCmd, "-XshowSettings:all");
+ TestResult tr = doExec(javaCmd, "-XshowSettings:all");
containsAllOptions(tr);
}
static void runTestOptionVM() throws IOException {
- TestResult tr = null;
- tr = doExec(javaCmd, "-XshowSettings:vm");
+ TestResult tr = doExec(javaCmd, "-XshowSettings:vm");
checkContains(tr, VM_SETTINGS);
- checkNoContains(tr, PROP_SETTINGS);
- checkNoContains(tr, LOCALE_SETTINGS);
+ checkNotContains(tr, PROP_SETTINGS);
+ checkNotContains(tr, LOCALE_SETTINGS);
}
static void runTestOptionProperty() throws IOException {
- TestResult tr = null;
- tr = doExec(javaCmd, "-XshowSettings:properties");
- checkNoContains(tr, VM_SETTINGS);
+ TestResult tr = doExec(javaCmd, "-XshowSettings:properties");
+ checkNotContains(tr, VM_SETTINGS);
checkContains(tr, PROP_SETTINGS);
- checkNoContains(tr, LOCALE_SETTINGS);
+ checkNotContains(tr, LOCALE_SETTINGS);
}
static void runTestOptionLocale() throws IOException {
- TestResult tr = null;
- tr = doExec(javaCmd, "-XshowSettings:locale");
- checkNoContains(tr, VM_SETTINGS);
- checkNoContains(tr, PROP_SETTINGS);
+ TestResult tr = doExec(javaCmd, "-XshowSettings:locale");
+ checkNotContains(tr, VM_SETTINGS);
+ checkNotContains(tr, PROP_SETTINGS);
checkContains(tr, LOCALE_SETTINGS);
}
static void runTestBadOptions() throws IOException {
- TestResult tr = null;
- tr = doExec(javaCmd, "-XshowSettingsBadOption");
- checkNoContains(tr, VM_SETTINGS);
- checkNoContains(tr, PROP_SETTINGS);
- checkNoContains(tr, LOCALE_SETTINGS);
+ TestResult tr = doExec(javaCmd, "-XshowSettingsBadOption");
+ checkNotContains(tr, VM_SETTINGS);
+ checkNotContains(tr, PROP_SETTINGS);
+ checkNotContains(tr, LOCALE_SETTINGS);
checkContains(tr, "Unrecognized option: -XshowSettingsBadOption");
}
static void runTest7123582() throws IOException {
- TestResult tr = null;
- tr = doExec(javaCmd, "-XshowSettings", "-version");
+ TestResult tr = doExec(javaCmd, "-XshowSettings", "-version");
if (!tr.isOK()) {
- System.out.println(tr.status);
+ System.out.println(tr);
throw new RuntimeException("test fails");
}
containsAllOptions(tr);
}
- public static void main(String... args) {
- try {
- runTestOptionAll();
- runTestOptionDefault();
- runTestOptionVM();
- runTestOptionProperty();
- runTestOptionLocale();
- runTestBadOptions();
- runTest7123582();
- } catch (IOException ioe) {
- throw new RuntimeException(ioe);
+ public static void main(String... args) throws IOException {
+ runTestOptionAll();
+ runTestOptionDefault();
+ runTestOptionVM();
+ runTestOptionProperty();
+ runTestOptionLocale();
+ runTestBadOptions();
+ runTest7123582();
+ if (testExitValue != 0) {
+ throw new Error(testExitValue + " tests failed");
}
}
}
--- a/jdk/test/tools/launcher/TestHelper.java Tue Apr 19 14:39:35 2016 +0200
+++ b/jdk/test/tools/launcher/TestHelper.java Mon Apr 18 09:38:38 2016 -0700
@@ -603,23 +603,23 @@
return true;
}
- boolean matches(String stringToMatch) {
+ boolean matches(String regexToMatch) {
for (String x : testOutput) {
- if (x.matches(stringToMatch)) {
+ if (x.matches(regexToMatch)) {
return true;
}
}
- appendError("string <" + stringToMatch + "> not found");
+ appendError("regex <" + regexToMatch + "> not matched");
return false;
}
- boolean notMatches(String stringToMatch) {
+ boolean notMatches(String regexToMatch) {
for (String x : testOutput) {
- if (!x.matches(stringToMatch)) {
+ if (!x.matches(regexToMatch)) {
return true;
}
}
- appendError("string <" + stringToMatch + "> found");
+ appendError("regex <" + regexToMatch + "> matched");
return false;
}
}
--- a/jdk/test/tools/launcher/TestSpecialArgs.java Tue Apr 19 14:39:35 2016 +0200
+++ b/jdk/test/tools/launcher/TestSpecialArgs.java Mon Apr 18 09:38:38 2016 -0700
@@ -241,7 +241,7 @@
@Test
void testNMArgumentProcessing() throws FileNotFoundException {
- TestResult tr = null;
+ TestResult tr;
// the direct invokers of the VM
String options[] = {
"-version", "-fullversion", "-help", "-?", "-X"
--- a/jdk/test/tools/launcher/TooSmallStackSize.java Tue Apr 19 14:39:35 2016 +0200
+++ b/jdk/test/tools/launcher/TooSmallStackSize.java Mon Apr 18 09:38:38 2016 -0700
@@ -85,11 +85,10 @@
*/
static String checkStack(String stackSize) {
String min_stack_allowed;
- TestResult tr;
if (verbose)
System.out.println("*** Testing " + stackSize);
- tr = doExec(javaCmd, "-Xss" + stackSize, "-version");
+ TestResult tr = doExec(javaCmd, "-Xss" + stackSize, "-version");
if (verbose)
printTestOutput(tr);
@@ -114,11 +113,9 @@
* Run the JVM with the minimum allowed stack size. This should always succeed.
*/
static void checkMinStackAllowed(String stackSize) {
- TestResult tr = null;
-
if (verbose)
System.out.println("*** Testing " + stackSize);
- tr = doExec(javaCmd, "-Xss" + stackSize, "-version");
+ TestResult tr = doExec(javaCmd, "-Xss" + stackSize, "-version");
if (verbose)
printTestOutput(tr);
--- a/jdk/test/tools/launcher/ToolsOpts.java Tue Apr 19 14:39:35 2016 +0200
+++ b/jdk/test/tools/launcher/ToolsOpts.java Mon Apr 18 09:38:38 2016 -0700
@@ -149,7 +149,7 @@
*/
static void runTestOptions() throws IOException {
init();
- TestResult tr = null;
+ TestResult tr;
int jpos = -1;
for (String arg[] : optionPatterns) {
jpos = indexOfJoption(arg);
--- a/jdk/test/tools/launcher/VersionCheck.java Tue Apr 19 14:39:35 2016 +0200
+++ b/jdk/test/tools/launcher/VersionCheck.java Mon Apr 18 09:38:38 2016 -0700
@@ -151,12 +151,11 @@
* of the -version output as they are inconsistent.
*/
static boolean testToolVersion() {
- TestResult tr = null;
TestHelper.testExitValue = 0;
for (File f : new File(JAVA_BIN).listFiles(new ToolFilter(BLACKLIST_VERSION))) {
String x = f.getAbsolutePath();
System.out.println("Testing (-version): " + x);
- tr = doExec(x, "-version");
+ TestResult tr = doExec(x, "-version");
tr.checkPositive();
}
return TestHelper.testExitValue == 0;