From e1c8add69973b0eae9a87cf2181a0f1cbbe62f4b Mon Sep 17 00:00:00 2001 From: Wade Walker Date: Fri, 4 Jan 2019 09:51:44 -0600 Subject: Removed illegal reflective access to sun.java2d.opengl.OGLUtilities We were reading a variety of surface type definitions from sun.java2d.opengl.OGLUtilities using reflection, which has thrown warnings since Java 9 and which soon will become illegal. For now, just hard-coded these types to remove the warnings that happen during static initialization. Eventually the entire Java2D class will have to be revamped if we want to be able to actually use it. --- src/jogl/classes/jogamp/opengl/awt/Java2D.java | 39 ++++++-------------------- 1 file changed, 8 insertions(+), 31 deletions(-) (limited to 'src/jogl/classes/jogamp/opengl/awt/Java2D.java') diff --git a/src/jogl/classes/jogamp/opengl/awt/Java2D.java b/src/jogl/classes/jogamp/opengl/awt/Java2D.java index f8826f23d..7f6c48ee2 100644 --- a/src/jogl/classes/jogamp/opengl/awt/Java2D.java +++ b/src/jogl/classes/jogamp/opengl/awt/Java2D.java @@ -87,12 +87,14 @@ public class Java2D { private static Method getOGLSurfaceTypeMethod; // Publicly-visible constants for OpenGL surface types - public static final int UNDEFINED = getOGLUtilitiesIntField("UNDEFINED"); - public static final int WINDOW = getOGLUtilitiesIntField("WINDOW"); - public static final int PBUFFER = getOGLUtilitiesIntField("PBUFFER"); - public static final int TEXTURE = getOGLUtilitiesIntField("TEXTURE"); - public static final int FLIP_BACKBUFFER = getOGLUtilitiesIntField("FLIP_BACKBUFFER"); - public static final int FBOBJECT = getOGLUtilitiesIntField("FBOBJECT"); + // Used to determine these by reflection, but in Java 9+ that's illegal, so had to just + // hard-code these from sun.java2d.pipe.hw.AccelSurface. + public static final int UNDEFINED = 0; + public static final int WINDOW = 1; + public static final int PBUFFER = 2; // this one doesn't even seem to exist in current versions of AccelSurface + public static final int TEXTURE = 3; + public static final int FLIP_BACKBUFFER = 4; + public static final int FBOBJECT = 5; // If FBOs are enabled in the Java2D/OpenGL pipeline, all contexts // created by JOGL must share textures and display lists with the @@ -565,31 +567,6 @@ public class Java2D { } } - private static int getOGLUtilitiesIntField(final String name) { - final Integer i = AccessController.doPrivileged(new PrivilegedAction() { - @Override - public Integer run() { - try { - final Class utils = Class.forName("sun.java2d.opengl.OGLUtilities"); - final Field f = utils.getField(name); - f.setAccessible(true); - return (Integer) f.get(null); - } catch (final Exception e) { - if (DEBUG) { - e.printStackTrace(); - } - return null; - } - } - }); - if (i == null) - return 0; - if (DEBUG) { - System.err.println("OGLUtilities." + name + " = " + i.intValue()); - } - return i.intValue(); - } - private static void initFBOShareContext(final GraphicsDevice device) { // Note 1: this must not be done in the static initalizer due to // deadlock problems. -- cgit v1.2.3