Wed, 07 Jul 2010 15:35:58 -0700
6967423: Hotspot support for modules image
Summary: Add hotspot support for modules image
Reviewed-by: acorn
1.1 --- a/make/linux/makefiles/sa.make Wed Jul 07 14:12:08 2010 -0400 1.2 +++ b/make/linux/makefiles/sa.make Wed Jul 07 15:35:58 2010 -0700 1.3 @@ -40,6 +40,9 @@ 1.4 # tools.jar is needed by the JDI - SA binding 1.5 SA_CLASSPATH = $(BOOT_JAVA_HOME)/lib/tools.jar 1.6 1.7 +# TODO: if it's a modules image, check if SA module is installed. 1.8 +MODULELIB_PATH= $(BOOT_JAVA_HOME)/lib/modules 1.9 + 1.10 # gnumake 3.78.1 does not accept the *s that 1.11 # are in AGENT_FILES1 and AGENT_FILES2, so use the shell to expand them 1.12 AGENT_FILES1 := $(shell /usr/bin/test -d $(AGENT_DIR) && /bin/ls $(AGENT_FILES1)) 1.13 @@ -65,7 +68,7 @@ 1.14 echo "ALT_BOOTDIR, BOOTDIR or JAVA_HOME needs to be defined to build SA"; \ 1.15 exit 1; \ 1.16 fi 1.17 - $(QUIETLY) if [ ! -f $(SA_CLASSPATH) ] ; then \ 1.18 + $(QUIETLY) if [ ! -f $(SA_CLASSPATH) -a ! -d $(MODULELIB_PATH) ] ; then \ 1.19 echo "Missing $(SA_CLASSPATH) file. Use 1.6.0 or later version of JDK";\ 1.20 echo ""; \ 1.21 exit 1; \
2.1 --- a/make/solaris/makefiles/sa.make Wed Jul 07 14:12:08 2010 -0400 2.2 +++ b/make/solaris/makefiles/sa.make Wed Jul 07 15:35:58 2010 -0700 2.3 @@ -36,6 +36,9 @@ 2.4 # tools.jar is needed by the JDI - SA binding 2.5 SA_CLASSPATH = $(BOOT_JAVA_HOME)/lib/tools.jar 2.6 2.7 +# TODO: if it's a modules image, check if SA module is installed. 2.8 +MODULELIB_PATH= $(BOOT_JAVA_HOME)/lib/modules 2.9 + 2.10 # gnumake 3.78.1 does not accept the *s that 2.11 # are in AGENT_FILES1 and AGENT_FILES2, so use the shell to expand them 2.12 AGENT_FILES1 := $(shell /usr/bin/test -d $(AGENT_DIR) && /bin/ls $(AGENT_FILES1)) 2.13 @@ -59,7 +62,7 @@ 2.14 echo "ALT_BOOTDIR, BOOTDIR or JAVA_HOME needs to be defined to build SA"; \ 2.15 exit 1; \ 2.16 fi 2.17 - $(QUIETLY) if [ ! -f $(SA_CLASSPATH) ] ; then \ 2.18 + $(QUIETLY) if [ ! -f $(SA_CLASSPATH) -a ! -d $(MODULELIB_PATH) ] ; then \ 2.19 echo "Missing $(SA_CLASSPATH) file. Use 1.6.0 or later version of JDK";\ 2.20 echo ""; \ 2.21 exit 1; \
3.1 --- a/src/os/linux/vm/os_linux.cpp Wed Jul 07 14:12:08 2010 -0400 3.2 +++ b/src/os/linux/vm/os_linux.cpp Wed Jul 07 15:35:58 2010 -0700 3.3 @@ -2079,9 +2079,9 @@ 3.4 static char saved_jvm_path[MAXPATHLEN] = {0}; 3.5 3.6 // Find the full path to the current module, libjvm.so or libjvm_g.so 3.7 -void os::jvm_path(char *buf, jint len) { 3.8 +void os::jvm_path(char *buf, jint buflen) { 3.9 // Error checking. 3.10 - if (len < MAXPATHLEN) { 3.11 + if (buflen < MAXPATHLEN) { 3.12 assert(false, "must use a large-enough buffer"); 3.13 buf[0] = '\0'; 3.14 return; 3.15 @@ -2117,6 +2117,9 @@ 3.16 // Look for JAVA_HOME in the environment. 3.17 char* java_home_var = ::getenv("JAVA_HOME"); 3.18 if (java_home_var != NULL && java_home_var[0] != 0) { 3.19 + char* jrelib_p; 3.20 + int len; 3.21 + 3.22 // Check the current module name "libjvm.so" or "libjvm_g.so". 3.23 p = strrchr(buf, '/'); 3.24 assert(strstr(p, "/libjvm") == p, "invalid library name"); 3.25 @@ -2124,14 +2127,24 @@ 3.26 3.27 if (realpath(java_home_var, buf) == NULL) 3.28 return; 3.29 - sprintf(buf + strlen(buf), "/jre/lib/%s", cpu_arch); 3.30 + 3.31 + // determine if this is a legacy image or modules image 3.32 + // modules image doesn't have "jre" subdirectory 3.33 + len = strlen(buf); 3.34 + jrelib_p = buf + len; 3.35 + snprintf(jrelib_p, buflen-len, "/jre/lib/%s", cpu_arch); 3.36 + if (0 != access(buf, F_OK)) { 3.37 + snprintf(jrelib_p, buflen-len, "/lib/%s", cpu_arch); 3.38 + } 3.39 + 3.40 if (0 == access(buf, F_OK)) { 3.41 // Use current module name "libjvm[_g].so" instead of 3.42 // "libjvm"debug_only("_g")".so" since for fastdebug version 3.43 // we should have "libjvm.so" but debug_only("_g") adds "_g"! 3.44 // It is used when we are choosing the HPI library's name 3.45 // "libhpi[_g].so" in hpi::initialize_get_interface(). 3.46 - sprintf(buf + strlen(buf), "/hotspot/libjvm%s.so", p); 3.47 + len = strlen(buf); 3.48 + snprintf(buf + len, buflen-len, "/hotspot/libjvm%s.so", p); 3.49 } else { 3.50 // Go back to path of .so 3.51 if (realpath(dli_fname, buf) == NULL)
4.1 --- a/src/os/solaris/vm/os_solaris.cpp Wed Jul 07 14:12:08 2010 -0400 4.2 +++ b/src/os/solaris/vm/os_solaris.cpp Wed Jul 07 15:35:58 2010 -0700 4.3 @@ -2435,6 +2435,8 @@ 4.4 char* java_home_var = ::getenv("JAVA_HOME"); 4.5 if (java_home_var != NULL && java_home_var[0] != 0) { 4.6 char cpu_arch[12]; 4.7 + char* jrelib_p; 4.8 + int len; 4.9 sysinfo(SI_ARCHITECTURE, cpu_arch, sizeof(cpu_arch)); 4.10 #ifdef _LP64 4.11 // If we are on sparc running a 64-bit vm, look in jre/lib/sparcv9. 4.12 @@ -2450,14 +2452,23 @@ 4.13 p = strstr(p, "_g") ? "_g" : ""; 4.14 4.15 realpath(java_home_var, buf); 4.16 - sprintf(buf + strlen(buf), "/jre/lib/%s", cpu_arch); 4.17 + // determine if this is a legacy image or modules image 4.18 + // modules image doesn't have "jre" subdirectory 4.19 + len = strlen(buf); 4.20 + jrelib_p = buf + len; 4.21 + snprintf(jrelib_p, buflen-len, "/jre/lib/%s", cpu_arch); 4.22 + if (0 != access(buf, F_OK)) { 4.23 + snprintf(jrelib_p, buflen-len, "/lib/%s", cpu_arch); 4.24 + } 4.25 + 4.26 if (0 == access(buf, F_OK)) { 4.27 // Use current module name "libjvm[_g].so" instead of 4.28 // "libjvm"debug_only("_g")".so" since for fastdebug version 4.29 // we should have "libjvm.so" but debug_only("_g") adds "_g"! 4.30 // It is used when we are choosing the HPI library's name 4.31 // "libhpi[_g].so" in hpi::initialize_get_interface(). 4.32 - sprintf(buf + strlen(buf), "/hotspot/libjvm%s.so", p); 4.33 + len = strlen(buf); 4.34 + snprintf(buf + len, buflen-len, "/hotspot/libjvm%s.so", p); 4.35 } else { 4.36 // Go back to path of .so 4.37 realpath((char *)dlinfo.dli_fname, buf);
5.1 --- a/src/share/vm/runtime/os.cpp Wed Jul 07 14:12:08 2010 -0400 5.2 +++ b/src/share/vm/runtime/os.cpp Wed Jul 07 15:35:58 2010 -0700 5.3 @@ -886,6 +886,11 @@ 5.4 "%/lib/jsse.jar:" 5.5 "%/lib/jce.jar:" 5.6 "%/lib/charsets.jar:" 5.7 + 5.8 + // ## TEMPORARY hack to keep the legacy launcher working when 5.9 + // ## only the boot module is installed (cf. j.l.ClassLoader) 5.10 + "%/lib/modules/jdk.boot.jar:" 5.11 + 5.12 "%/classes"; 5.13 char* sysclasspath = format_boot_path(classpath_format, home, home_len, fileSep, pathSep); 5.14 if (sysclasspath == NULL) return false;