changeset 4899:03d38a9723ff

7129420: [macosx] SplashScreen.getSplashScreen() returns null Summary: Use GetJREPath() to infer the location of the splash screen library Reviewed-by: art, ksrini, swingler
author anthony
date Fri, 27 Jan 2012 15:37:56 +0400
parents c0036a561b5a
children c28e318653c6
files src/macosx/bin/java_md_macosx.c src/share/bin/emessages.h
diffstat 2 files changed, 21 insertions(+), 36 deletions(-) [+]
line wrap: on
line diff
--- a/src/macosx/bin/java_md_macosx.c	Thu Jan 26 18:23:38 2012 -0800
+++ b/src/macosx/bin/java_md_macosx.c	Fri Jan 27 15:37:56 2012 +0400
@@ -795,45 +795,29 @@
 
 void* SplashProcAddress(const char* name) {
     if (!hSplashLib) {
-        const char * splashLibPath;
-        char path[PATH_MAX];
-        Dl_info dli;
-
-        path[0] = 0;
-        if (dladdr(&SplashProcAddress, &dli)) {
-            // This is always reported as <path>/bin/java* (java or javaw, whatever)
-            char * realPath = realpath(dli.dli_fname, path);
-
-            if (realPath != path) {
-                path[0] = 0;
-            } else {
-                // chop off the "/bin/java*" part...
-                char * c = strrchr(path, '/');
-
-                if (!c) {
-                    path[0] = 0;
-                } else {
-                    *c = 0;
-                    c = strrchr(path, '/');
-
-                    if (!c) {
-                        path[0] = 0;
-                    } else {
-                        *c = 0;
-                        // ...and add the lib path instead
-                        snprintf(c, sizeof(path)-strlen(path), "/lib/%s", SPLASHSCREEN_SO);
-                    }
-                }
-            }
+        char jrePath[PATH_MAX];
+        if (!GetJREPath(jrePath, sizeof(jrePath), GetArch(), JNI_FALSE)) {
+            JLI_ReportErrorMessage(JRE_ERROR1);
+            return NULL;
         }
 
-        if (path[0]) {
-            splashLibPath = path;
-        } else {
-            // try our best, but most probably this will fail to load
-            splashLibPath = SPLASHSCREEN_SO;
+        char splashPath[PATH_MAX];
+        const int ret = JLI_Snprintf(splashPath, sizeof(splashPath),
+                "%s/lib/%s", jrePath, SPLASHSCREEN_SO);
+        if (ret >= (int)sizeof(splashPath)) {
+            JLI_ReportErrorMessage(JRE_ERROR11);
+            return NULL;
         }
-        hSplashLib = dlopen(splashLibPath, RTLD_LAZY | RTLD_GLOBAL);
+        if (ret < 0) {
+            JLI_ReportErrorMessage(JRE_ERROR13);
+            return NULL;
+        }
+
+        hSplashLib = dlopen(splashPath, RTLD_LAZY | RTLD_GLOBAL);
+        // It's OK if dlopen() fails. The splash screen library binary file
+        // might have been stripped out from the JRE image to reduce its size
+        // (e.g. on embedded platforms).
+
         if (hSplashLib) {
             if (!SetJavaVMValue()) {
                 dlclose(hSplashLib);
--- a/src/share/bin/emessages.h	Thu Jan 26 18:23:38 2012 -0800
+++ b/src/share/bin/emessages.h	Fri Jan 27 15:37:56 2012 +0400
@@ -87,6 +87,7 @@
 #define JRE_ERROR10     "Error: Unable to resolve current executable"
 #define JRE_ERROR11     "Error: Path length exceeds maximum length (PATH_MAX)"
 #define JRE_ERROR12     "Error: Exec of %s failed"
+#define JRE_ERROR13     "Error: String processing operation failed"
 
 #define DLL_ERROR1      "Error: dl failure on line %d"
 #define DLL_ERROR2      "Error: failed %s, because %s"