changeset 3713:7c98b6b4e8a7

6994933: java.awt.Desktop feature is "intermittently" supported on Solaris. Really unexpected behavior. Reviewed-by: art, dcherepanov
author dav
date Wed, 16 Feb 2011 01:12:53 +0300
parents 14d9e6af8889
children 41da8f9ea83a df0de56682b7
files src/solaris/classes/sun/awt/X11/XDesktopPeer.java src/solaris/native/sun/xawt/awt_Desktop.c
diffstat 2 files changed, 35 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/src/solaris/classes/sun/awt/X11/XDesktopPeer.java	Tue Feb 15 15:09:20 2011 +0000
+++ b/src/solaris/classes/sun/awt/X11/XDesktopPeer.java	Wed Feb 16 01:12:53 2011 +0300
@@ -44,11 +44,27 @@
 public class XDesktopPeer implements DesktopPeer {
 
     private static boolean nativeLibraryLoaded = false;
-    static {
-        nativeLibraryLoaded = init();
+    private static boolean initExecuted = false;
+
+    private static void initWithLock(){
+        XToolkit.awtLock();
+        try {
+            if (!initExecuted) {
+                nativeLibraryLoaded = init();
+            }
+        } finally {
+            initExecuted = true;
+            XToolkit.awtUnlock();
+        }
+    }
+
+    //package-private
+    XDesktopPeer(){
+        initWithLock();
     }
 
     static boolean isDesktopSupported() {
+        initWithLock();
         return nativeLibraryLoaded;
     }
 
@@ -83,12 +99,17 @@
     }
 
     private void launch(URI uri) throws IOException {
-        if (!nativeLibraryLoaded) {
-            throw new IOException("Failed to load native libraries.");
+        byte[] uriByteArray = ( uri.toString() + '\0' ).getBytes();
+        boolean result = false;
+        XToolkit.awtLock();
+        try {
+            if (!nativeLibraryLoaded) {
+                throw new IOException("Failed to load native libraries.");
+            }
+            result = gnome_url_show(uriByteArray);
+        } finally {
+            XToolkit.awtUnlock();
         }
-
-        byte[] uriByteArray = ( uri.toString() + '\0' ).getBytes();
-        boolean result = gnome_url_show(uriByteArray);
         if (!result) {
             throw new IOException("Failed to show URI:" + uri);
         }
--- a/src/solaris/native/sun/xawt/awt_Desktop.c	Tue Feb 15 15:09:20 2011 +0000
+++ b/src/solaris/native/sun/xawt/awt_Desktop.c	Wed Feb 16 01:12:53 2011 +0300
@@ -48,9 +48,15 @@
     }
     dlerror(); /* Clear errors */
     gnome_vfs_init = (GNOME_VFS_INIT_TYPE*)dlsym(vfs_handle, "gnome_vfs_init");
+    if (gnome_vfs_init == NULL){
+#ifdef INTERNAL_BUILD
+        fprintf(stderr, "dlsym( gnome_vfs_init) returned NULL\n");
+#endif
+        return 0;
+    }
     if ((errmsg = dlerror()) != NULL) {
 #ifdef INTERNAL_BUILD
-        fprintf(stderr, "can not find symble gnome_vfs_init\n");
+        fprintf(stderr, "can not find symbol gnome_vfs_init %s \n", errmsg);
 #endif
         return 0;
     }