--- a/jdk/src/java.base/share/native/libjli/java.c Wed Nov 23 16:16:35 2016 +0000
+++ b/jdk/src/java.base/share/native/libjli/java.c Thu Dec 01 08:57:53 2016 +0000
@@ -61,12 +61,13 @@
* interfaces.
*/
-/* we always print to stderr */
-#define USE_STDERR JNI_TRUE
+#define USE_STDERR JNI_TRUE /* we usually print to stderr */
+#define USE_STDOUT JNI_FALSE
static jboolean printVersion = JNI_FALSE; /* print and exit */
static jboolean showVersion = JNI_FALSE; /* print but continue */
static jboolean printUsage = JNI_FALSE; /* print and exit*/
+static jboolean printTo = USE_STDERR; /* where to print version/usage */
static jboolean printXUsage = JNI_FALSE; /* print and exit*/
static jboolean dryRun = JNI_FALSE; /* initialize VM and exit */
static char *showSettings = NULL; /* print but continue */
@@ -567,6 +568,7 @@
JLI_StrCmp(name, "--add-modules") == 0 ||
JLI_StrCmp(name, "--limit-modules") == 0 ||
JLI_StrCmp(name, "--add-exports") == 0 ||
+ JLI_StrCmp(name, "--add-opens") == 0 ||
JLI_StrCmp(name, "--add-reads") == 0 ||
JLI_StrCmp(name, "--patch-module") == 0;
}
@@ -758,12 +760,15 @@
if (*arg != '-'
|| JLI_StrCmp(arg, "-version") == 0
+ || JLI_StrCmp(arg, "--version") == 0
|| JLI_StrCmp(arg, "-fullversion") == 0
+ || JLI_StrCmp(arg, "--full-version") == 0
|| JLI_StrCmp(arg, "-help") == 0
|| JLI_StrCmp(arg, "--help") == 0
|| JLI_StrCmp(arg, "-?") == 0
|| JLI_StrCmp(arg, "-jar") == 0
- || JLI_StrCmp(arg, "-X") == 0) {
+ || JLI_StrCmp(arg, "-X") == 0
+ || JLI_StrCmp(arg, "--help-extra") == 0) {
return;
}
}
@@ -1288,6 +1293,7 @@
} else if (JLI_StrCmp(arg, "--add-modules") == 0 ||
JLI_StrCmp(arg, "--limit-modules") == 0 ||
JLI_StrCmp(arg, "--add-exports") == 0 ||
+ JLI_StrCmp(arg, "--add-opens") == 0 ||
JLI_StrCmp(arg, "--add-reads") == 0 ||
JLI_StrCmp(arg, "--patch-module") == 0) {
REPORT_ERROR (has_arg, ARG_ERROR6, arg);
@@ -1295,22 +1301,36 @@
/*
* The following cases will cause the argument parsing to stop
*/
- } else if (JLI_StrCmp(arg, "--help") == 0 ||
- JLI_StrCmp(arg, "-help") == 0 ||
+ } else if (JLI_StrCmp(arg, "-help") == 0 ||
JLI_StrCmp(arg, "-h") == 0 ||
JLI_StrCmp(arg, "-?") == 0) {
printUsage = JNI_TRUE;
return JNI_TRUE;
+ } else if (JLI_StrCmp(arg, "--help") == 0) {
+ printUsage = JNI_TRUE;
+ printTo = USE_STDOUT;
+ return JNI_TRUE;
} else if (JLI_StrCmp(arg, "-version") == 0) {
printVersion = JNI_TRUE;
return JNI_TRUE;
+ } else if (JLI_StrCmp(arg, "--version") == 0) {
+ printVersion = JNI_TRUE;
+ printTo = USE_STDOUT;
+ return JNI_TRUE;
} else if (JLI_StrCmp(arg, "-showversion") == 0) {
showVersion = JNI_TRUE;
+ } else if (JLI_StrCmp(arg, "--show-version") == 0) {
+ showVersion = JNI_TRUE;
+ printTo = USE_STDOUT;
} else if (JLI_StrCmp(arg, "--dry-run") == 0) {
dryRun = JNI_TRUE;
} else if (JLI_StrCmp(arg, "-X") == 0) {
printXUsage = JNI_TRUE;
return JNI_TRUE;
+ } else if (JLI_StrCmp(arg, "--help-extra") == 0) {
+ printXUsage = JNI_TRUE;
+ printTo = USE_STDOUT;
+ return JNI_TRUE;
/*
* The following case checks for -XshowSettings OR -XshowSetting:SUBOPT.
* In the latter case, any SUBOPT value not recognized will default to "all"
@@ -1330,6 +1350,9 @@
} else if (JLI_StrCmp(arg, "-fullversion") == 0) {
JLI_ReportMessage("%s full version \"%s\"", _launcher_name, GetFullVersion());
return JNI_FALSE;
+ } else if (JLI_StrCmp(arg, "--full-version") == 0) {
+ JLI_ShowMessage("%s %s", _launcher_name, GetFullVersion());
+ return JNI_FALSE;
} else if (JLI_StrCmp(arg, "-verbosegc") == 0) {
AddOption("-verbose:gc", NULL);
} else if (JLI_StrCmp(arg, "-t") == 0) {
@@ -1752,11 +1775,11 @@
NULL_CHECK(print = (*env)->GetStaticMethodID(env,
ver,
(extraLF == JNI_TRUE) ? "println" : "print",
- "()V"
+ "(Z)V"
)
);
- (*env)->CallStaticVoidMethod(env, ver, print);
+ (*env)->CallStaticVoidMethod(env, ver, print, printTo);
}
/*
@@ -1794,7 +1817,7 @@
"listModules", "(ZLjava/lang/String;)V"));
NULL_CHECK(joptString = (*env)->NewStringUTF(env, optString));
(*env)->CallStaticVoidMethod(env, cls, listModulesID,
- USE_STDERR,
+ USE_STDOUT,
joptString);
}
@@ -1812,7 +1835,7 @@
if (doXUsage) {
NULL_CHECK(printXUsageMessage = (*env)->GetStaticMethodID(env, cls,
"printXUsageMessage", "(Z)V"));
- (*env)->CallStaticVoidMethod(env, cls, printXUsageMessage, USE_STDERR);
+ (*env)->CallStaticVoidMethod(env, cls, printXUsageMessage, printTo);
} else {
NULL_CHECK(initHelp = (*env)->GetStaticMethodID(env, cls,
"initHelpMessage", "(Ljava/lang/String;)V"));
@@ -1853,7 +1876,7 @@
}
/* Complete the usage message and print to stderr*/
- (*env)->CallStaticVoidMethod(env, cls, printHelp, USE_STDERR);
+ (*env)->CallStaticVoidMethod(env, cls, printHelp, printTo);
}
return;
}
@@ -2255,3 +2278,16 @@
fprintf(stderr, "\n");
va_end(vl);
}
+
+/*
+ * A utility procedure to always print to stdout
+ */
+void
+JLI_ShowMessage(const char* fmt, ...)
+{
+ va_list vl;
+ va_start(vl, fmt);
+ vfprintf(stdout, fmt, vl);
+ fprintf(stdout, "\n");
+ va_end(vl);
+}