Bug 1317 - JOGL AWT sample crashes on Java 9
Summary: JOGL AWT sample crashes on Java 9
Status: IN_PROGRESS
Alias: None
Product: Nativewindow
Classification: JogAmp
Component: core (show other bugs)
Version: 2.4.0
Hardware: pc_x86_64 windows
: P4 major
Assignee: Sven Gothel
URL:
Depends on:
Blocks:
 
Reported: 2016-07-14 15:41 CEST by Stijn Debruyckere
Modified: 2017-12-08 07:43 CET (History)
2 users (show)

See Also:
Type: DEFECT
SCM Refs:
Workaround: TRUE


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Stijn Debruyckere 2016-07-14 15:41:10 CEST
The JOGL AWT sample crashes on Java 9.

To reproduce, just start the JOGL AWT sample that can be found here:
  https://jogamp.org/wiki/index.php/Using_JOGL_in_AWT_SWT_and_Swing

Environment: Windows 64-bit, Java 9 (build 9-ea+126).

Error:
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: -1
	at jogamp.opengl.windows.wgl.awt.WindowsAWTWGLGraphicsConfigurationFactory.chooseGraphicsConfigurationImpl(WindowsAWTWGLGraphicsConfigurationFactory.java:171)
	at com.jogamp.nativewindow.GraphicsConfigurationFactory.chooseGraphicsConfiguration(GraphicsConfigurationFactory.java:424)
	at com.jogamp.opengl.awt.GLCanvas.chooseGraphicsConfiguration(GLCanvas.java:1560)
	at com.jogamp.opengl.awt.GLCanvas.addNotify(GLCanvas.java:611)
	at java.awt.Container.addNotify(java.desktop@9-ea/Container.java:2795)
	at java.awt.Window.addNotify(java.desktop@9-ea/Window.java:768)
	at java.awt.Frame.addNotify(java.desktop@9-ea/Frame.java:490)
	at java.awt.Window.show(java.desktop@9-ea/Window.java:1030)
	at java.awt.Component.show(java.desktop@9-ea/Component.java:1694)
	at java.awt.Component.setVisible(java.desktop@9-ea/Component.java:1641)
	at java.awt.Window.setVisible(java.desktop@9-ea/Window.java:1013)
	at OneTriangleAWT.main(OneTriangleAWT.java:62)
	at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(java.base@9-ea/Native Method)
	at jdk.internal.reflect.NativeMethodAccessorImpl.invoke(java.base@9-ea/NativeMethodAccessorImpl.java:62)
	at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(java.base@9-ea/DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(java.base@9-ea/Method.java:533)
	at com.intellij.rt.execution.application.AppMain.main(AppMain.java:144)
Comment 1 Stijn Debruyckere 2016-07-14 15:49:56 CEST
Note that both OneTriangleAWT and OneTriangleSwingGLCanvas crash with the same error. OneTriangleSwingGLJPanel crashes as well, but that seems due to a JDK bug: 
  https://bugs.openjdk.java.net/browse/JDK-8160421
Comment 2 Julien Gouesse 2016-07-26 14:33:29 CEST
(In reply to Stijn Debruyckere from comment #1)
> Note that both OneTriangleAWT and OneTriangleSwingGLCanvas crash with the
> same error. OneTriangleSwingGLJPanel crashes as well, but that seems due to
> a JDK bug: 
>   https://bugs.openjdk.java.net/browse/JDK-8160421

Why do you think that it seems to be due to this bug?
Comment 3 Stijn Debruyckere 2016-07-27 17:05:08 CEST
For all clarity: OneTriangleAWT and OneTriangleSwingGLCanvas crashed with the ArrayIndexOutOfBoundsException mentioned in the description.

OneTriangleSwingGLJPanel crashed with a NullPointerException, the exact same one as JDK-8160421 which leads me to believe it was due to that bug ;-) The resolution is set to fixed, but the fix version still says 'team' instead of '9' so I believe it's not yet available in the EA builds.
Comment 4 Julien Gouesse 2016-07-27 20:33:04 CEST
(In reply to Stijn Debruyckere from comment #3)
> For all clarity: OneTriangleAWT and OneTriangleSwingGLCanvas crashed with
> the ArrayIndexOutOfBoundsException mentioned in the description.
> 
> OneTriangleSwingGLJPanel crashed with a NullPointerException, the exact same
> one as JDK-8160421 which leads me to believe it was due to that bug ;-) The
> resolution is set to fixed, but the fix version still says 'team' instead of
> '9' so I believe it's not yet available in the EA builds.

Ok, thanks, it's crystal clear now. Please let me know when the fix is available in a EA build.
Comment 5 Julien Gouesse 2017-04-20 15:35:45 CEST
(In reply to Stijn Debruyckere from comment #3)
> For all clarity: OneTriangleAWT and OneTriangleSwingGLCanvas crashed with
> the ArrayIndexOutOfBoundsException mentioned in the description.
> 
> OneTriangleSwingGLJPanel crashed with a NullPointerException, the exact same
> one as JDK-8160421 which leads me to believe it was due to that bug ;-) The
> resolution is set to fixed, but the fix version still says 'team' instead of
> '9' so I believe it's not yet available in the EA builds.

OneTriangleSwingGLJPanel should work now as JDK-8160421 is fixed in the latest early build. Please can you give it a try?
Comment 6 Julien Gouesse 2017-06-05 13:34:20 CEST
When I run JOGLQuad (my example from the wiki) with the build 172, I get:
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: -1
        at jogamp.opengl.windows.wgl.awt.WindowsAWTWGLGraphicsConfigurationFactory.chooseGraphicsConfigurationImpl(WindowsAWTWGLGraphicsConfigurationFactory.java:171)
        at com.jogamp.nativewindow.GraphicsConfigurationFactory.chooseGraphicsConfiguration(GraphicsConfigurationFactory.java:424)
        at com.jogamp.opengl.awt.GLCanvas.chooseGraphicsConfiguration(GLCanvas.java:1560)
        at com.jogamp.opengl.awt.GLCanvas.addNotify(GLCanvas.java:611)
        at java.desktop/java.awt.Container.addNotify(Container.java:2796)
        at java.desktop/java.awt.Window.addNotify(Window.java:772)
        at java.desktop/java.awt.Frame.addNotify(Frame.java:490)
        at java.desktop/java.awt.Window.show(Window.java:1034)
        at java.desktop/java.awt.Component.show(Component.java:1669)
        at java.desktop/java.awt.Component.setVisible(Component.java:1616)
        at java.desktop/java.awt.Window.setVisible(Window.java:1017)
        at JOGLQuad.main(JOGLQuad.java:86)
Comment 7 Julien Gouesse 2017-06-05 13:38:37 CEST
I entered this:
"C:\Program Files\Java\jdk-9\bin\java.exe" --permit-illegal-access  -cp .;C:\checkout-svn\HEAD1\java\lib\jogamp-fat.jar JOGLQuad

It seems to work:
WARNING: --permit-illegal-access will be removed in the next major release
WARNING: Illegal access by com.jogamp.common.os.NativeLibrary$3 (file:/C:/checkout-svn/HEAD1/java/lib/jogamp-fat.jar) to method java.lang.ClassLoader.findLibrary(java.lang.String) (permitted by --permit-illegal-access)
WARNING: Illegal access by jogamp.opengl.awt.Java2D$2 (file:/C:/checkout-svn/HEAD1/java/lib/jogamp-fat.jar) to field sun.java2d.opengl.OGLUtilities.UNDEFINED (permitted by --permit-illegal-access)
WARNING: Illegal access by jogamp.opengl.awt.Java2D$2 (file:/C:/checkout-svn/HEAD1/java/lib/jogamp-fat.jar) to field sun.java2d.opengl.OGLUtilities.WINDOW (permitted by --permit-illegal-access)
WARNING: Illegal access by jogamp.opengl.awt.Java2D$2 (file:/C:/checkout-svn/HEAD1/java/lib/jogamp-fat.jar) to field sun.java2d.opengl.OGLUtilities.TEXTURE (permitted by --permit-illegal-access)
WARNING: Illegal access by jogamp.opengl.awt.Java2D$2 (file:/C:/checkout-svn/HEAD1/java/lib/jogamp-fat.jar) to field sun.java2d.opengl.OGLUtilities.FLIP_BACKBUFFER (permitted by --permit-illegal-access)
WARNING: Illegal access by jogamp.opengl.awt.Java2D$2 (file:/C:/checkout-svn/HEAD1/java/lib/jogamp-fat.jar) to field sun.java2d.opengl.OGLUtilities.FBOBJECT (permitted by --permit-illegal-access)
WARNING: Illegal access by jogamp.nativewindow.jawt.JAWTUtil$1 (file:/C:/checkout-svn/HEAD1/java/lib/jogamp-fat.jar) to method sun.awt.SunToolkit.awtLock() (permitted by --permit-illegal-access)
WARNING: Illegal access by jogamp.nativewindow.jawt.JAWTUtil$1 (file:/C:/checkout-svn/HEAD1/java/lib/jogamp-fat.jar) to method sun.awt.SunToolkit.awtUnlock() (permitted by --permit-illegal-access)
WARNING: Illegal access by com.jogamp.opengl.awt.GLCanvas$14 (file:/C:/checkout-svn/HEAD1/java/lib/jogamp-fat.jar) to method sun.awt.windows.WToolkit.disableBackgroundErase(java.awt.Canvas) (permitted by --permit-illegal-access)
WARNING: Illegal access by jogamp.nativewindow.jawt.windows.Win32SunJDKReflection$1 (file:/C:/checkout-svn/HEAD1/java/lib/jogamp-fat.jar) to method sun.awt.Win32GraphicsConfig.getConfig(sun.awt.Win32GraphicsDevice,int) (permitted by --permit-illegal-access)
WARNING: Illegal access by jogamp.nativewindow.jawt.windows.Win32SunJDKReflection$1 (file:/C:/checkout-svn/HEAD1/java/lib/jogamp-fat.jar) to method sun.awt.Win32GraphicsConfig.getVisual() (permitted by --permit-illegal-access)
WARNING: Illegal access by com.jogamp.nativewindow.awt.AppContextInfo (file:/C:/checkout-svn/HEAD1/java/lib/jogamp-fat.jar) to method sun.awt.AppContext.getAppContext() (permitted by --permit-illegal-access)

We have a workaround for sure.
Comment 8 Julien Gouesse 2017-06-05 13:39:30 CEST
It's no longer a blocker as we have a workaround.
Comment 9 Julien Gouesse 2017-06-09 11:33:13 CEST
It should help to break the encapsulation when --permit-illegal-access stops being supported in Java 1.10:
--add-exports=java.base/java.lang=ALL-UNNAMED
--add-exports=java.desktop/sun.awt=ALL-UNNAMED
--add-exports=java.desktop/sun.java2d=ALL-UNNAMED

The very first exports addition should work on the long term to remove the warning about java.lang.ClassLoader.findLibrary(java.lang.String). However, the packages in sun.awt and sun.java2d might be moved or substantially modified.

It works with Java Webstart too:
https://bugs.openjdk.java.net/browse/JDK-8172986

I need to test my suggestions. If they work, I'll lower the severity of this bug to "normal".
Comment 10 Andy Skinner 2017-09-08 16:32:05 CEST
My understanding is that the reflective access will work, but that a warning will appear.  Is that correct?

Since we use JOGL in a product used by many customers, we would see that warning as a major issue.  I'm still reading up on this, but do we know what might be done about it?

thanks
andy
Comment 11 Julien Gouesse 2017-09-08 16:59:00 CEST
(In reply to Andy Skinner from comment #10)
> My understanding is that the reflective access will work, but that a warning
> will appear.  Is that correct?
> 
> Since we use JOGL in a product used by many customers, we would see that
> warning as a major issue.  I'm still reading up on this, but do we know what
> might be done about it?
> 
> thanks
> andy

The warning appears when using the dumbest workaround based on --permit-illegal-access but the second solution shouldn't print any warning.
Comment 12 Andy Skinner 2017-09-08 17:38:09 CEST
The second solution is using the other add exports?
--add-exports=java.base/java.lang=ALL-UNNAMED
--add-exports=java.desktop/sun.awt=ALL-UNNAMED
--add-exports=java.desktop/sun.java2d=ALL-UNNAMED

That does seem to work for me, and will do for now.

thanks
andy
Comment 13 Julien Gouesse 2017-09-08 18:38:39 CEST
(In reply to Andy Skinner from comment #12)
> The second solution is using the other add exports?
> --add-exports=java.base/java.lang=ALL-UNNAMED
> --add-exports=java.desktop/sun.awt=ALL-UNNAMED
> --add-exports=java.desktop/sun.java2d=ALL-UNNAMED
> 
> That does seem to work for me, and will do for now.
> 
> thanks
> andy

Yes. Thank you for the feedback.
Comment 14 Julien Gouesse 2017-12-08 07:43:18 CET
Oops, maybe something wrong happens under Mac OS X (in jogamp.opengl.macosx.cgl.awt.MacOSXAWTCGLGraphicsConfigurationFactory) but it has to be tested without mixing JOGL 2 with JOGL 1:
http://forum.jogamp.org/Jogl-Jogamp-on-Java-9-tp4038012p4038383.html