Skip to content
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

Illegal reflective access on Java 9+ #46

Open
marinier opened this issue Apr 30, 2020 · 2 comments
Open

Illegal reflective access on Java 9+ #46

marinier opened this issue Apr 30, 2020 · 2 comments

Comments

@marinier
Copy link

When I run my unit tests, I get this warning:

WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.spf4j.log.SLF4JBridgeHandler$3 (file:/C:/Users/bob.marinier/.m2/repository/org/spf4j/spf4j-slf4j-test/8.8.1/spf4j-slf4j-test-8.8.1.jar) to field java.util.logging.LogRecord.needToInferCaller
WARNING: Please consider reporting this to the maintainers of org.spf4j.log.SLF4JBridgeHandler$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

This is a Java 9+ issue. The answer to this question has more info: https://stackoverflow.com/questions/50251798/what-is-an-illegal-reflective-access

I can think of a few ways to potentially address this:

  • Avoid performing these reflective accesses. This may not be possible.
  • Release a Java 11 version (Java 9 and 10 are already EOL) of this project. Probably all you need to do is add a module-info.java file with the appropriate content.
  • Update the README to include instructions for working around this problem. In particular, the following JVM args need to be added:
--add-opens=java.logging/java.util.logging=ALL-UNNAMED
--add-opens=java.base/java.lang=ALL-UNNAMED

(The first line addresses the specific warning above. The second line addresses another warning that comes up when the first one is addressed. Note, the previous suggestion would have this information in the module-info.java file, and thus end users wouldn't have to do this themselves.)

@zolyfarkas
Copy link
Owner

thank you for reporting this.

This is caused by a workaround for accessing caller class+method without inference which is costly when transforming java.util.LogRecord to a slf4j log record...

There are some JDK issues related to this:
https://bugs.java.com/bugdatabase/view_bug.do?bug_id=4515935
I also filed a JDK request for enhancement: 9064834

For now I will add your suggestions to the documentation.
Will keep this issue open until I start using JDK 11 for building spf4j and be able to leverage the module system, etc...

@zolyfarkas
Copy link
Owner

TODO: review:
org.spf4j.base.Throwables
org.spf4j.base.Reflections

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants