296 // char arch[12]; |
296 // char arch[12]; |
297 // sysinfo(SI_ARCHITECTURE, arch, sizeof(arch)); |
297 // sysinfo(SI_ARCHITECTURE, arch, sizeof(arch)); |
298 |
298 |
299 // The next steps are taken in the product version: |
299 // The next steps are taken in the product version: |
300 // |
300 // |
301 // Obtain the JAVA_HOME value from the location of libjvm[_g].so. |
301 // Obtain the JAVA_HOME value from the location of libjvm.so. |
302 // This library should be located at: |
302 // This library should be located at: |
303 // <JAVA_HOME>/jre/lib/<arch>/{client|server}/libjvm[_g].so. |
303 // <JAVA_HOME>/jre/lib/<arch>/{client|server}/libjvm.so. |
304 // |
304 // |
305 // If "/jre/lib/" appears at the right place in the path, then we |
305 // If "/jre/lib/" appears at the right place in the path, then we |
306 // assume libjvm[_g].so is installed in a JDK and we use this path. |
306 // assume libjvm.so is installed in a JDK and we use this path. |
307 // |
307 // |
308 // Otherwise exit with message: "Could not create the Java virtual machine." |
308 // Otherwise exit with message: "Could not create the Java virtual machine." |
309 // |
309 // |
310 // The following extra steps are taken in the debugging version: |
310 // The following extra steps are taken in the debugging version: |
311 // |
311 // |
312 // If "/jre/lib/" does NOT appear at the right place in the path |
312 // If "/jre/lib/" does NOT appear at the right place in the path |
313 // instead of exit check for $JAVA_HOME environment variable. |
313 // instead of exit check for $JAVA_HOME environment variable. |
314 // |
314 // |
315 // If it is defined and we are able to locate $JAVA_HOME/jre/lib/<arch>, |
315 // If it is defined and we are able to locate $JAVA_HOME/jre/lib/<arch>, |
316 // then we append a fake suffix "hotspot/libjvm[_g].so" to this path so |
316 // then we append a fake suffix "hotspot/libjvm.so" to this path so |
317 // it looks like libjvm[_g].so is installed there |
317 // it looks like libjvm.so is installed there |
318 // <JAVA_HOME>/jre/lib/<arch>/hotspot/libjvm[_g].so. |
318 // <JAVA_HOME>/jre/lib/<arch>/hotspot/libjvm.so. |
319 // |
319 // |
320 // Otherwise exit. |
320 // Otherwise exit. |
321 // |
321 // |
322 // Important note: if the location of libjvm.so changes this |
322 // Important note: if the location of libjvm.so changes this |
323 // code needs to be changed accordingly. |
323 // code needs to be changed accordingly. |
1226 |
1226 |
1227 const char* os::get_current_directory(char *buf, int buflen) { |
1227 const char* os::get_current_directory(char *buf, int buflen) { |
1228 return getcwd(buf, buflen); |
1228 return getcwd(buf, buflen); |
1229 } |
1229 } |
1230 |
1230 |
1231 // check if addr is inside libjvm[_g].so |
1231 // check if addr is inside libjvm.so |
1232 bool os::address_is_in_vm(address addr) { |
1232 bool os::address_is_in_vm(address addr) { |
1233 static address libjvm_base_addr; |
1233 static address libjvm_base_addr; |
1234 Dl_info dlinfo; |
1234 Dl_info dlinfo; |
1235 |
1235 |
1236 if (libjvm_base_addr == NULL) { |
1236 if (libjvm_base_addr == NULL) { |
1687 print_signal_handler(st, BREAK_SIGNAL, buf, buflen); |
1687 print_signal_handler(st, BREAK_SIGNAL, buf, buflen); |
1688 } |
1688 } |
1689 |
1689 |
1690 static char saved_jvm_path[MAXPATHLEN] = {0}; |
1690 static char saved_jvm_path[MAXPATHLEN] = {0}; |
1691 |
1691 |
1692 // Find the full path to the current module, libjvm or libjvm_g |
1692 // Find the full path to the current module, libjvm |
1693 void os::jvm_path(char *buf, jint buflen) { |
1693 void os::jvm_path(char *buf, jint buflen) { |
1694 // Error checking. |
1694 // Error checking. |
1695 if (buflen < MAXPATHLEN) { |
1695 if (buflen < MAXPATHLEN) { |
1696 assert(false, "must use a large-enough buffer"); |
1696 assert(false, "must use a large-enough buffer"); |
1697 buf[0] = '\0'; |
1697 buf[0] = '\0'; |
1730 char* java_home_var = ::getenv("JAVA_HOME"); |
1730 char* java_home_var = ::getenv("JAVA_HOME"); |
1731 if (java_home_var != NULL && java_home_var[0] != 0) { |
1731 if (java_home_var != NULL && java_home_var[0] != 0) { |
1732 char* jrelib_p; |
1732 char* jrelib_p; |
1733 int len; |
1733 int len; |
1734 |
1734 |
1735 // Check the current module name "libjvm" or "libjvm_g". |
1735 // Check the current module name "libjvm" |
1736 p = strrchr(buf, '/'); |
1736 p = strrchr(buf, '/'); |
1737 assert(strstr(p, "/libjvm") == p, "invalid library name"); |
1737 assert(strstr(p, "/libjvm") == p, "invalid library name"); |
1738 p = strstr(p, "_g") ? "_g" : ""; |
|
1739 |
1738 |
1740 rp = realpath(java_home_var, buf); |
1739 rp = realpath(java_home_var, buf); |
1741 if (rp == NULL) |
1740 if (rp == NULL) |
1742 return; |
1741 return; |
1743 |
1742 |
1762 |
1761 |
1763 // If the path exists within JAVA_HOME, add the JVM library name |
1762 // If the path exists within JAVA_HOME, add the JVM library name |
1764 // to complete the path to JVM being overridden. Otherwise fallback |
1763 // to complete the path to JVM being overridden. Otherwise fallback |
1765 // to the path to the current library. |
1764 // to the path to the current library. |
1766 if (0 == access(buf, F_OK)) { |
1765 if (0 == access(buf, F_OK)) { |
1767 // Use current module name "libjvm[_g]" instead of |
1766 // Use current module name "libjvm" |
1768 // "libjvm"debug_only("_g")"" since for fastdebug version |
|
1769 // we should have "libjvm" but debug_only("_g") adds "_g"! |
|
1770 len = strlen(buf); |
1767 len = strlen(buf); |
1771 snprintf(buf + len, buflen-len, "/libjvm%s%s", p, JNI_LIB_SUFFIX); |
1768 snprintf(buf + len, buflen-len, "/libjvm%s", JNI_LIB_SUFFIX); |
1772 } else { |
1769 } else { |
1773 // Fall back to path of current library |
1770 // Fall back to path of current library |
1774 rp = realpath(dli_fname, buf); |
1771 rp = realpath(dli_fname, buf); |
1775 if (rp == NULL) |
1772 if (rp == NULL) |
1776 return; |
1773 return; |