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

Allow to provide source file java language version #975

Open
laurentgo opened this issue Sep 29, 2023 · 0 comments
Open

Allow to provide source file java language version #975

laurentgo opened this issue Sep 29, 2023 · 0 comments

Comments

@laurentgo
Copy link

When formatting files with google-java-format, the parser uses the same source version as its own runtime version (running google-java-format on JDK X implies that that Java source files are conformant with JDK X), but this is actually not necessary true and files may be aiming for a different (older) Java version. Nowadays it is a common pattern to use --release flag to compiler for a specific older version of the language using a newer JDK.

Unfortunately Java language is not fully backward compatible and some features have introduced breaking changes like reserved identifiers var, with, yieldorrecord` (see current list in JLS Section 3.8)

For files who were designed to compile with an older Java version and who are using now reserved identifiers, this cause their processing with google-java-format using a recent JDK version to fail.

A solution would be to allow to pass either the source or the release option to the java parser to adapt its own parsing to the java version used by the file.

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

1 participant