7125793: MAC: test_gamma should always work

Fix gamma launcher on Mac OS X and reconcile test_gamma script on Unix platforms

Reviewed-by: dcubed, ohair, jcoomes, dholmes, ksrini
This commit is contained in:
James Melvin 2012-01-24 19:33:14 -05:00 committed by Paul Hohensee
parent cba74d6208
commit ccf7d491f7
9 changed files with 278 additions and 74 deletions

View file

@ -301,6 +301,12 @@ static char cpu_arch[] = "sparc";
#error Add appropriate cpu_arch setting
#endif
// Compiler variant
#ifdef COMPILER2
#define COMPILER_VARIANT "server"
#else
#define COMPILER_VARIANT "client"
#endif
#ifndef _ALLBSD_SOURCE
// pid_t gettid()
@ -2507,7 +2513,7 @@ void os::print_signal_handlers(outputStream* st, char* buf, size_t buflen) {
static char saved_jvm_path[MAXPATHLEN] = {0};
// Find the full path to the current module, libjvm.so or libjvm_g.so
// Find the full path to the current module, libjvm or libjvm_g
void os::jvm_path(char *buf, jint buflen) {
// Error checking.
if (buflen < MAXPATHLEN) {
@ -2532,11 +2538,11 @@ void os::jvm_path(char *buf, jint buflen) {
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
// "<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 fix
// up the path so it looks like libjvm.so is installed there (append a
// fake suffix hotspot/libjvm.so).
// 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)
@ -2550,7 +2556,7 @@ void os::jvm_path(char *buf, jint buflen) {
char* jrelib_p;
int len;
// Check the current module name "libjvm.so" or "libjvm_g.so".
// Check the current module name "libjvm" or "libjvm_g".
p = strrchr(buf, '/');
assert(strstr(p, "/libjvm") == p, "invalid library name");
p = strstr(p, "_g") ? "_g" : "";
@ -2563,19 +2569,32 @@ void os::jvm_path(char *buf, jint buflen) {
// modules image doesn't have "jre" subdirectory
len = strlen(buf);
jrelib_p = buf + len;
snprintf(jrelib_p, buflen-len, "/jre/lib/%s", cpu_arch);
// Add the appropriate library subdir
snprintf(jrelib_p, buflen-len, "/jre/lib");
if (0 != access(buf, F_OK)) {
snprintf(jrelib_p, buflen-len, "/lib/%s", cpu_arch);
snprintf(jrelib_p, buflen-len, "/lib");
}
// Add the appropriate client or server subdir
len = strlen(buf);
jrelib_p = buf + len;
snprintf(jrelib_p, buflen-len, "/%s", COMPILER_VARIANT);
if (0 != access(buf, F_OK)) {
snprintf(jrelib_p, buflen-len, "");
}
// 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[_g].so" instead of
// "libjvm"debug_only("_g")".so" since for fastdebug version
// we should have "libjvm.so" but debug_only("_g") adds "_g"!
// Use current module name "libjvm[_g]" instead of
// "libjvm"debug_only("_g")"" since for fastdebug version
// we should have "libjvm" but debug_only("_g") adds "_g"!
len = strlen(buf);
snprintf(buf + len, buflen-len, "/hotspot/libjvm%s.so", p);
snprintf(buf + len, buflen-len, "/libjvm%s%s", p, JNI_LIB_SUFFIX);
} else {
// Go back to path of .so
// Fall back to path of current library
rp = realpath(dli_fname, buf);
if (rp == NULL)
return;