JOGL Java 10 modularization

classic Classic list List threaded Threaded
19 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).
Reply | Threaded
Open this post in threaded view
|

Re: JOGL Java 10 modularization

swong
Can you be more explicit as to exactly what you had to set in the project settings, module-info.java, run configurations, etc. to get a JOGL app to work in Java 10 with a modular Eclipse project?    

I have been pulling my hair out for days trying to get around the same "index out of bounds" error.  

To note, I even tried running the JOGL demos ( https://jogamp.org/deployment/jogamp-current/jogl-test-applets.html ) but when I run the JNLP launch for the "JOGL Version Information" demo, I get:

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(Unknown Source)


Note:  I had to add ttp://jogamp.org to the "Exception Site List" in the Java console for the JNLP launch to run at all.   the JNLP launch file indicates that JOGL ver.2.3.2 is being used.)

For the record, my system details:
Win10 personally but Mac and Linux must also be supported with the same codebase)
Java 10.0.2
Eclipse Photon

My particular application is trying to get the NASA WorldWind Java (WWJ) code to run under a Java 10 project that has a module-info.java defined.    The WWJ runs with a non-modular project but not with a modular project where I get the "index out of bounds" exception right when the JOGL-based component is added to its parent component (i.e. same as above).

Please help -- The code is part of my students' final project which has run no problem for years until we switched from Java 8 to Java 10.  I need to get this code operational in the next few days and it cannot be delayed as I am already late in getting this to the students.


Any advice and/or suggestions would be greatly appreciated as I have no idea what to try next.  

Thank you all in advance!



Reply | Threaded
Open this post in threaded view
|

Re: JOGL Java 10 modularization

gouessej
Administrator
Hello

Java Web Start isn't included in Java >= 1.11:
https://www.oracle.com/technetwork/java/eol-135779.html
The Web Deployment Technology bundled with the JRE, consisting of the Java Plugin and Java Web Start has a shorter support lifecycle: only five years of Premier Support. The deployment stack was marked as deprecated and flagged for removal in Java SE 9 and Java SE 10. Oracle Java SE 11 and later versions will not include the Deployment Stack.
If I were you, I would make it work without Eclipse as a first step. If you try to solve all problems at the same time, you'll fail. Then, why not using Ant or Maven to build without Eclipse? After that, you could still use one of those tools inside Eclipse Photon.

Have you tried to use "java --add-exports java.base/java.lang=ALL-UNNAMED --add-exports java.desktop/sun.awt=ALL-UNNAMED --add-exports java.desktop/sun.java2d=ALL-UNNAMED" and
module your_module_name {
    requires java.base;
    requires java.desktop;
}
?

Note that you can put "Add-Exports: java.base/java.lang java.desktop/sun.awt java.desktop/sun.java2d" into your manifest file.
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
|

Re: JOGL Java 10 modularization

swong
I'm not trying to write a JNLP launched app, I only tried to run the demo on the JOGL site -- my point is that code straight from the JOGL site doesn't run on Java 10.    I was trying to eliminate myself as factor in whether or not JOGL can run on Java 10.

I did try the add-exports options but they made no difference.   I got the exact same error message as mentioned above.







Reply | Threaded
Open this post in threaded view
|

Re: JOGL Java 10 modularization

swong
I got the above posted jogl-test code to bring up a blank (black) JOGL canvas on a frame... sort of.   I noticed that it would not run for me when using the provided launch configuration to run the code directly.   The code only ran after it was assembled into its JAR files and the only JAR file that would run was the one that included the dependencies.

The curious thing about the JAR files is that they don't utilize the JAR'd versions of JOGL, i.e. the jogl-all.jar, gluegen-rt.jar and the natives JARs.    Instead, Maven creates an executable JAR (the one with the dependencies) where all the required code is included as un-JAR'd packages.  


Here's a theory to chew on -- I may be way off base but this seems to fit my observations:

One of the reasons that JOGL 2.3.2 doesn't run in a modular project is due to Java treating the multiple JARs in the JOGL system as independent automatic modules and thus does not allow free access of the code in one JAR to the code in another JAR.    I think this may be a particular problem in accessing the native code.

Thus, by putting the entire JOGL system inside of a single JAR file, these access problems go away because module boundaries are not being crossed anymore.  

Possible solutions:
A.  Put the entire JOGL system in a single JAR file.   This could make the JOGL distribution too large for some applications however.   This is the route I am currently pursuing but not successfully yet due to changes in package names and available methods between v.2.3.2 and earlier versions.
Or
B. Make all the JARs in the JOGL system into named modules with internal module-info.java files.   The "requires" and "exports" declarations would have to be figured out for each JAR/module.   This would take a lot of work to accomplish but could greatly reduce the overall JOGL system size for some applications and would not have to rely on the vagaries of automatic modules.   This is arguably the better long-term solution.

Thoughts on this theory, anyone?
 
BTW, does anyone know what the proper replacements for these methods that have disappeared in JOGL 2.3.2?

GLU.destroy()
GLDrawable.getHeight()
GLDrawable.getWidth()

Thank you to all for your help and feedback!
Reply | Threaded
Open this post in threaded view
|

Re: JOGL Java 10 modularization

gouessej
Administrator
Then, why not using jogamp-fat.jar?

Rather use getSurfaceWidth and getSurfaceHeight.
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
|

Re: JOGL Java 10 modularization

swong
I saw some oblique references to joglamp-fat.jar but could neither figure out what it was nor where to get it.

the getWidth/Height -> getSurfaceWidth/Height substitution makes sense.  

I couldn't find the replacement for destroy() however and I've got some legacy code (WorldWind Java 2.1.0) that makes that call.

Thanks for your help, it is *greatly* appreciated!
Reply | Threaded
Open this post in threaded view
|

Re: JOGL Java 10 modularization

gouessej
Administrator
jogamp-fat.jar is here:
http://jogamp.org/deployment/jogamp-current/archive/jogamp-fat-all.7z

GLU.destroy() no longer exists in JOGL >= 2.3.2. In my humble opinion, you should rebuild WorldWind with JOGL 2.3.2 if there is no version supporting it yet.
Julien Gouesse | Personal blog | Website