JOGL Java 10 modularization

classic Classic list List threaded Threaded
12 messages Options
Reply | Threaded
Open this post in threaded view
|

JOGL Java 10 modularization

kaisevoj
Hello,

I have been trying to get out project base working on Java 10 with jigsaw modules, but JOGL keeps failing on me, and I cannot find any help online.

Note whole project compiles and works fine with no module-info.java file, and I managed to get working module link between two different projects (not EVERYTHING is broken).

JOGL project (A) has following module-info.java and maven dependencies. Then there is another project (B) using JOGL project, but having no access to any JOGL types (they are not exported anyway). Project B runs stuff from project A. Project B is not modular (yet).

Module info file:

    module com.foo.bar {
             ...
             requires jogl.all.main;
             requires gluegen.rt.main;
    }

Maven dependencies:

    <dependency>
        <groupId>org.jogamp.gluegen</groupId>
        <artifactId>gluegen-rt-main</artifactId>
        <version>2.3.2</version>
    </dependency>
    <dependency>
        <groupId>org.jogamp.jogl</groupId>
        <artifactId>jogl-all-main</artifactId>
        <version>2.3.2</version>
    </dependency>

Eclipse reports on any jogl import:

    import com.jogamp.opengl.GL4;
    -> The import com.jogamp.opengl cannot be resolved

What is strange, maven happily builds the project A/B with no errors, and when I run the project B from command line as jar, everything works with no additional runtime errors.

This leads me to believe maven build is fine with the transition (does it even know about modules?), and only one confused here is eclipse.

Eclipse Libraries in Java Build Path:



Using:
Eclipse Photon 4.8.0 (20180619-1200),
Maven 3.5.3 (3.7.0 compiler plugin),
Java JDK-10.0.1

Regards,
Vojtěch
Reply | Threaded
Open this post in threaded view
|

Re: JOGL Java 10 modularization

gouessej
Administrator
Hey

Have you tried to use your project in command line outside of Eclipse? Actually, as long as your module containing JOGL contains GlueGen too, it should work.
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
|

Re: JOGL Java 10 modularization

kaisevoj
Well maven compiles the project just fine (bot compile and execution run with no errors as expected), and afaik it uses java compiler directly, no eclipse involved. There must be some secret setting in eclipse project.

Current version of jogl is not modular? At least eclipse claims it is not (not that it should be a problem).

It seems from all jogamp tutorials that you are using eclipse as well, do you have a minimum working example of jogl app as complete workspace perchance? I could at least try to load that and in case it works as-is on my machine, I can work my way down through all differences it nothing else.

Will try to make something of the sort tomorrow, see if I can replicate the problem on something I can share here.
Reply | Threaded
Open this post in threaded view
|

Re: JOGL Java 10 modularization

gouessej
Administrator
Yes, the current version isn't modular.

Some of us use multiple IDEs, I use mainly Eclipse and Netbeans but my GNU Linux distribution provides only OpenJDK 1.8. You can try my own projects, T.U.E.R uses Ant and JogAmp's Ardor3D Continuation uses Maven, both work fine in Eclipse but note that I have never tested them with a very recent version of Eclipse.
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
|

Re: JOGL Java 10 modularization

kaisevoj
Hi,

I played a bit with the project, and found out no errors are produced if I use

<dependency>
        <groupId>org.jogamp.gluegen</groupId>
        <artifactId>gluegen-rt</artifactId>
        <version>2.3.2</version>
</dependency>
<dependency>
        <groupId>org.jogamp.jogl</groupId>
        <artifactId>jogl-all</artifactId>
        <version>2.3.2</version>
</dependency>

instead of main alternatives (supplying natives through deprecated dll's) with module-info

module com.test {
        requires gluegen.rt;
        requires jogl.all;
        requires java.desktop;
        exports com.test;
}

but I arrived at a runtime error

Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: -1
        at jogl.all@2.3.2/jogamp.opengl.windows.wgl.awt.WindowsAWTWGLGraphicsConfigurationFactory.chooseGraphicsConfigurationImpl(WindowsAWTWGLGraphicsConfigurationFactory.java:171)
        at jogl.all@2.3.2/com.jogamp.nativewindow.GraphicsConfigurationFactory.chooseGraphicsConfiguration(GraphicsConfigurationFactory.java:424)
        at jogl.all@2.3.2/com.jogamp.opengl.awt.GLCanvas.chooseGraphicsConfiguration(GLCanvas.java:1560)
        at jogl.all@2.3.2/com.jogamp.opengl.awt.GLCanvas.addNotify(GLCanvas.java:611)
        at java.desktop/java.awt.Container.addNotify(Container.java:2798)
        at java.desktop/java.awt.Window.addNotify(Window.java:786)
        at java.desktop/java.awt.Frame.addNotify(Frame.java:490)
        at java.desktop/java.awt.Window.show(Window.java:1048)
        at java.desktop/java.awt.Component.show(Component.java:1674)
        at java.desktop/java.awt.Component.setVisible(Component.java:1621)
        at java.desktop/java.awt.Window.setVisible(Window.java:1031)
        at com.test/com.test.Main.main(Main.java:47)

Was not able to google much about it (except it is know by some to be java 9 related JOGL issue, advising not to use java 9 - helpful).

I created repo (https://github.com/kaisevoj/jogl-test) with minimal sample code that produces exception above with module-info.java present, but runs fine without it - that makes me believe this is bound to be issue connected to modularization.

Best regards,
Vojtěch
Reply | Threaded
Open this post in threaded view
|

Re: JOGL Java 10 modularization

gouessej
Administrator
You have to add some exports to make JOGL work with Java >= 1.9, I indicated which ones on this forum and in the bug tracker but the latter is still not working :s

Don't expect a search engine to be very helpful for such problems.
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
|

Re: JOGL Java 10 modularization

kaisevoj
Hi,

I scoured the thread http://forum.jogamp.org/Jogl-Jogamp-on-Java-9-td4038012i60.html and I assume you mean 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

Adding them as VM arguments did not help. I did not manage to find any further conclusions to that thread, possibly missed something (many of the links point to bug tracker).

Best regards,
Vojtěch
Reply | Threaded
Open this post in threaded view
|

Re: JOGL Java 10 modularization

gouessej
Administrator
I tested my solution in command line under Windows 10 several months ago with Java 1.9 under Windows and it worked flawlessly, I succeeded in running a simple example showing a rotating triangle drawn in a GLCanvas. How do you pass the exports?

P.S: Put the exports into the right module info file.
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
|

Re: JOGL Java 10 modularization

kaisevoj
As eclipse configuration VM argument



updated on github repository.
Reply | Threaded
Open this post in threaded view
|

Re: JOGL Java 10 modularization

kaisevoj
When I run it from console

java -Djogamp.gluegen.UseTempJarCache=false -Djava.library.path="jogl-test/natives/windows-amd64/" -jar jogl-test/target/test-0.0.1-SNAPSHOT-jar-with-dependencies.jar

it works. Eclipse isn't really giving me a lot of options.
Reply | Threaded
Open this post in threaded view
|

Re: JOGL Java 10 modularization

gouessej
Administrator
Personally, I would try to use a more simple third party library just to confirm that the problem comes from Eclipse Photon. Why not trying to make a very simple test with Vecmath?
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
|

Re: JOGL Java 10 modularization

kaisevoj
I managed to get working case of two modularized projects where one is dependency of the other, while both have third party dependencies (modular and non-modular).

Eclipse was able to generate working module-info.java files for existing projects (add export for all packages, add requires for all necessary modules).