Skip to content

Illegal reflective access on Java 9+ #46

Description

@marinier

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.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions