src/os/solaris/vm/os_solaris.cpp

Print this page
rev 2110 : [mq]: is-debugger-present


2490 
2491 // Find the full path to the current module, libjvm.so or libjvm_g.so
2492 void os::jvm_path(char *buf, jint buflen) {
2493   // Error checking.
2494   if (buflen < MAXPATHLEN) {
2495     assert(false, "must use a large-enough buffer");
2496     buf[0] = '\0';
2497     return;
2498   }
2499   // Lazy resolve the path to current module.
2500   if (saved_jvm_path[0] != 0) {
2501     strcpy(buf, saved_jvm_path);
2502     return;
2503   }
2504 
2505   Dl_info dlinfo;
2506   int ret = dladdr(CAST_FROM_FN_PTR(void *, os::jvm_path), &dlinfo);
2507   assert(ret != 0, "cannot locate libjvm");
2508   realpath((char *)dlinfo.dli_fname, buf);
2509 
2510   if (strcmp(Arguments::sun_java_launcher(), "gamma") == 0) {
2511     // Support for the gamma launcher.  Typical value for buf is
2512     // "<JAVA_HOME>/jre/lib/<arch>/<vmtype>/libjvm.so".  If "/jre/lib/" appears at
2513     // the right place in the string, then assume we are installed in a JDK and
2514     // we're done.  Otherwise, check for a JAVA_HOME environment variable and fix
2515     // up the path so it looks like libjvm.so is installed there (append a
2516     // fake suffix hotspot/libjvm.so).
2517     const char *p = buf + strlen(buf) - 1;
2518     for (int count = 0; p > buf && count < 5; ++count) {
2519       for (--p; p > buf && *p != '/'; --p)
2520         /* empty */ ;
2521     }
2522 
2523     if (strncmp(p, "/jre/lib/", 9) != 0) {
2524       // Look for JAVA_HOME in the environment.
2525       char* java_home_var = ::getenv("JAVA_HOME");
2526       if (java_home_var != NULL && java_home_var[0] != 0) {
2527         char cpu_arch[12];
2528         char* jrelib_p;
2529         int   len;
2530         sysinfo(SI_ARCHITECTURE, cpu_arch, sizeof(cpu_arch));




2490 
2491 // Find the full path to the current module, libjvm.so or libjvm_g.so
2492 void os::jvm_path(char *buf, jint buflen) {
2493   // Error checking.
2494   if (buflen < MAXPATHLEN) {
2495     assert(false, "must use a large-enough buffer");
2496     buf[0] = '\0';
2497     return;
2498   }
2499   // Lazy resolve the path to current module.
2500   if (saved_jvm_path[0] != 0) {
2501     strcpy(buf, saved_jvm_path);
2502     return;
2503   }
2504 
2505   Dl_info dlinfo;
2506   int ret = dladdr(CAST_FROM_FN_PTR(void *, os::jvm_path), &dlinfo);
2507   assert(ret != 0, "cannot locate libjvm");
2508   realpath((char *)dlinfo.dli_fname, buf);
2509 
2510   if (Arguments::created_by_gamma_launcher()) {
2511     // Support for the gamma launcher.  Typical value for buf is
2512     // "<JAVA_HOME>/jre/lib/<arch>/<vmtype>/libjvm.so".  If "/jre/lib/" appears at
2513     // the right place in the string, then assume we are installed in a JDK and
2514     // we're done.  Otherwise, check for a JAVA_HOME environment variable and fix
2515     // up the path so it looks like libjvm.so is installed there (append a
2516     // fake suffix hotspot/libjvm.so).
2517     const char *p = buf + strlen(buf) - 1;
2518     for (int count = 0; p > buf && count < 5; ++count) {
2519       for (--p; p > buf && *p != '/'; --p)
2520         /* empty */ ;
2521     }
2522 
2523     if (strncmp(p, "/jre/lib/", 9) != 0) {
2524       // Look for JAVA_HOME in the environment.
2525       char* java_home_var = ::getenv("JAVA_HOME");
2526       if (java_home_var != NULL && java_home_var[0] != 0) {
2527         char cpu_arch[12];
2528         char* jrelib_p;
2529         int   len;
2530         sysinfo(SI_ARCHITECTURE, cpu_arch, sizeof(cpu_arch));