diff options
author | Michael Bien <[email protected]> | 2010-06-17 00:14:11 +0200 |
---|---|---|
committer | Michael Bien <[email protected]> | 2010-06-17 00:14:11 +0200 |
commit | 33a24c85dd18d851b614359bb6b19535afd56d33 (patch) | |
tree | e943d0d45d28e41633d7279c41e03d81fd94a009 | |
parent | eca1abf29ac48dd18c2d40f44c2396ce160df6f2 (diff) |
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
15 files changed, 35 insertions, 26 deletions
diff --git a/make/config/jogl/glu-CustomJavaCode-base.java b/make/config/jogl/glu-CustomJavaCode-base.java index 7aee33ae1..8d2ebe662 100755 --- a/make/config/jogl/glu-CustomJavaCode-base.java +++ b/make/config/jogl/glu-CustomJavaCode-base.java @@ -169,7 +169,7 @@ protected static boolean checkedGLUtessellatorImpl = false; protected static final void validateGLUtessellatorImpl() { if(!checkedGLUtessellatorImpl) { - availableGLUtessellatorImpl = ReflectionUtil.isClassAvailable("com.jogamp.opengl.impl.glu.tessellator.GLUtessellatorImpl"); + availableGLUtessellatorImpl = ReflectionUtil.isClassAvailable("com.jogamp.opengl.impl.glu.tessellator.GLUtessellatorImpl", GLU.class.getClassLoader()); checkedGLUtessellatorImpl = true; } if(!availableGLUtessellatorImpl) { @@ -1220,7 +1220,7 @@ protected static final void validateGLUquadricImpl() { if(!checkedGLUquadricImpl) { synchronized (syncObject) { if(!checkedGLUquadricImpl) { - availableGLUquadricImpl = ReflectionUtil.isClassAvailable("com.jogamp.opengl.impl.glu.GLUquadricImpl"); + availableGLUquadricImpl = ReflectionUtil.isClassAvailable("com.jogamp.opengl.impl.glu.GLUquadricImpl", GLU.class.getClassLoader()); checkedGLUquadricImpl = true; } } diff --git a/make/config/jogl/glu-CustomJavaCode-gl2es1.java b/make/config/jogl/glu-CustomJavaCode-gl2es1.java index 742f7c240..3f520498b 100755 --- a/make/config/jogl/glu-CustomJavaCode-gl2es1.java +++ b/make/config/jogl/glu-CustomJavaCode-gl2es1.java @@ -86,7 +86,7 @@ protected static boolean checkedMipmap = false; protected static final void validateMipmap() { if(!checkedMipmap) { - availableMipmap = ReflectionUtil.isClassAvailable("com.jogamp.opengl.impl.glu.mipmap.Mipmap"); + availableMipmap = ReflectionUtil.isClassAvailable("com.jogamp.opengl.impl.glu.mipmap.Mipmap", GLU.class.getClassLoader()); checkedMipmap = true; } if(!availableMipmap) { 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); diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/impl/NativeWindowFactoryImpl.java b/src/nativewindow/classes/com/jogamp/nativewindow/impl/NativeWindowFactoryImpl.java index 8cf02965b..2ee2cb02c 100644 --- a/src/nativewindow/classes/com/jogamp/nativewindow/impl/NativeWindowFactoryImpl.java +++ b/src/nativewindow/classes/com/jogamp/nativewindow/impl/NativeWindowFactoryImpl.java @@ -87,7 +87,7 @@ public class NativeWindowFactoryImpl extends NativeWindowFactory { throw new IllegalArgumentException("OS " + getNativeOSName(false) + " not yet supported"); } - nativeWindowConstructor = ReflectionUtil.getConstructor(windowClassName, new Class[] { Object.class, AbstractGraphicsConfiguration.class }); + nativeWindowConstructor = ReflectionUtil.getConstructor(windowClassName, getClass().getClassLoader(), new Class[] { Object.class, AbstractGraphicsConfiguration.class }); } catch (Exception e) { throw (IllegalArgumentException) new IllegalArgumentException().initCause(e); } diff --git a/src/nativewindow/classes/javax/media/nativewindow/GraphicsConfigurationFactory.java b/src/nativewindow/classes/javax/media/nativewindow/GraphicsConfigurationFactory.java index c692e51c4..75d5c33bc 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/GraphicsConfigurationFactory.java +++ b/src/nativewindow/classes/javax/media/nativewindow/GraphicsConfigurationFactory.java @@ -78,7 +78,7 @@ public abstract class GraphicsConfigurationFactory { if (NativeWindowFactory.TYPE_X11.equals(NativeWindowFactory.getNativeWindowType(true))) { try { GraphicsConfigurationFactory factory = (GraphicsConfigurationFactory) - ReflectionUtil.createInstance("com.jogamp.nativewindow.impl.x11.X11GraphicsConfigurationFactory", new Object[] {}); + ReflectionUtil.createInstance("com.jogamp.nativewindow.impl.x11.X11GraphicsConfigurationFactory", GraphicsConfigurationFactory.class.getClassLoader(), new Object[] {}); registerFactory(javax.media.nativewindow.x11.X11GraphicsDevice.class, factory); } catch (Exception e) { throw new RuntimeException(e); diff --git a/src/nativewindow/classes/javax/media/nativewindow/NativeWindowFactory.java b/src/nativewindow/classes/javax/media/nativewindow/NativeWindowFactory.java index 41be6e4b2..eb52e7211 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/NativeWindowFactory.java +++ b/src/nativewindow/classes/javax/media/nativewindow/NativeWindowFactory.java @@ -113,8 +113,10 @@ public abstract class NativeWindowFactory { nativeWindowingTypeCustom = nativeOSNameCustom; } + ClassLoader cl = NativeWindowFactory.class.getClassLoader(); + if( TYPE_X11.equals(nativeWindowingTypePure) ) { - ReflectionUtil.callStaticMethod( X11UtilClassName, "initSingleton", new Class[] { }, new Object[] { } ); + ReflectionUtil.callStaticMethod( X11UtilClassName, cl, "initSingleton", new Class[] { }, new Object[] { } ); } registeredFactories = Collections.synchronizedMap(new HashMap()); @@ -130,12 +132,12 @@ public abstract class NativeWindowFactory { // We break compile-time dependencies on the AWT here to // make it easier to run this code on mobile devices isAWTAvailable = !Debug.getBooleanProperty("java.awt.headless", true, acc) && - ReflectionUtil.isClassAvailable(AWTComponentClassName) && - ReflectionUtil.isClassAvailable("javax.media.nativewindow.awt.AWTGraphicsDevice") ; + ReflectionUtil.isClassAvailable(AWTComponentClassName, cl) && + ReflectionUtil.isClassAvailable("javax.media.nativewindow.awt.AWTGraphicsDevice", cl) ; if ( isAWTAvailable ) { // register either our default factory or (if exist) the X11/AWT one -> AWT Component - registerFactory(ReflectionUtil.getClass(AWTComponentClassName, false), factory); + registerFactory(ReflectionUtil.getClass(AWTComponentClassName, false, cl), factory); } if(DEBUG) { diff --git a/src/newt/classes/com/jogamp/newt/impl/macosx/MacDisplay.java b/src/newt/classes/com/jogamp/newt/impl/macosx/MacDisplay.java index 861dc7a6c..0fde19cd4 100755 --- a/src/newt/classes/com/jogamp/newt/impl/macosx/MacDisplay.java +++ b/src/newt/classes/com/jogamp/newt/impl/macosx/MacDisplay.java @@ -93,17 +93,20 @@ public class MacDisplay extends Display { } protected static boolean runOnAWTEDT(boolean wait, Runnable r) { - if(ReflectionUtil.isClassAvailable("java.awt.EventQueue")) { + ClassLoader cl = MacDisplay.class.getClassLoader(); + if(ReflectionUtil.isClassAvailable("java.awt.EventQueue", cl)) { try { if(wait) { ReflectionUtil.callStaticMethod( "java.awt.EventQueue", + cl, "invokeAndWait", new Class[] { java.lang.Runnable.class }, new Object[] { r } ); } else { ReflectionUtil.callStaticMethod( "java.awt.EventQueue", + cl, "invokeLater", new Class[] { java.lang.Runnable.class }, new Object[] { r } ); diff --git a/src/newt/classes/com/jogamp/newt/util/MainThread.java b/src/newt/classes/com/jogamp/newt/util/MainThread.java index cfe1876b5..cbd520104 100644 --- a/src/newt/classes/com/jogamp/newt/util/MainThread.java +++ b/src/newt/classes/com/jogamp/newt/util/MainThread.java @@ -116,7 +116,7 @@ public class MainThread { // start user app .. try { - Class mainClass = ReflectionUtil.getClass(mainClassName, true); + Class mainClass = ReflectionUtil.getClass(mainClassName, true, getClass().getClassLoader()); if(null==mainClass) { throw new RuntimeException(new ClassNotFoundException("MainThread couldn't find main class "+mainClassName)); } |