Reflection Issue update ... ?

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

Reflection Issue update ... ?

snowcrash
Hello all I'm new here.

I have come across the following issue:

WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by com.jogamp.common.os.NativeLibrary$3 (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

When I searched Oracle's site I found:

When present at run time, --illegal-access= takes a keyword parameter to specify a mode of operation:

Note: Illegal-access operations to internal APIs from code on the class path are allowed by default in JDK 9.

permit: This mode opens packages in JDK 9 that existed in JDK 8 to code on the class path. This allows code on class path that relies on the use of setAccessible to break into JDK internals, or to do other illegal access on members of classes in these packages, to work as per previous releases. This enables both static access (such as, by compiled bytecode) and deep reflective access. Deep reflective access is accomplished through the platform's reflection APIs. The first reflective-access operation to any such package causes a warning to be issued. However, no warnings are issued after the first occurrence. This single warning describes how to enable further warnings. This mode is the default for JDK 9 but will change in a future release.

warn: This mode is identical to permit except that a warning message is issued for each illegal reflective-access operation.

debug: This mode is identical to warn except that both a warning message and a stack trace are issued for each illegal reflective-access operation.

deny: This mode disables all illegal-access operations except for those enabled by other command-line options, such as--add-opens. This mode will become the default in a future release.

The default mode, --illegal-access=permit, is intended to make you aware of code on the class path that reflectively accesses any JDK-internal APIs at least once. To learn about all such accesses, you can use the warn or the debug modes. For each library or framework on the class path that requires illegal access, you have two options:

If the component's maintainers have already released a fixed version that no longer uses JDK-internal APIs then you can consider upgrading to that version.

If the component still needs to be fixed, then you can contact its maintainers and ask them to replace their use of JDK-internal APIs with the proper exported APIs.

If you must continue to use a component that requires illegal access, then you can eliminate the warning messages by using one or more --add-opens options to open only those internal packages to which access is required.

To verify that your application is ready for a future version of the JDK, run it with --illegal-access=deny along with any necessary --add-opens options. Any remaining illegal-access errors will most likely be due to static references from compiled code to JDK-internal APIs. You can identify those by running the jdeps tool with the --jdk-internals option. For performance reasons, JDK 9 does not issue warnings for illegal static-access operations.

Using "warn" as specified above gave:

WARNING: Illegal reflective access by com.jogamp.common.os.NativeLibrary$3 (gluegen-rt.jar) to method java.lang.ClassLoader.findLibrary(java.lang.String)

WARNING: Illegal reflective access by jogamp.opengl.awt.Java2D$2 (jogl-all.jar) to field sun.java2d.opengl.OGLUtilities.UNDEFINED
WARNING: Illegal reflective access by jogamp.opengl.awt.Java2D$2 (jogl-all.jar) to field sun.java2d.opengl.OGLUtilities.WINDOW
WARNING: Illegal reflective access by jogamp.opengl.awt.Java2D$2 (jogl-all.jar) to field sun.java2d.opengl.OGLUtilities.TEXTURE
WARNING: Illegal reflective access by jogamp.opengl.awt.Java2D$2 (jogl-all.jar) to field sun.java2d.opengl.OGLUtilities.FLIP_BACKBUFFER
WARNING: Illegal reflective access by jogamp.opengl.awt.Java2D$2 (jogl-all.jar) to field sun.java2d.opengl.OGLUtilities.FBOBJECT
WARNING: Illegal reflective access by jogamp.nativewindow.jawt.JAWTUtil$1 (jogl-all.jar) to method sun.awt.SunToolkit.awtLock()
WARNING: Illegal reflective access by jogamp.nativewindow.jawt.JAWTUtil$1 (jogl-all.jar) to method sun.awt.SunToolkit.awtUnlock()

Thoughts, feedback, updates on this issue would be most appreciated I've seen parts of the issue addressed but thought to add the parts above for more information for others who might come across the issue.

Thanx
Reply | Threaded
Open this post in threaded view
|

Re: Reflection Issue update ... ?

gouessej
Administrator
Hello

The problem with ClassLoader.findLibrary() has already been addressed, I already spoke about that here several times, this call is unnecessary now as the extension mechanism was removed from Java and is absent from the latest LTS version (Java 11).
Julien Gouesse | Personal blog | Website