--- a/jdk/src/solaris/back/linker_md.c Sun Dec 02 16:37:31 2012 +0000
+++ b/jdk/src/solaris/back/linker_md.c Sun Dec 02 19:16:56 2012 -0500
@@ -54,6 +54,32 @@
#define LIB_SUFFIX "so"
#endif
+static void dll_build_name(char* buffer, size_t buflen,
+ const char* pname, const char* fname) {
+ // Based on os_solaris.cpp
+
+ char *path_sep = PATH_SEPARATOR;
+ char *pathname = (char *)pname;
+ while (strlen(pathname) > 0) {
+ char *p = strchr(pathname, *path_sep);
+ if (p == NULL) {
+ p = pathname + strlen(pathname);
+ }
+ /* check for NULL path */
+ if (p == pathname) {
+ continue;
+ }
+ (void)snprintf(buffer, buflen, "%.*s/lib%s." LIB_SUFFIX, (p - pathname),
+ pathname, fname);
+
+ if (access(buffer, F_OK) == 0) {
+ break;
+ }
+ pathname = p + 1;
+ *buffer = '\0';
+ }
+}
+
/*
* create a string for the JNI native function name by adding the
* appropriate decorations.
@@ -76,16 +102,16 @@
{
const int pnamelen = pname ? strlen(pname) : 0;
+ *holder = '\0';
/* Quietly truncate on buffer overflow. Should be an error. */
if (pnamelen + (int)strlen(fname) + 10 > holderlen) {
- *holder = '\0';
return;
}
if (pnamelen == 0) {
(void)snprintf(holder, holderlen, "lib%s." LIB_SUFFIX, fname);
} else {
- (void)snprintf(holder, holderlen, "%s/lib%s." LIB_SUFFIX, pname, fname);
+ dll_build_name(holder, holderlen, pname, fname);
}
}