8027113: decouple the '-XXaltjvm=<path>' option from the gamma launcher
Summary: decoupled the '-XXaltjvm=<path>' option from the gamma launcher. Clearing the way for removing the remaining cruft associated with the previously removed gamma launcher.
Reviewed-by: dcubed, dholmes
--- a/hotspot/make/Makefile Thu Jan 30 09:41:45 2014 +0100
+++ b/hotspot/make/Makefile Thu Jan 30 14:12:22 2014 -0800
@@ -557,11 +557,11 @@
# Testing the built JVM
-RUN_JVM=JAVA_HOME=$(JDK_IMPORT_PATH) $(JDK_IMPORT_PATH)/bin/java -d$(ARCH_DATA_MODEL) -Dsun.java.launcher=gamma
+RUN_JVM=JAVA_HOME=$(JDK_IMPORT_PATH) $(JDK_IMPORT_PATH)/bin/java -d$(ARCH_DATA_MODEL) -XXaltjvm=$(ALTJVM_DIR) -Dsun.java.launcher.is_altjvm=true
generic_test:
@$(ECHO) "Running with: $(ALTJVM_DIR)"
- @$(RUN_JVM) -XXaltjvm=$(ALTJVM_DIR) -Xinternalversion
- @$(RUN_JVM) -XXaltjvm=$(ALTJVM_DIR) -showversion -help
+ @$(RUN_JVM) -Xinternalversion
+ @$(RUN_JVM) -showversion -help
# C2 test targets
test_product test_optimized test_fastdebug test_debug:
--- a/hotspot/make/hotspot.script Thu Jan 30 09:41:45 2014 +0100
+++ b/hotspot/make/hotspot.script Thu Jan 30 14:12:22 2014 -0800
@@ -49,7 +49,7 @@
GDB=gdb
fi
-# This is the name of the gdb binary to use
+# This is the name of the dbx binary to use
if [ ! "$DBX" ]
then
DBX=dbx
@@ -68,9 +68,16 @@
# End of user changeable parameters -----------------------------------------
#
+OS=`uname -s`
+
# Make sure the paths are fully specified, i.e. they must begin with /.
REL_MYDIR=`dirname $0`
MYDIR=`cd $REL_MYDIR && pwd`
+case "$OS" in
+CYGWIN*)
+ MYDIR=`cygpath -m "$MYDIR"`
+ ;;
+esac
#
# Look whether the user wants to run inside gdb
@@ -102,8 +109,17 @@
JDK=@@JDK_IMPORT_PATH@@
fi
-if [ "${JDK}" = "" ]; then
- echo "Failed to find JDK. Either ALT_JAVA_HOME is not set or JDK_IMPORT_PATH is empty."
+if [ "${JDK}" != "" ]; then
+ case "$OS" in
+ CYGWIN*)
+ JDK=`cygpath -m "$JDK"`
+ ;;
+ esac
+
+else
+ echo "Failed to find JDK." \
+ "Either ALT_JAVA_HOME is not set or JDK_IMPORT_PATH is empty."
+ exit 1
fi
# We will set the LD_LIBRARY_PATH as follows:
@@ -120,7 +136,6 @@
# Set up a suitable LD_LIBRARY_PATH or DYLD_LIBRARY_PATH
-OS=`uname -s`
if [ "${OS}" = "Darwin" ]
then
if [ -z "$DYLD_LIBRARY_PATH" ]
@@ -141,7 +156,7 @@
export LD_LIBRARY_PATH
fi
-JPARMS="-Dsun.java.launcher=gamma -XXaltjvm=$MYDIR $@ $JAVA_ARGS";
+JPARMS="-XXaltjvm=$MYDIR -Dsun.java.launcher.is_altjvm=true $@ $JAVA_ARGS";
# Locate the java launcher
LAUNCHER=$JDK/bin/java
@@ -152,6 +167,11 @@
GDBSRCDIR=$MYDIR
BASEDIR=`cd $MYDIR/../../.. && pwd`
+case "$OS" in
+CYGWIN*)
+ BASEDIR=`cygpath -m "$BASEDIR"`
+ ;;
+esac
init_gdb() {
# Create a gdb script in case we should run inside gdb
--- a/hotspot/src/os/bsd/vm/os_bsd.cpp Thu Jan 30 09:41:45 2014 +0100
+++ b/hotspot/src/os/bsd/vm/os_bsd.cpp Thu Jan 30 14:12:22 2014 -0800
@@ -1788,12 +1788,14 @@
if (rp == NULL)
return;
- if (Arguments::created_by_gamma_launcher()) {
- // Support for the gamma launcher. Typical value for buf is
- // "<JAVA_HOME>/jre/lib/<arch>/<vmtype>/libjvm". If "/jre/lib/" appears at
- // the right place in the string, then assume we are installed in a JDK and
- // we're done. Otherwise, check for a JAVA_HOME environment variable and
- // construct a path to the JVM being overridden.
+ if (Arguments::sun_java_launcher_is_altjvm()) {
+ // Support for the java launcher's '-XXaltjvm=<path>' option. Typical
+ // value for buf is "<JAVA_HOME>/jre/lib/<arch>/<vmtype>/libjvm.so"
+ // or "<JAVA_HOME>/jre/lib/<vmtype>/libjvm.dylib". If "/jre/lib/"
+ // appears at the right place in the string, then assume we are
+ // installed in a JDK and we're done. Otherwise, check for a
+ // JAVA_HOME environment variable and construct a path to the JVM
+ // being overridden.
const char *p = buf + strlen(buf) - 1;
for (int count = 0; p > buf && count < 5; ++count) {
--- a/hotspot/src/os/linux/vm/os_linux.cpp Thu Jan 30 09:41:45 2014 +0100
+++ b/hotspot/src/os/linux/vm/os_linux.cpp Thu Jan 30 14:12:22 2014 -0800
@@ -2371,13 +2371,14 @@
if (rp == NULL)
return;
- if (Arguments::created_by_gamma_launcher()) {
- // Support for the gamma launcher. Typical value for buf is
- // "<JAVA_HOME>/jre/lib/<arch>/<vmtype>/libjvm.so". If "/jre/lib/" appears at
- // the right place in the string, then assume we are installed in a JDK and
- // we're done. Otherwise, check for a JAVA_HOME environment variable and fix
- // up the path so it looks like libjvm.so is installed there (append a
- // fake suffix hotspot/libjvm.so).
+ if (Arguments::sun_java_launcher_is_altjvm()) {
+ // Support for the java launcher's '-XXaltjvm=<path>' option. Typical
+ // value for buf is "<JAVA_HOME>/jre/lib/<arch>/<vmtype>/libjvm.so".
+ // If "/jre/lib/" appears at the right place in the string, then
+ // assume we are installed in a JDK and we're done. Otherwise, check
+ // for a JAVA_HOME environment variable and fix up the path so it
+ // looks like libjvm.so is installed there (append a fake suffix
+ // hotspot/libjvm.so).
const char *p = buf + strlen(buf) - 1;
for (int count = 0; p > buf && count < 5; ++count) {
for (--p; p > buf && *p != '/'; --p)
--- a/hotspot/src/os/solaris/vm/os_solaris.cpp Thu Jan 30 09:41:45 2014 +0100
+++ b/hotspot/src/os/solaris/vm/os_solaris.cpp Thu Jan 30 14:12:22 2014 -0800
@@ -2441,13 +2441,14 @@
return;
}
- if (Arguments::created_by_gamma_launcher()) {
- // Support for the gamma launcher. Typical value for buf is
- // "<JAVA_HOME>/jre/lib/<arch>/<vmtype>/libjvm.so". If "/jre/lib/" appears at
- // the right place in the string, then assume we are installed in a JDK and
- // we're done. Otherwise, check for a JAVA_HOME environment variable and fix
- // up the path so it looks like libjvm.so is installed there (append a
- // fake suffix hotspot/libjvm.so).
+ if (Arguments::sun_java_launcher_is_altjvm()) {
+ // Support for the java launcher's '-XXaltjvm=<path>' option. Typical
+ // value for buf is "<JAVA_HOME>/jre/lib/<arch>/<vmtype>/libjvm.so".
+ // If "/jre/lib/" appears at the right place in the string, then
+ // assume we are installed in a JDK and we're done. Otherwise, check
+ // for a JAVA_HOME environment variable and fix up the path so it
+ // looks like libjvm.so is installed there (append a fake suffix
+ // hotspot/libjvm.so).
const char *p = buf + strlen(buf) - 1;
for (int count = 0; p > buf && count < 5; ++count) {
for (--p; p > buf && *p != '/'; --p)
--- a/hotspot/src/os/windows/vm/os_windows.cpp Thu Jan 30 09:41:45 2014 +0100
+++ b/hotspot/src/os/windows/vm/os_windows.cpp Thu Jan 30 14:12:22 2014 -0800
@@ -1810,32 +1810,30 @@
}
buf[0] = '\0';
- if (Arguments::created_by_gamma_launcher()) {
- // Support for the gamma launcher. Check for an
- // JAVA_HOME environment variable
- // and fix up the path so it looks like
- // libjvm.so is installed there (append a fake suffix
- // hotspot/libjvm.so).
- char* java_home_var = ::getenv("JAVA_HOME");
- if (java_home_var != NULL && java_home_var[0] != 0) {
-
- strncpy(buf, java_home_var, buflen);
-
- // determine if this is a legacy image or modules image
- // modules image doesn't have "jre" subdirectory
- size_t len = strlen(buf);
- char* jrebin_p = buf + len;
- jio_snprintf(jrebin_p, buflen-len, "\\jre\\bin\\");
- if (0 != _access(buf, 0)) {
- jio_snprintf(jrebin_p, buflen-len, "\\bin\\");
- }
- len = strlen(buf);
- jio_snprintf(buf + len, buflen-len, "hotspot\\jvm.dll");
- }
- }
-
- if(buf[0] == '\0') {
- GetModuleFileName(vm_lib_handle, buf, buflen);
+ if (Arguments::sun_java_launcher_is_altjvm()) {
+ // Support for the java launcher's '-XXaltjvm=<path>' option. Check
+ // for a JAVA_HOME environment variable and fix up the path so it
+ // looks like jvm.dll is installed there (append a fake suffix
+ // hotspot/jvm.dll).
+ char* java_home_var = ::getenv("JAVA_HOME");
+ if (java_home_var != NULL && java_home_var[0] != 0) {
+ strncpy(buf, java_home_var, buflen);
+
+ // determine if this is a legacy image or modules image
+ // modules image doesn't have "jre" subdirectory
+ size_t len = strlen(buf);
+ char* jrebin_p = buf + len;
+ jio_snprintf(jrebin_p, buflen-len, "\\jre\\bin\\");
+ if (0 != _access(buf, 0)) {
+ jio_snprintf(jrebin_p, buflen-len, "\\bin\\");
+ }
+ len = strlen(buf);
+ jio_snprintf(buf + len, buflen-len, "hotspot\\jvm.dll");
+ }
+ }
+
+ if (buf[0] == '\0') {
+ GetModuleFileName(vm_lib_handle, buf, buflen);
}
strcpy(saved_jvm_path, buf);
}
--- a/hotspot/src/share/tools/ProjectCreator/WinGammaPlatformVC10.java Thu Jan 30 09:41:45 2014 +0100
+++ b/hotspot/src/share/tools/ProjectCreator/WinGammaPlatformVC10.java Thu Jan 30 14:12:22 2014 -0800
@@ -161,7 +161,18 @@
for (BuildConfig cfg : allConfigs) {
startTag(cfg, "PropertyGroup");
tagData("LocalDebuggerCommand", cfg.get("JdkTargetRoot") + "\\bin\\java.exe");
- tagData("LocalDebuggerCommandArguments", "-XXaltjvm=$(TargetDir) -Dsun.java.launcher=gamma");
+ // The JVM loads some libraries using a path relative to
+ // itself because it expects to be in a JRE or a JDK. The java
+ // launcher's '-XXaltjvm=' option allows the JVM to be outside
+ // the JRE or JDK so '-Dsun.java.launcher.is_altjvm=true'
+ // forces a fake JAVA_HOME relative path to be used to
+ // find the other libraries. The '-XX:+PauseAtExit' option
+ // causes the VM to wait for key press before exiting; this
+ // allows any stdout or stderr messages to be seen before
+ // the cmdtool exits.
+ tagData("LocalDebuggerCommandArguments", "-XXaltjvm=$(TargetDir) "
+ + "-Dsun.java.launcher.is_altjvm=true "
+ + "-XX:+UnlockDiagnosticVMOptions -XX:+PauseAtExit");
tagData("LocalDebuggerEnvironment", "JAVA_HOME=" + cfg.get("JdkTargetRoot"));
endTag();
}
--- a/hotspot/src/share/vm/runtime/arguments.cpp Thu Jan 30 09:41:45 2014 +0100
+++ b/hotspot/src/share/vm/runtime/arguments.cpp Thu Jan 30 14:12:22 2014 -0800
@@ -101,7 +101,7 @@
const char* Arguments::_java_vendor_url_bug = DEFAULT_VENDOR_URL_BUG;
const char* Arguments::_sun_java_launcher = DEFAULT_JAVA_LAUNCHER;
int Arguments::_sun_java_launcher_pid = -1;
-bool Arguments::_created_by_gamma_launcher = false;
+bool Arguments::_sun_java_launcher_is_altjvm = false;
// These parameters are reset in method parse_vm_init_args(JavaVMInitArgs*)
bool Arguments::_AlwaysCompileLoopMethods = AlwaysCompileLoopMethods;
@@ -151,7 +151,8 @@
// Process java launcher properties.
void Arguments::process_sun_java_launcher_properties(JavaVMInitArgs* args) {
- // See if sun.java.launcher or sun.java.launcher.pid is defined.
+ // See if sun.java.launcher, sun.java.launcher.is_altjvm or
+ // sun.java.launcher.pid is defined.
// Must do this before setting up other system properties,
// as some of them may depend on launcher type.
for (int index = 0; index < args->nOptions; index++) {
@@ -162,6 +163,12 @@
process_java_launcher_argument(tail, option->extraInfo);
continue;
}
+ if (match_option(option, "-Dsun.java.launcher.is_altjvm=", &tail)) {
+ if (strcmp(tail, "true") == 0) {
+ _sun_java_launcher_is_altjvm = true;
+ }
+ continue;
+ }
if (match_option(option, "-Dsun.java.launcher.pid=", &tail)) {
_sun_java_launcher_pid = atoi(tail);
continue;
@@ -1013,9 +1020,10 @@
_java_command = value;
// Record value in Arguments, but let it get passed to Java.
- } else if (strcmp(key, "sun.java.launcher.pid") == 0) {
- // launcher.pid property is private and is processed
- // in process_sun_java_launcher_properties();
+ } else if (strcmp(key, "sun.java.launcher.is_altjvm") == 0 ||
+ strcmp(key, "sun.java.launcher.pid") == 0) {
+ // sun.java.launcher.is_altjvm and sun.java.launcher.pid property are
+ // private and are processed in process_sun_java_launcher_properties();
// the sun.java.launcher property is passed on to the java application
FreeHeap(key);
if (eq != NULL) {
@@ -1800,9 +1808,6 @@
void Arguments::process_java_launcher_argument(const char* launcher, void* extra_info) {
_sun_java_launcher = strdup(launcher);
- if (strcmp("gamma", _sun_java_launcher) == 0) {
- _created_by_gamma_launcher = true;
- }
}
bool Arguments::created_by_java_launcher() {
@@ -1810,8 +1815,8 @@
return strcmp(DEFAULT_JAVA_LAUNCHER, _sun_java_launcher) != 0;
}
-bool Arguments::created_by_gamma_launcher() {
- return _created_by_gamma_launcher;
+bool Arguments::sun_java_launcher_is_altjvm() {
+ return _sun_java_launcher_is_altjvm;
}
//===========================================================================================================
@@ -3765,16 +3770,6 @@
}
}
- // set PauseAtExit if the gamma launcher was used and a debugger is attached
- // but only if not already set on the commandline
- if (Arguments::created_by_gamma_launcher() && os::is_debugger_attached()) {
- bool set = false;
- CommandLineFlags::wasSetOnCmdline("PauseAtExit", &set);
- if (!set) {
- FLAG_SET_DEFAULT(PauseAtExit, true);
- }
- }
-
return JNI_OK;
}
--- a/hotspot/src/share/vm/runtime/arguments.hpp Thu Jan 30 09:41:45 2014 +0100
+++ b/hotspot/src/share/vm/runtime/arguments.hpp Thu Jan 30 14:12:22 2014 -0800
@@ -268,14 +268,14 @@
static const char* _java_vendor_url_bug;
// sun.java.launcher, private property to provide information about
- // java/gamma launcher
+ // java launcher
static const char* _sun_java_launcher;
// sun.java.launcher.pid, private property
static int _sun_java_launcher_pid;
- // was this VM created by the gamma launcher
- static bool _created_by_gamma_launcher;
+ // was this VM created via the -XXaltjvm=<path> option
+ static bool _sun_java_launcher_is_altjvm;
// Option flags
static bool _has_profile;
@@ -483,8 +483,8 @@
static const char* sun_java_launcher() { return _sun_java_launcher; }
// Was VM created by a Java launcher?
static bool created_by_java_launcher();
- // Was VM created by the gamma Java launcher?
- static bool created_by_gamma_launcher();
+ // -Dsun.java.launcher.is_altjvm
+ static bool sun_java_launcher_is_altjvm();
// -Dsun.java.launcher.pid
static int sun_java_launcher_pid() { return _sun_java_launcher_pid; }