diff options
author | Sven Gothel <[email protected]> | 2009-06-18 06:50:13 +0000 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2010-04-19 00:56:06 +0200 |
commit | 248d4afb694355037b1dd98db3ed48f1fff20f50 (patch) | |
tree | 3f9afa9824a76182e43e03dd7498198c75b5e87c /src/nativewindow | |
parent | 938e9b6628c2b09c9dfb183d42c7dab834b48876 (diff) |
- Fix: X11 locking The current thread default display or the given display is being used, hence it is no more required to use a ToolkitLock for X11 without AWT.
Removed X11 ToolkitLock in case of X11 without AWT,
which is being detected with the absence of the classes
java.awt.Component _AND_ javax.media.nativewindow.awt.AWTGraphicsDevice
or with the system property
java.awt.headless=true
Only in the Java2D/Swing case, one 'leaking' Display
is created within canCreateGLPbuffer().
- Workaround for Hotsport bugs #4395095, #6852404
4395095 JNI access to java.nio DirectBuffer constructor/accessor
6852404 Race condition in JNI Direct Buffer access and creation routines
- Added build.xml
-Dbuild.noarchives=true property to skip the time consuming
creation of zip archives.
git-svn-id: file:///usr/local/projects/SUN/JOGL/git-svn/svn-server-sync/jogl/trunk@1988 232f8b59-042b-4e1e-8c03-345bb8c30851
Diffstat (limited to 'src/nativewindow')
-rw-r--r-- | src/nativewindow/classes/com/sun/nativewindow/impl/jvm/JVMUtil.java (renamed from src/nativewindow/classes/com/sun/nativewindow/impl/x11/X11NativeWindowFactory.java) | 79 |
1 files changed, 40 insertions, 39 deletions
diff --git a/src/nativewindow/classes/com/sun/nativewindow/impl/x11/X11NativeWindowFactory.java b/src/nativewindow/classes/com/sun/nativewindow/impl/jvm/JVMUtil.java index 1c67d61..a4bffb1 100644 --- a/src/nativewindow/classes/com/sun/nativewindow/impl/x11/X11NativeWindowFactory.java +++ b/src/nativewindow/classes/com/sun/nativewindow/impl/jvm/JVMUtil.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009 Sun Microsystems, Inc. All Rights Reserved. + * Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are @@ -30,48 +30,49 @@ * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. */ -package com.sun.nativewindow.impl.x11; +package com.sun.nativewindow.impl.jvm; -import javax.media.nativewindow.*; +import java.nio.ByteBuffer; import com.sun.nativewindow.impl.*; -public class X11NativeWindowFactory extends NativeWindowFactoryImpl { - // On X11 platforms we need to do some locking; this basic - // implementation should suffice for some simple window toolkits - private ToolkitLock toolkitLock = new ToolkitLock() { - private Thread owner; - private int recursionCount; - - public synchronized void lock() { - Thread cur = Thread.currentThread(); - if (owner == cur) { - ++recursionCount; - return; - } - while (owner != null) { - try { - wait(); - } catch (InterruptedException e) { - throw new RuntimeException(e); - } - } - owner = cur; - } +/** + * Currently this tool works around the Hotspot race condition bugs: + <PRE> + 4395095 JNI access to java.nio DirectBuffer constructor/accessor + 6852404 Race condition in JNI Direct Buffer access and creation routines + </PRE> + * + * Make sure to initialize this class as soon as possible, + * before doing any multithreading work. + * + */ +public class JVMUtil { + private static final boolean DEBUG = Debug.debug("JVMUtil"); + + static { + initSingleton(); + } + + private static volatile boolean isInit = false; - public synchronized void unlock() { - if (owner != Thread.currentThread()) { - throw new RuntimeException("Not owner"); - } - if (recursionCount > 0) { - --recursionCount; - return; - } - owner = null; - notifyAll(); - } - }; + public static synchronized void initSingleton() { + if(isInit) return; + isInit=true; - public ToolkitLock getToolkitLock() { - return toolkitLock; + NativeLibLoaderBase.loadNativeWindow("jvm"); + + ByteBuffer buffer = InternalBufferUtil.newByteBuffer(64); + if( ! initialize(buffer) ) { + throw new RuntimeException("Failed to initialize the JVMUtil "+Thread.currentThread().getName()); + } + if(DEBUG) { + Exception e = new Exception("JVMUtil.initSingleton() .. initialized "+Thread.currentThread().getName()); + e.printStackTrace(); + } } + + private JVMUtil() {} + + private static native boolean initialize(java.nio.ByteBuffer buffer); } + |