NASAWorldWind / WorldWindJava

The NASA WorldWind Java SDK (WWJ) is for building cross-platform 3D geospatial desktop applications in Java.
724 stars 327 forks source link

Running with Java 9 Causes Warning #147

Closed scottdewald closed 5 years ago

scottdewald commented 6 years ago

My application is built using WorldWind v2.1.0 on Windows 10. When previously running using Java 8, the application ran with no warnings. I updated to Java 9.0.1 and I get the following warning messages from the underlying components being used by WorldWind:

WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by com.jogamp.common.os.NativeLibrary$3 (file:/C:/Users/scott/Dev/lib/worldwind-v2.1.0/gluegen-rt.jar) to method java.lang.ClassLoader.findLibrary(java.lang.String)
WARNING: Please consider reporting this to the maintainers of com.jogamp.common.os.NativeLibrary$3
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release

I can get rid of these warnings by disabling reflective access via the command line argument: --illegal-access=deny. Things appear to run correctly when I use this arg, but I am not sure if this is a good approach. I may just not have encountered the feature yet which I am disabling.

Questions: 1) Will disabling reflective access for com.jogamp.common.os.NativeLibrary cause any known problems? 2) Is there a plan to update WorldWind and associated libraries for Java 9?

Thanks

kotogadekiru commented 6 years ago

I ran into a similar problem while upgrading to java 10. It would be interesting to get some insigth into what would be the best way to handle this problems. Thanks.

rmoffatt commented 6 years ago

I too am curious as I've also switched to java 10.

The error is printed somewhere from the constructor of javax.media.opengl.awt.GLJPanel. It can be replicated by creating a new gov.nasa.worldwind.awt.WorldWindowGLJPanel.

Further insight into this is greatly appreciated.

sbwong commented 6 years ago

Has anyone tried running WWJ with a Java 9+ project that uses modules? Without modules, I get the same warning detailed above but the maps do at least come up and WWJ appears functional. But as soon as the main project is put into a module, i.e. a module-info.java file is created for the project, WWJ throws a fatal "Index out of bounds" exception when a map canvas is added to its parent Container.

Note that this exception could be masked by other exceptions if other operations are being done as well, for instance, adding the map controls layer -- WWJ can't seem to find the image files for the arrows -- which might actually be a clue as to what is going on but I haven't figured out exactly how yet.

From what I've seen in my wanderings, JOGL incompatibility with Java 9+ is a likely suspect. Note that the above exception is actually occurring in the JOGL codebase, not the WWJ codebase. "javax.media.opengl.awt" is actually a JOGL package, not a Java AWT package -- this package was renamed to the more appropriate "com.jogamp.opengl.awt" in the latest JOGL (v2.3.2 from 2016!). WWJ 2.1.0 uses an earlier version of JOGL. (v1.7?)

ipkpjersi commented 5 years ago

Sounds like my experiences with Java 9+ module projects. I upgrade my Java projects to use 9+ modules with module-info.java and then all kinds of dependencies randomly throw weird runtime exceptions because, surprise surprise, they aren't written to take advantage of Java 9+'s modular features. It's likely gonna take years for this problem to work itself out at this rate.

Seems like with these reflective access warnings (that will eventually be full errors) the dependency either needs to re-write the code in question so it is no longer using that reflective access, or you need to upgrade your entire project to a Java 9+ module project and hope that all the dependencies you are using are upgraded to take advantage of Java 9+'s modular features.

In general, some older dependencies like for example gluegen-rt haven't been updated in years and likely never will be so Java 12/13/etc compatibility is likely not happening, possibly ever.

markpet49 commented 5 years ago

Activity on JOGL has resumed recently. The develop branch of the WorldWind project has been updated to use the unreleased version of JOGL 2.4 which gets rid the warnings and crashes with Java 11+.