2077 } |
2077 } |
2078 |
2078 |
2079 static char saved_jvm_path[MAXPATHLEN] = {0}; |
2079 static char saved_jvm_path[MAXPATHLEN] = {0}; |
2080 |
2080 |
2081 // Find the full path to the current module, libjvm.so or libjvm_g.so |
2081 // Find the full path to the current module, libjvm.so or libjvm_g.so |
2082 void os::jvm_path(char *buf, jint len) { |
2082 void os::jvm_path(char *buf, jint buflen) { |
2083 // Error checking. |
2083 // Error checking. |
2084 if (len < MAXPATHLEN) { |
2084 if (buflen < MAXPATHLEN) { |
2085 assert(false, "must use a large-enough buffer"); |
2085 assert(false, "must use a large-enough buffer"); |
2086 buf[0] = '\0'; |
2086 buf[0] = '\0'; |
2087 return; |
2087 return; |
2088 } |
2088 } |
2089 // Lazy resolve the path to current module. |
2089 // Lazy resolve the path to current module. |
2115 |
2115 |
2116 if (strncmp(p, "/jre/lib/", 9) != 0) { |
2116 if (strncmp(p, "/jre/lib/", 9) != 0) { |
2117 // Look for JAVA_HOME in the environment. |
2117 // Look for JAVA_HOME in the environment. |
2118 char* java_home_var = ::getenv("JAVA_HOME"); |
2118 char* java_home_var = ::getenv("JAVA_HOME"); |
2119 if (java_home_var != NULL && java_home_var[0] != 0) { |
2119 if (java_home_var != NULL && java_home_var[0] != 0) { |
|
2120 char* jrelib_p; |
|
2121 int len; |
|
2122 |
2120 // Check the current module name "libjvm.so" or "libjvm_g.so". |
2123 // Check the current module name "libjvm.so" or "libjvm_g.so". |
2121 p = strrchr(buf, '/'); |
2124 p = strrchr(buf, '/'); |
2122 assert(strstr(p, "/libjvm") == p, "invalid library name"); |
2125 assert(strstr(p, "/libjvm") == p, "invalid library name"); |
2123 p = strstr(p, "_g") ? "_g" : ""; |
2126 p = strstr(p, "_g") ? "_g" : ""; |
2124 |
2127 |
2125 if (realpath(java_home_var, buf) == NULL) |
2128 if (realpath(java_home_var, buf) == NULL) |
2126 return; |
2129 return; |
2127 sprintf(buf + strlen(buf), "/jre/lib/%s", cpu_arch); |
2130 |
|
2131 // determine if this is a legacy image or modules image |
|
2132 // modules image doesn't have "jre" subdirectory |
|
2133 len = strlen(buf); |
|
2134 jrelib_p = buf + len; |
|
2135 snprintf(jrelib_p, buflen-len, "/jre/lib/%s", cpu_arch); |
|
2136 if (0 != access(buf, F_OK)) { |
|
2137 snprintf(jrelib_p, buflen-len, "/lib/%s", cpu_arch); |
|
2138 } |
|
2139 |
2128 if (0 == access(buf, F_OK)) { |
2140 if (0 == access(buf, F_OK)) { |
2129 // Use current module name "libjvm[_g].so" instead of |
2141 // Use current module name "libjvm[_g].so" instead of |
2130 // "libjvm"debug_only("_g")".so" since for fastdebug version |
2142 // "libjvm"debug_only("_g")".so" since for fastdebug version |
2131 // we should have "libjvm.so" but debug_only("_g") adds "_g"! |
2143 // we should have "libjvm.so" but debug_only("_g") adds "_g"! |
2132 // It is used when we are choosing the HPI library's name |
2144 // It is used when we are choosing the HPI library's name |
2133 // "libhpi[_g].so" in hpi::initialize_get_interface(). |
2145 // "libhpi[_g].so" in hpi::initialize_get_interface(). |
2134 sprintf(buf + strlen(buf), "/hotspot/libjvm%s.so", p); |
2146 len = strlen(buf); |
|
2147 snprintf(buf + len, buflen-len, "/hotspot/libjvm%s.so", p); |
2135 } else { |
2148 } else { |
2136 // Go back to path of .so |
2149 // Go back to path of .so |
2137 if (realpath(dli_fname, buf) == NULL) |
2150 if (realpath(dli_fname, buf) == NULL) |
2138 return; |
2151 return; |
2139 } |
2152 } |