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" warning #622

Closed
mschechter-bellese opened this issue Jun 29, 2021 · 3 comments
Closed

"Illegal reflective access" warning #622

mschechter-bellese opened this issue Jun 29, 2021 · 3 comments

Comments

@mschechter-bellese
Copy link

Using the latest release (1.10.0) via fmt-maven-plugin, I get the following warning when formatting my code.

09:24:58.285 [INFO] --- fmt-maven-plugin:2.11:format (default) @ xxxxx ---
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by com.google.googlejavaformat.java.JavacTokens$CommentSavingTokenizer (file:/Users/xxxx/.m2/repository/com/google/googlejavaformat/google-java-format/1.10.0/google-java-format-1.10.0.jar) to field com.sun.tools.javac.parser.JavaTokenizer.reader
WARNING: Please consider reporting this to the maintainers of com.google.googlejavaformat.java.JavacTokens$CommentSavingTokenizer
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

While the error is not fatal, it is something that inexperienced developers will need to be educated about. It is also generally accepted that warnings/errors should be addressed instead of ignored, as this can make it more difficult to identify actual issues when reviewing logs/output.

Similar issues have been seen in Jackson Afterburner (replaced by Jackson Blackbird, as the issue could not be addressed without major re-write).

@cushon
Copy link
Collaborator

cushon commented Jun 29, 2021

Adding the --add-exports= flags documented in https://github.com/google/google-java-format#jdk-16 should resolve those warnings. They're required for JDK 16 and newer which makes those diagnostics errors, but the same flags will suppress the warnings in earlier JDK versions.

@mschechter-bellese
Copy link
Author

This definitely works; it's a bit odd having to add this in for a Maven plugin, though 😀

Thanks!

@cushon cushon closed this as completed Jul 23, 2021
@youngm
Copy link

youngm commented Dec 29, 2021

I don't know java modules that well. But, has everyone accepted the fact that this is just the way it's going to have to be when using the google-java-formatter for the foreseeable future?

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

3 participants