提交 cd62ed16 编写于 作者: D dav

6994933: java.awt.Desktop feature is "intermittently" supported on Solaris....

6994933: java.awt.Desktop feature is "intermittently" supported on Solaris. Really unexpected behavior.
Reviewed-by: art, dcherepanov
上级 f5cd8dd5
...@@ -44,11 +44,27 @@ import java.awt.peer.DesktopPeer; ...@@ -44,11 +44,27 @@ import java.awt.peer.DesktopPeer;
public class XDesktopPeer implements DesktopPeer { public class XDesktopPeer implements DesktopPeer {
private static boolean nativeLibraryLoaded = false; private static boolean nativeLibraryLoaded = false;
static { private static boolean initExecuted = false;
private static void initWithLock(){
XToolkit.awtLock();
try {
if (!initExecuted) {
nativeLibraryLoaded = init(); nativeLibraryLoaded = init();
} }
} finally {
initExecuted = true;
XToolkit.awtUnlock();
}
}
//package-private
XDesktopPeer(){
initWithLock();
}
static boolean isDesktopSupported() { static boolean isDesktopSupported() {
initWithLock();
return nativeLibraryLoaded; return nativeLibraryLoaded;
} }
...@@ -83,12 +99,17 @@ public class XDesktopPeer implements DesktopPeer { ...@@ -83,12 +99,17 @@ public class XDesktopPeer implements DesktopPeer {
} }
private void launch(URI uri) throws IOException { private void launch(URI uri) throws IOException {
byte[] uriByteArray = ( uri.toString() + '\0' ).getBytes();
boolean result = false;
XToolkit.awtLock();
try {
if (!nativeLibraryLoaded) { if (!nativeLibraryLoaded) {
throw new IOException("Failed to load native libraries."); throw new IOException("Failed to load native libraries.");
} }
result = gnome_url_show(uriByteArray);
byte[] uriByteArray = ( uri.toString() + '\0' ).getBytes(); } finally {
boolean result = gnome_url_show(uriByteArray); XToolkit.awtUnlock();
}
if (!result) { if (!result) {
throw new IOException("Failed to show URI:" + uri); throw new IOException("Failed to show URI:" + uri);
} }
......
...@@ -48,9 +48,15 @@ int init(){ ...@@ -48,9 +48,15 @@ int init(){
} }
dlerror(); /* Clear errors */ dlerror(); /* Clear errors */
gnome_vfs_init = (GNOME_VFS_INIT_TYPE*)dlsym(vfs_handle, "gnome_vfs_init"); 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) { if ((errmsg = dlerror()) != NULL) {
#ifdef INTERNAL_BUILD #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 #endif
return 0; return 0;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册