1563 // Find the full path to the current module, libjvm.so.
1564 void os::jvm_path(char *buf, jint buflen) {
1565 // Error checking.
1566 if (buflen < MAXPATHLEN) {
1567 assert(false, "must use a large-enough buffer");
1568 buf[0] = '\0';
1569 return;
1570 }
1571 // Lazy resolve the path to current module.
1572 if (saved_jvm_path[0] != 0) {
1573 strcpy(buf, saved_jvm_path);
1574 return;
1575 }
1576
1577 Dl_info dlinfo;
1578 int ret = dladdr(CAST_FROM_FN_PTR(void *, os::jvm_path), &dlinfo);
1579 assert(ret != 0, "cannot locate libjvm");
1580 char* rp = os::Posix::realpath((char *)dlinfo.dli_fname, buf, buflen);
1581 assert(rp != NULL, "error in realpath(): maybe the 'path' argument is too long?");
1582
1583 strncpy(saved_jvm_path, buf, sizeof(saved_jvm_path));
1584 saved_jvm_path[sizeof(saved_jvm_path) - 1] = '\0';
1585 }
1586
1587 void os::print_jni_name_prefix_on(outputStream* st, int args_size) {
1588 // no prefix required, not even "_"
1589 }
1590
1591 void os::print_jni_name_suffix_on(outputStream* st, int args_size) {
1592 // no suffix required
1593 }
1594
1595 ////////////////////////////////////////////////////////////////////////////////
1596 // sun.misc.Signal support
1597
1598 static volatile jint sigint_count = 0;
1599
1600 static void
1601 UserHandler(int sig, void *siginfo, void *context) {
1602 // 4511530 - sem_post is serialized and handled by the manager thread. When
|
1563 // Find the full path to the current module, libjvm.so.
1564 void os::jvm_path(char *buf, jint buflen) {
1565 // Error checking.
1566 if (buflen < MAXPATHLEN) {
1567 assert(false, "must use a large-enough buffer");
1568 buf[0] = '\0';
1569 return;
1570 }
1571 // Lazy resolve the path to current module.
1572 if (saved_jvm_path[0] != 0) {
1573 strcpy(buf, saved_jvm_path);
1574 return;
1575 }
1576
1577 Dl_info dlinfo;
1578 int ret = dladdr(CAST_FROM_FN_PTR(void *, os::jvm_path), &dlinfo);
1579 assert(ret != 0, "cannot locate libjvm");
1580 char* rp = os::Posix::realpath((char *)dlinfo.dli_fname, buf, buflen);
1581 assert(rp != NULL, "error in realpath(): maybe the 'path' argument is too long?");
1582
1583 if (Arguments::sun_java_launcher_is_altjvm()) {
1584 // Support for the java launcher's '-XXaltjvm=<path>' option. Typical
1585 // value for buf is "<JAVA_HOME>/jre/lib/<vmtype>/libjvm.so".
1586 // If "/jre/lib/" appears at the right place in the string, then
1587 // assume we are installed in a JDK and we're done. Otherwise, check
1588 // for a JAVA_HOME environment variable and fix up the path so it
1589 // looks like libjvm.so is installed there (append a fake suffix
1590 // hotspot/libjvm.so).
1591 const char *p = buf + strlen(buf) - 1;
1592 for (int count = 0; p > buf && count < 4; ++count) {
1593 for (--p; p > buf && *p != '/'; --p)
1594 /* empty */ ;
1595 }
1596
1597 if (strncmp(p, "/jre/lib/", 9) != 0) {
1598 // Look for JAVA_HOME in the environment.
1599 char* java_home_var = ::getenv("JAVA_HOME");
1600 if (java_home_var != NULL && java_home_var[0] != 0) {
1601 char* jrelib_p;
1602 int len;
1603
1604 // Check the current module name "libjvm.so".
1605 p = strrchr(buf, '/');
1606 if (p == NULL) {
1607 return;
1608 }
1609 assert(strstr(p, "/libjvm") == p, "invalid library name");
1610
1611 rp = os::Posix::realpath(java_home_var, buf, buflen);
1612 if (rp == NULL) {
1613 return;
1614 }
1615
1616 // determine if this is a legacy image or modules image
1617 // modules image doesn't have "jre" subdirectory
1618 len = strlen(buf);
1619 assert(len < buflen, "Ran out of buffer room");
1620 jrelib_p = buf + len;
1621 snprintf(jrelib_p, buflen-len, "/jre/lib");
1622 if (0 != access(buf, F_OK)) {
1623 snprintf(jrelib_p, buflen-len, "/lib");
1624 }
1625
1626 if (0 == access(buf, F_OK)) {
1627 // Use current module name "libjvm.so"
1628 len = strlen(buf);
1629 snprintf(buf + len, buflen-len, "/hotspot/libjvm.so");
1630 } else {
1631 // Go back to path of .so
1632 rp = os::Posix::realpath((char *)dlinfo.dli_fname, buf, buflen);
1633 if (rp == NULL) {
1634 return;
1635 }
1636 }
1637 }
1638 }
1639 }
1640
1641 strncpy(saved_jvm_path, buf, sizeof(saved_jvm_path));
1642 saved_jvm_path[sizeof(saved_jvm_path) - 1] = '\0';
1643 }
1644
1645 void os::print_jni_name_prefix_on(outputStream* st, int args_size) {
1646 // no prefix required, not even "_"
1647 }
1648
1649 void os::print_jni_name_suffix_on(outputStream* st, int args_size) {
1650 // no suffix required
1651 }
1652
1653 ////////////////////////////////////////////////////////////////////////////////
1654 // sun.misc.Signal support
1655
1656 static volatile jint sigint_count = 0;
1657
1658 static void
1659 UserHandler(int sig, void *siginfo, void *context) {
1660 // 4511530 - sem_post is serialized and handled by the manager thread. When
|