New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JavaLibCHelper emits illegal reflective access warnings on Java 9 #108

Closed
eregon opened this Issue Oct 4, 2017 · 1 comment

Comments

Projects
None yet
2 participants
@eregon
Contributor

eregon commented Oct 4, 2017

JavaLibCHelper emits warnings on Java 9:

WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by jnr.posix.JavaLibCHelper (file:...jar) to method sun.nio.ch.SelChImpl.getFD()
WARNING: Please consider reporting this to the maintainers of jnr.posix.JavaLibCHelper
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
$ java --illegal-access=warn ...  
WARNING: Illegal reflective access by jnr.posix.JavaLibCHelper (file:/home/eregon/code/java9-ws/truffleruby/mxbuild/dists/truffleruby.jar) to method sun.nio.ch.SelChImpl.getFD()
WARNING: Illegal reflective access by jnr.posix.JavaLibCHelper (file:/home/eregon/code/java9-ws/truffleruby/mxbuild/dists/truffleruby.jar) to field sun.nio.ch.FileChannelImpl.fd
WARNING: Illegal reflective access by jnr.posix.JavaLibCHelper (file:/home/eregon/code/java9-ws/truffleruby/mxbuild/dists/truffleruby.jar) to field java.io.FileDescriptor.fd

The first two are only used by getDescriptorFromChannel() which is only used in tests.
Maybe we can just make that a private helper for tests? But not sure if somebody actually uses this helper.

The last one (FileDescriptor.fd) is used in tests but also for fstat() and other libc functions taking a FileDescriptor.

What would be a good option to fix these warnings?
I am thinking maybe just check for Java 9 and in such a case just set them to null as if there was a SecurityException.
Or maybe move those in a separate class so they only load on first usage.
In the case of TruffleRuby, we have fds as int so these methods taking FileDescriptor instances are never used I believe.

cc @headius @chrisseaton

eregon added a commit to eregon/jnr-posix that referenced this issue Oct 4, 2017

Use reflection to get native file descriptors on first access
* As it creates warnings on Java 9.
* Fixes jnr#108.

eregon added a commit to eregon/jnr-posix that referenced this issue Oct 4, 2017

@headius headius closed this in #109 Oct 10, 2017

@headius headius added this to the 3.0.42 milestone Oct 10, 2017

@headius

This comment has been minimized.

Member

headius commented Oct 10, 2017

Released in 3.0.42.

alexis779 added a commit to alexis779/jnr-posix that referenced this issue Jan 17, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment