Login  Register

NPE in JoglPipeline on Java 17 (works on Java 11)

Posted by juancho on Oct 22, 2023; 10:43pm
URL: https://forum.jogamp.org/NPE-in-JoglPipeline-on-Java-17-works-on-Java-11-tp4043088.html

Hi, I am trying to migrate a project from Java 11 to 17. One of the modules, which uses Java3d throws the following exception:

Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException: Cannot invoke "com.jogamp.nativewindow.awt.AWTGraphicsConfiguration.getAWTGraphicsConfiguration()" because "awtConfig" is null
        at org.jogamp.java3d.JoglPipeline.getGraphicsConfig(JoglPipeline.java:8346)
        at org.jogamp.java3d.Canvas3D.getGraphicsConfig(Canvas3D.java:957)
        at org.jogamp.java3d.Canvas3D.<init>(Canvas3D.java:1027)
        at org.jogamp.java3d.Canvas3D.<init>(Canvas3D.java:989)
        at org.jrmarchio.syrac.S3dPanel.<init>(S3dPanel.java:112)
        at org.jrmarchio.syrac.SyracLevels3D.<init>(SyracLevels3D.java:34)
        at org.jrmarchio.syrac.SyracLevels3D$1.run(SyracLevels3D.java:57)
        at java.desktop/java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:318)
        at java.desktop/java.awt.EventQueue.dispatchEventImpl(EventQueue.java:771)
        at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:722)
        at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:716)
        at java.base/java.security.AccessController.doPrivileged(AccessController.java:399)
        at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:86)
        at java.desktop/java.awt.EventQueue.dispatchEvent(EventQueue.java:741)
        at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:203)
        at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:124)
        at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:113)
        at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:109)
        at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
        at java.desktop/java.awt.EventDispatchThread.run(EventDispatchThread.java:90)

Using following libs:

jogamp-java3d1.7.1-build-20200222
and  jogamp libs 2.5.0

Note that the program runs well with those libs by just switching java version back to 11

I noticed that in the following code snippet
    GraphicsConfiguration getGraphicsConfig(GraphicsConfiguration gconfig) {
a        GraphicsConfigInfo gcInf0 = (GraphicsConfigInfo)Canvas3D.graphicsConfigTable.get(gconfig);
b        AWTGraphicsConfiguration awtConfig = (AWTGraphicsConfiguration)gcInf0.getPrivateData();
c        return awtConfig.getAWTGraphicsConfiguration();
    }

Line a returns a GraphicsConfigInfo with a null privateData field, so line b makes awtConfig null and then the following line is a NPE

That is as far as I followed it

Any suggestion to make it work would be appreciated
---
Juan