Skip to content

8171508: Remove -Dsun.java.launcher.is_altjvm option #24310

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
75 changes: 27 additions & 48 deletions src/hotspot/os/aix/os_aix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1306,60 +1306,39 @@ void os::jvm_path(char *buf, jint buflen) {
char* rp = os::realpath((char *)dlinfo.dli_fname, buf, buflen);
assert(rp != nullptr, "error in realpath(): maybe the 'path' argument is too long?");

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/<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 < 4; ++count) {
for (--p; p > buf && *p != '/'; --p)
/* empty */ ;
}
// If executing unit tests we require JAVA_HOME to point to the real JDK.
if (Arguments::executing_unit_tests()) {
// Look for JAVA_HOME in the environment.
char* java_home_var = ::getenv("JAVA_HOME");
if (java_home_var != nullptr && java_home_var[0] != 0) {

// Check the current module name "libjvm.so".
const char* p = strrchr(buf, '/');
if (p == nullptr) {
return;
}
assert(strstr(p, "/libjvm") == p, "invalid library name");

if (strncmp(p, "/jre/lib/", 9) != 0) {
// Look for JAVA_HOME in the environment.
char* java_home_var = ::getenv("JAVA_HOME");
if (java_home_var != nullptr && java_home_var[0] != 0) {
char* jrelib_p;
int len;
stringStream ss(buf, buflen);
rp = os::realpath(java_home_var, buf, buflen);
if (rp == nullptr) {
return;
}

// Check the current module name "libjvm.so".
p = strrchr(buf, '/');
if (p == nullptr) {
return;
}
assert(strstr(p, "/libjvm") == p, "invalid library name");
assert((int)strlen(buf) < buflen, "Ran out of buffer room");
ss.print("%s/lib", buf);

rp = os::realpath(java_home_var, buf, buflen);
if (0 == access(buf, F_OK)) {
// Use current module name "libjvm.so"
ss.print("/%s/libjvm%s", Abstract_VM_Version::vm_variant(), JNI_LIB_SUFFIX);
assert(strcmp(buf + strlen(buf) - strlen(JNI_LIB_SUFFIX), JNI_LIB_SUFFIX) == 0,
"buf has been truncated");
} else {
// Go back to path of .so
rp = os::realpath((char *)dlinfo.dli_fname, buf, buflen);
if (rp == nullptr) {
return;
}

// determine if this is a legacy image or modules image
// modules image doesn't have "jre" subdirectory
len = strlen(buf);
assert(len < buflen, "Ran out of buffer room");
jrelib_p = buf + len;
snprintf(jrelib_p, buflen-len, "/jre/lib");
if (0 != access(buf, F_OK)) {
snprintf(jrelib_p, buflen-len, "/lib");
}

if (0 == access(buf, F_OK)) {
// Use current module name "libjvm.so"
len = strlen(buf);
snprintf(buf + len, buflen-len, "/hotspot/libjvm.so");
} else {
// Go back to path of .so
rp = os::realpath((char *)dlinfo.dli_fname, buf, buflen);
if (rp == nullptr) {
return;
}
}
}
}
}
Expand Down
92 changes: 33 additions & 59 deletions src/hotspot/os/bsd/os_bsd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1502,71 +1502,45 @@ void os::jvm_path(char *buf, jint buflen) {
return;
}

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) {
for (--p; p > buf && *p != '/'; --p)
/* empty */ ;
}
// If executing unit tests we require JAVA_HOME to point to the real JDK.
if (Arguments::executing_unit_tests()) {
// Look for JAVA_HOME in the environment.
char* java_home_var = ::getenv("JAVA_HOME");
if (java_home_var != nullptr && java_home_var[0] != 0) {

// Check the current module name "libjvm"
const char* p = strrchr(buf, '/');
assert(strstr(p, "/libjvm") == p, "invalid library name");

stringStream ss(buf, buflen);
rp = os::realpath(java_home_var, buf, buflen);
if (rp == nullptr) {
return;
}

if (strncmp(p, "/jre/lib/", 9) != 0) {
// Look for JAVA_HOME in the environment.
char* java_home_var = ::getenv("JAVA_HOME");
if (java_home_var != nullptr && java_home_var[0] != 0) {
char* jrelib_p;
int len;
assert((int)strlen(buf) < buflen, "Ran out of buffer space");
// Add the appropriate library and JVM variant subdirs
ss.print("%s/lib/%s", buf, Abstract_VM_Version::vm_variant());

// Check the current module name "libjvm"
p = strrchr(buf, '/');
assert(strstr(p, "/libjvm") == p, "invalid library name");
if (0 != access(buf, F_OK)) {
ss.reset();
ss.print("%s/lib", buf);
}

rp = os::realpath(java_home_var, buf, buflen);
// If the path exists within JAVA_HOME, add the JVM library name
// to complete the path to JVM being overridden. Otherwise fallback
// to the path to the current library.
if (0 == access(buf, F_OK)) {
// Use current module name "libjvm"
ss.print("/libjvm%s", JNI_LIB_SUFFIX);
assert(strcmp(buf + strlen(buf) - strlen(JNI_LIB_SUFFIX), JNI_LIB_SUFFIX) == 0,
"buf has been truncated");
} else {
// Fall back to path of current library
rp = os::realpath(dli_fname, buf, buflen);
if (rp == nullptr) {
return;
}

// determine if this is a legacy image or modules image
// modules image doesn't have "jre" subdirectory
len = strlen(buf);
assert(len < buflen, "Ran out of buffer space");
jrelib_p = buf + len;

// Add the appropriate library subdir
snprintf(jrelib_p, buflen-len, "/jre/lib");
if (0 != access(buf, F_OK)) {
snprintf(jrelib_p, buflen-len, "/lib");
}

// Add the appropriate JVM variant subdir
len = strlen(buf);
jrelib_p = buf + len;
snprintf(jrelib_p, buflen-len, "/%s", Abstract_VM_Version::vm_variant());
if (0 != access(buf, F_OK)) {
snprintf(jrelib_p, buflen-len, "%s", "");
}

// If the path exists within JAVA_HOME, add the JVM library name
// to complete the path to JVM being overridden. Otherwise fallback
// to the path to the current library.
if (0 == access(buf, F_OK)) {
// Use current module name "libjvm"
len = strlen(buf);
snprintf(buf + len, buflen-len, "/libjvm%s", JNI_LIB_SUFFIX);
} else {
// Fall back to path of current library
rp = os::realpath(dli_fname, buf, buflen);
if (rp == nullptr) {
return;
}
}
}
}
}
Expand Down
75 changes: 27 additions & 48 deletions src/hotspot/os/linux/os_linux.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2772,60 +2772,39 @@ void os::jvm_path(char *buf, jint buflen) {
return;
}

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/<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)
/* empty */ ;
}
// If executing unit tests we require JAVA_HOME to point to the real JDK.
if (Arguments::executing_unit_tests()) {
// Look for JAVA_HOME in the environment.
char* java_home_var = ::getenv("JAVA_HOME");
if (java_home_var != nullptr && java_home_var[0] != 0) {

// Check the current module name "libjvm.so".
const char* p = strrchr(buf, '/');
if (p == nullptr) {
return;
}
assert(strstr(p, "/libjvm") == p, "invalid library name");

if (strncmp(p, "/jre/lib/", 9) != 0) {
// Look for JAVA_HOME in the environment.
char* java_home_var = ::getenv("JAVA_HOME");
if (java_home_var != nullptr && java_home_var[0] != 0) {
char* jrelib_p;
int len;
stringStream ss(buf, buflen);
rp = os::realpath(java_home_var, buf, buflen);
if (rp == nullptr) {
return;
}

// Check the current module name "libjvm.so".
p = strrchr(buf, '/');
if (p == nullptr) {
return;
}
assert(strstr(p, "/libjvm") == p, "invalid library name");
assert((int)strlen(buf) < buflen, "Ran out of buffer room");
ss.print("%s/lib", buf);

rp = os::realpath(java_home_var, buf, buflen);
if (0 == access(buf, F_OK)) {
// Use current module name "libjvm.so"
ss.print("/%s/libjvm%s", Abstract_VM_Version::vm_variant(), JNI_LIB_SUFFIX);
assert(strcmp(buf + strlen(buf) - strlen(JNI_LIB_SUFFIX), JNI_LIB_SUFFIX) == 0,
"buf has been truncated");
} else {
// Go back to path of .so
rp = os::realpath(dli_fname, buf, buflen);
if (rp == nullptr) {
return;
}

// determine if this is a legacy image or modules image
// modules image doesn't have "jre" subdirectory
len = checked_cast<int>(strlen(buf));
assert(len < buflen, "Ran out of buffer room");
jrelib_p = buf + len;
snprintf(jrelib_p, buflen-len, "/jre/lib");
if (0 != access(buf, F_OK)) {
snprintf(jrelib_p, buflen-len, "/lib");
}

if (0 == access(buf, F_OK)) {
// Use current module name "libjvm.so"
len = (int)strlen(buf);
snprintf(buf + len, buflen-len, "/hotspot/libjvm.so");
} else {
// Go back to path of .so
rp = os::realpath(dli_fname, buf, buflen);
if (rp == nullptr) {
return;
}
}
}
}
}
Expand Down
24 changes: 7 additions & 17 deletions src/hotspot/os/windows/os_windows.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2206,26 +2206,16 @@ void os::jvm_path(char *buf, jint buflen) {
}

buf[0] = '\0';
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).
// If executing unit tests we require JAVA_HOME to point to the real JDK.
if (Arguments::executing_unit_tests()) {
char* java_home_var = ::getenv("JAVA_HOME");
if (java_home_var != nullptr && java_home_var[0] != 0 &&
strlen(java_home_var) < (size_t)buflen) {
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");
stringStream ss(buf, buflen);
ss.print("%s\\bin\\%s\\jvm%s",
java_home_var, Abstract_VM_Version::vm_variant(), JNI_LIB_SUFFIX);
assert(strcmp(buf + strlen(buf) - strlen(JNI_LIB_SUFFIX), JNI_LIB_SUFFIX) == 0,
"buf has been truncated");
}
}

Expand Down
18 changes: 6 additions & 12 deletions src/hotspot/share/runtime/arguments.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ size_t Arguments::_conservative_max_heap_alignment = 0;
Arguments::Mode Arguments::_mode = _mixed;
const char* Arguments::_java_vendor_url_bug = nullptr;
const char* Arguments::_sun_java_launcher = DEFAULT_JAVA_LAUNCHER;
bool Arguments::_sun_java_launcher_is_altjvm = false;
bool Arguments::_executing_unit_tests = false;

// These parameters are reset in method parse_vm_init_args()
bool Arguments::_AlwaysCompileLoopMethods = AlwaysCompileLoopMethods;
Expand Down Expand Up @@ -355,7 +355,7 @@ bool Arguments::internal_module_property_helper(const char* property, bool check

// Process java launcher properties.
void Arguments::process_sun_java_launcher_properties(JavaVMInitArgs* args) {
// See if sun.java.launcher or sun.java.launcher.is_altjvm is defined.
// See if sun.java.launcher 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++) {
Expand All @@ -366,10 +366,8 @@ void Arguments::process_sun_java_launcher_properties(JavaVMInitArgs* args) {
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;
}
if (match_option(option, "-XX:+ExecutingUnitTests")) {
_executing_unit_tests = true;
continue;
}
}
Expand Down Expand Up @@ -1271,10 +1269,6 @@ bool Arguments::add_property(const char* prop, PropertyWriteable writeable, Prop
} else {
warning("The java.compiler system property is obsolete and no longer supported.");
}
} else if (strcmp(key, "sun.java.launcher.is_altjvm") == 0) {
// sun.java.launcher.is_altjvm property is
// private and is processed in process_sun_java_launcher_properties();
// the sun.java.launcher property is passed on to the java application
} else if (strcmp(key, "sun.boot.library.path") == 0) {
// append is true, writable is true, internal is false
PropertyList_unique_add(&_system_properties, key, value, AppendProperty,
Expand Down Expand Up @@ -1763,8 +1757,8 @@ bool Arguments::created_by_java_launcher() {
return strcmp(DEFAULT_JAVA_LAUNCHER, _sun_java_launcher) != 0;
}

bool Arguments::sun_java_launcher_is_altjvm() {
return _sun_java_launcher_is_altjvm;
bool Arguments::executing_unit_tests() {
return _executing_unit_tests;
}

//===========================================================================================================
Expand Down
8 changes: 4 additions & 4 deletions src/hotspot/share/runtime/arguments.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -238,8 +238,8 @@ class Arguments : AllStatic {
// java launcher
static const char* _sun_java_launcher;

// was this VM created via the -XXaltjvm=<path> option
static bool _sun_java_launcher_is_altjvm;
// was this VM created with the -XX:+ExecutingUnitTests option
static bool _executing_unit_tests;

// for legacy gc options (-verbose:gc and -Xloggc:)
static LegacyGCLogging _legacyGCLogging;
Expand Down Expand Up @@ -429,8 +429,8 @@ class Arguments : AllStatic {
static const char* sun_java_launcher() { return _sun_java_launcher; }
// Was VM created by a Java launcher?
static bool created_by_java_launcher();
// -Dsun.java.launcher.is_altjvm
static bool sun_java_launcher_is_altjvm();
// -XX:+ExecutingUnitTests
static bool executing_unit_tests();

// abort, exit, vfprintf hooks
static abort_hook_t abort_hook() { return _abort_hook; }
Expand Down
Loading