From 33a24c85dd18d851b614359bb6b19535afd56d33 Mon Sep 17 00:00:00 2001 From: Michael Bien Date: Thu, 17 Jun 2010 00:14:11 +0200 Subject: Provide a classloader for all reflection driven classloading ops. - attempt to solve some issues in module systems - all classes are now loaded with the same classloader which loads GLProfile --- src/jogl/classes/com/jogamp/opengl/impl/GLContextImpl.java | 2 +- src/jogl/classes/com/jogamp/opengl/impl/ThreadingImpl.java | 7 ++++--- .../classes/com/jogamp/opengl/impl/egl/EGLDrawableFactory.java | 2 +- .../opengl/impl/macosx/cgl/MacOSXCGLDrawableFactory.java | 2 +- .../opengl/impl/windows/wgl/WindowsWGLDrawableFactory.java | 2 +- .../com/jogamp/opengl/impl/x11/glx/X11GLXDrawableFactory.java | 2 +- src/jogl/classes/javax/media/opengl/GLDrawableFactory.java | 7 ++++--- src/jogl/classes/javax/media/opengl/GLProfile.java | 10 ++++++---- 8 files changed, 19 insertions(+), 15 deletions(-) (limited to 'src/jogl/classes') diff --git a/src/jogl/classes/com/jogamp/opengl/impl/GLContextImpl.java b/src/jogl/classes/com/jogamp/opengl/impl/GLContextImpl.java index dc98b5514..54d9b4e80 100644 --- a/src/jogl/classes/com/jogamp/opengl/impl/GLContextImpl.java +++ b/src/jogl/classes/com/jogamp/opengl/impl/GLContextImpl.java @@ -641,7 +641,7 @@ public abstract class GLContextImpl extends GLContext { // private Object createInstance(GLProfile glp, String suffix, Class[] cstrArgTypes, Object[] cstrArgs) { - return ReflectionUtil.createInstance(glp.getGLImplBaseClassName()+suffix, cstrArgTypes, cstrArgs); + return ReflectionUtil.createInstance(glp.getGLImplBaseClassName()+suffix, getClass().getClassLoader(), cstrArgTypes, cstrArgs); } /** Create the GL for this context. */ diff --git a/src/jogl/classes/com/jogamp/opengl/impl/ThreadingImpl.java b/src/jogl/classes/com/jogamp/opengl/impl/ThreadingImpl.java index 1a68f38d4..35bb93899 100644 --- a/src/jogl/classes/com/jogamp/opengl/impl/ThreadingImpl.java +++ b/src/jogl/classes/com/jogamp/opengl/impl/ThreadingImpl.java @@ -64,6 +64,7 @@ public class ThreadingImpl { AccessController.doPrivileged(new PrivilegedAction() { public Object run() { String workaround = Debug.getProperty("jogl.1thread", true); + ClassLoader cl = ThreadingImpl.class.getClassLoader(); // Default to using the AWT thread on all platforms except // Windows. On OS X there is instability apparently due to // using the JAWT on non-AWT threads. On X11 platforms there @@ -72,8 +73,8 @@ public class ThreadingImpl { // while holding the AWT lock. The optimization of // makeCurrent / release calls isn't worth these stability // problems. - hasAWT = ReflectionUtil.isClassAvailable("java.awt.Canvas") && - ReflectionUtil.isClassAvailable("javax.media.opengl.awt.GLCanvas"); + hasAWT = ReflectionUtil.isClassAvailable("java.awt.Canvas", cl) && + ReflectionUtil.isClassAvailable("javax.media.opengl.awt.GLCanvas", cl); String osType = NativeWindowFactory.getNativeWindowType(false); _isX11 = NativeWindowFactory.TYPE_X11.equals(osType); @@ -103,7 +104,7 @@ public class ThreadingImpl { Object threadingPluginObj=null; // try to fetch the AWTThreadingPlugin try { - threadingPluginObj = ReflectionUtil.createInstance("com.jogamp.opengl.impl.awt.AWTThreadingPlugin"); + threadingPluginObj = ReflectionUtil.createInstance("com.jogamp.opengl.impl.awt.AWTThreadingPlugin", cl); } catch (JogampRuntimeException jre) { /* n/a .. */ } return threadingPluginObj; } diff --git a/src/jogl/classes/com/jogamp/opengl/impl/egl/EGLDrawableFactory.java b/src/jogl/classes/com/jogamp/opengl/impl/egl/EGLDrawableFactory.java index 935281c6c..72498a7af 100755 --- a/src/jogl/classes/com/jogamp/opengl/impl/egl/EGLDrawableFactory.java +++ b/src/jogl/classes/com/jogamp/opengl/impl/egl/EGLDrawableFactory.java @@ -55,7 +55,7 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl { // Check for other underlying stuff .. if(NativeWindowFactory.TYPE_X11.equals(NativeWindowFactory.getNativeWindowType(true))) { try { - ReflectionUtil.createInstance("com.jogamp.opengl.impl.x11.glx.X11GLXGraphicsConfigurationFactory"); + ReflectionUtil.createInstance("com.jogamp.opengl.impl.x11.glx.X11GLXGraphicsConfigurationFactory", EGLDrawableFactory.class.getClassLoader()); } catch (JogampRuntimeException jre) { /* n/a .. */ } } diff --git a/src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXCGLDrawableFactory.java b/src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXCGLDrawableFactory.java index 7f050412d..e71a78ffb 100644 --- a/src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXCGLDrawableFactory.java +++ b/src/jogl/classes/com/jogamp/opengl/impl/macosx/cgl/MacOSXCGLDrawableFactory.java @@ -78,7 +78,7 @@ public class MacOSXCGLDrawableFactory extends GLDrawableFactoryImpl { new MacOSXCGLGraphicsConfigurationFactory(); try { - ReflectionUtil.createInstance("com.jogamp.opengl.impl.macosx.cgl.awt.MacOSXAWTCGLGraphicsConfigurationFactory", + ReflectionUtil.createInstance("com.jogamp.opengl.impl.macosx.cgl.awt.MacOSXAWTCGLGraphicsConfigurationFactory", getClass().getClassLoader(), new Object[] {}); } catch (JogampRuntimeException jre) { /* n/a .. */ } } diff --git a/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLDrawableFactory.java b/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLDrawableFactory.java index 3fbe769e5..353ed8ac3 100644 --- a/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLDrawableFactory.java +++ b/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLDrawableFactory.java @@ -80,7 +80,7 @@ public class WindowsWGLDrawableFactory extends GLDrawableFactoryImpl { // The act of constructing them causes them to be registered new WindowsWGLGraphicsConfigurationFactory(); try { - ReflectionUtil.createInstance("com.jogamp.opengl.impl.windows.wgl.awt.WindowsAWTWGLGraphicsConfigurationFactory", + ReflectionUtil.createInstance("com.jogamp.opengl.impl.windows.wgl.awt.WindowsAWTWGLGraphicsConfigurationFactory", getClass().getClassLoader(), new Object[] {}); } catch (JogampRuntimeException jre) { /* n/a .. */ } diff --git a/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11GLXDrawableFactory.java b/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11GLXDrawableFactory.java index 822a3d0b3..c08c7c73f 100644 --- a/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11GLXDrawableFactory.java +++ b/src/jogl/classes/com/jogamp/opengl/impl/x11/glx/X11GLXDrawableFactory.java @@ -78,7 +78,7 @@ public class X11GLXDrawableFactory extends GLDrawableFactoryImpl { // The act of constructing them causes them to be registered new X11GLXGraphicsConfigurationFactory(); try { - ReflectionUtil.createInstance("com.jogamp.opengl.impl.x11.glx.awt.X11AWTGLXGraphicsConfigurationFactory", + ReflectionUtil.createInstance("com.jogamp.opengl.impl.x11.glx.awt.X11AWTGLXGraphicsConfigurationFactory", getClass().getClassLoader(), new Object[] {}); } catch (JogampRuntimeException jre) { /* n/a .. */ } diff --git a/src/jogl/classes/javax/media/opengl/GLDrawableFactory.java b/src/jogl/classes/javax/media/opengl/GLDrawableFactory.java index 81c7d4b4a..86e3def38 100644 --- a/src/jogl/classes/javax/media/opengl/GLDrawableFactory.java +++ b/src/jogl/classes/javax/media/opengl/GLDrawableFactory.java @@ -99,13 +99,14 @@ public abstract class GLDrawableFactory { GLDrawableFactory tmp = null; String factoryClassName = Debug.getProperty("jogl.gldrawablefactory.class.name", true, AccessController.getContext()); + ClassLoader cl = GLDrawableFactory.class.getClassLoader(); if (null == factoryClassName) { if ( nativeOSType.equals(NativeWindowFactory.TYPE_X11) ) { factoryClassName = "com.jogamp.opengl.impl.x11.glx.X11GLXDrawableFactory"; } else if ( nativeOSType.equals(NativeWindowFactory.TYPE_WINDOWS) ) { factoryClassName = "com.jogamp.opengl.impl.windows.wgl.WindowsWGLDrawableFactory"; } else if ( nativeOSType.equals(NativeWindowFactory.TYPE_MACOSX) ) { - if(ReflectionUtil.isClassAvailable(macosxFactoryClassNameAWTCGL)) { + if(ReflectionUtil.isClassAvailable(macosxFactoryClassNameAWTCGL, cl)) { factoryClassName = macosxFactoryClassNameAWTCGL; } else { factoryClassName = macosxFactoryClassNameCGL; @@ -122,7 +123,7 @@ public abstract class GLDrawableFactory { System.err.println("GLDrawableFactory.static - Native OS Factory for: "+nativeOSType+": "+factoryClassName); } try { - tmp = (GLDrawableFactory) ReflectionUtil.createInstance(factoryClassName); + tmp = (GLDrawableFactory) ReflectionUtil.createInstance(factoryClassName, cl); } catch (JogampRuntimeException jre) { if (GLProfile.DEBUG) { System.err.println("GLDrawableFactory.static - Native Platform: "+nativeOSType+" - not available: "+factoryClassName); @@ -134,7 +135,7 @@ public abstract class GLDrawableFactory { tmp = null; try { - tmp = (GLDrawableFactory) ReflectionUtil.createInstance("com.jogamp.opengl.impl.egl.EGLDrawableFactory"); + tmp = (GLDrawableFactory) ReflectionUtil.createInstance("com.jogamp.opengl.impl.egl.EGLDrawableFactory", cl); } catch (JogampRuntimeException jre) { if (GLProfile.DEBUG) { System.err.println("GLDrawableFactory.static - EGLDrawableFactory - not available"); diff --git a/src/jogl/classes/javax/media/opengl/GLProfile.java b/src/jogl/classes/javax/media/opengl/GLProfile.java index 21d32e16a..3b40dbe69 100644 --- a/src/jogl/classes/javax/media/opengl/GLProfile.java +++ b/src/jogl/classes/javax/media/opengl/GLProfile.java @@ -854,16 +854,18 @@ public class GLProfile { NativeWindowFactory.initSingleton(); + ClassLoader classloader = GLProfile.class.getClassLoader(); + isAWTAvailable = NativeWindowFactory.isAWTAvailable() && - ReflectionUtil.isClassAvailable("javax.media.opengl.awt.GLCanvas") ; // JOGL + ReflectionUtil.isClassAvailable("javax.media.opengl.awt.GLCanvas", classloader) ; // JOGL - hasGL234Impl = ReflectionUtil.isClassAvailable("com.jogamp.opengl.impl.gl4.GL4bcImpl"); + hasGL234Impl = ReflectionUtil.isClassAvailable("com.jogamp.opengl.impl.gl4.GL4bcImpl", classloader); hasGL4bcImpl = hasGL234Impl; hasGL4Impl = hasGL234Impl; hasGL3bcImpl = hasGL234Impl; hasGL3Impl = hasGL234Impl; hasGL2Impl = hasGL234Impl; - hasGL2ES12Impl = ReflectionUtil.isClassAvailable("com.jogamp.opengl.impl.gl2es12.GL2ES12Impl"); + hasGL2ES12Impl = ReflectionUtil.isClassAvailable("com.jogamp.opengl.impl.gl2es12.GL2ES12Impl", classloader); mappedProfiles = computeProfileMap(); boolean hasDesktopGL = false; @@ -929,7 +931,7 @@ public class GLProfile { hasGL2ES12Impl = hasGL2ES12Impl && GLContext.isGL2Available(); } - if ( ReflectionUtil.isClassAvailable("com.jogamp.opengl.impl.egl.EGLDrawableFactory") ) { + if ( ReflectionUtil.isClassAvailable("com.jogamp.opengl.impl.egl.EGLDrawableFactory", classloader) ) { t=null; try { GLDrawableFactoryImpl factory = (GLDrawableFactoryImpl) GLDrawableFactory.getFactoryImpl(GLES2); -- cgit v1.2.3