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

Support Java 14 language features (and decouple from javac-shaded) #347

Closed
iamdanfox opened this issue Sep 9, 2020 · 0 comments · Fixed by #365
Closed

Support Java 14 language features (and decouple from javac-shaded) #347

iamdanfox opened this issue Sep 9, 2020 · 0 comments · Fixed by #365

Comments

@iamdanfox
Copy link
Contributor

iamdanfox commented Sep 9, 2020

What happened?

Things like records, switch expressions, a new instanceof syntax and multiline strings are available in newer java compilers.

Support for these features landed in upstream google-java-format in various commits, including google/google-java-format@4ddb914.

Seems like they did this by making a new Java14InputAstVisitor which extends the normal JavaInputAstVisitor and then reflectively deciding whether or not to construct it depending on what java compiler version is on the classpath, as this affects whether org.openjdk.source.util.TreePathScanner has the extra visit methods or not:

  • visitBindingPattern
  • visitYield
  • visitSwitchExpression
  • visitInstanceOf

What did you want to happen?

I think we currently bundle com.google.errorprone:javac-shaded:9+181-r4173-1 in p-j-f, which means we're going to be a bit stuck on this front. Google switched away from this in google/google-java-format#447, and I think we need to do the same in order to be able to keep picking up new language features.

This will likely also require some tweaks to how p-j-f is used from the intellij plugin etc, as we'll need to ensure the relevant java modules (com.sun.tools.javac.{file,main,parser,tree,util,code,api}) are exposed using something like the --add-exports flag.

cc @fawind

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

Successfully merging a pull request may close this issue.

1 participant