Closed
Description
Consider the following minimal example:
public class MinimalExample {
public void thisIsNotFormattedCorrectly(Object something){
if(something instanceof String somethingAsString){
return;
}
//doSomethingElse
}
}
When formatting this with the 1.9 jar: java -jar google-java-format-1.9-all-deps.jar PATH/MinimalExample.java
the class is formatted correctly.
When formatting it with the 1.10 jar: java -jar google-java-format-1.10.0-all-deps.jar PATH/MinimalExample.java
I get the following error:
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by com.google.googlejavaformat.java.JavacTokens$CommentSavingTokenizer (file:/[PATH]/git/google-java-format-1.10.0-all-deps.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
[PATH]/MinimalExample.java:3:30: error: java.lang.LinkageError: com.sun.source.tree.BindingPatternTree.getName()
at com.google.googlejavaformat.java.java14.Java14InputAstVisitor.visitBindingPattern(Java14InputAstVisitor.java:67)
at com.google.googlejavaformat.java.java14.Java14InputAstVisitor.visitBindingPattern(Java14InputAstVisitor.java:47)
at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCBindingPattern.accept(JCTree.java:2231)
at jdk.compiler/com.sun.source.util.TreePathScanner.scan(TreePathScanner.java:82)
at com.google.googlejavaformat.java.JavaInputAstVisitor.scan(JavaInputAstVisitor.java:329)
at com.google.googlejavaformat.java.java14.Java14InputAstVisitor.visitInstanceOf(Java14InputAstVisitor.java:207)
at com.google.googlejavaformat.java.java14.Java14InputAstVisitor.visitInstanceOf(Java14InputAstVisitor.java:47)
at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCInstanceOf.accept(JCTree.java:2178)
at jdk.compiler/com.sun.source.util.TreePathScanner.scan(TreePathScanner.java:82)
at com.google.googlejavaformat.java.JavaInputAstVisitor.scan(JavaInputAstVisitor.java:329)
at com.google.googlejavaformat.java.JavaInputAstVisitor.visitIf(JavaInputAstVisitor.java:1081)
at com.google.googlejavaformat.java.JavaInputAstVisitor.visitIf(JavaInputAstVisitor.java:157)
at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCIf.accept(JCTree.java:1513)
at jdk.compiler/com.sun.source.util.TreePathScanner.scan(TreePathScanner.java:82)
at com.google.googlejavaformat.java.JavaInputAstVisitor.scan(JavaInputAstVisitor.java:329)
at com.google.googlejavaformat.java.JavaInputAstVisitor.visitStatements(JavaInputAstVisitor.java:2181)
at com.google.googlejavaformat.java.JavaInputAstVisitor.methodBody(JavaInputAstVisitor.java:1495)
at com.google.googlejavaformat.java.JavaInputAstVisitor.visitMethod(JavaInputAstVisitor.java:1482)
at com.google.googlejavaformat.java.JavaInputAstVisitor.visitMethod(JavaInputAstVisitor.java:157)
at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCMethodDecl.accept(JCTree.java:925)
at jdk.compiler/com.sun.source.util.TreePathScanner.scan(TreePathScanner.java:82)
at com.google.googlejavaformat.java.JavaInputAstVisitor.scan(JavaInputAstVisitor.java:329)
at com.google.googlejavaformat.java.JavaInputAstVisitor.addBodyDeclarations(JavaInputAstVisitor.java:3531)
at com.google.googlejavaformat.java.JavaInputAstVisitor.visitClassDeclaration(JavaInputAstVisitor.java:2004)
at com.google.googlejavaformat.java.java14.Java14InputAstVisitor.visitClass(Java14InputAstVisitor.java:104)
at com.google.googlejavaformat.java.java14.Java14InputAstVisitor.visitClass(Java14InputAstVisitor.java:47)
at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCClassDecl.accept(JCTree.java:832)
at jdk.compiler/com.sun.source.util.TreePathScanner.scan(TreePathScanner.java:82)
at com.google.googlejavaformat.java.JavaInputAstVisitor.scan(JavaInputAstVisitor.java:329)
at com.google.googlejavaformat.java.JavaInputAstVisitor.visitCompilationUnit(JavaInputAstVisitor.java:374)
at com.google.googlejavaformat.java.JavaInputAstVisitor.visitCompilationUnit(JavaInputAstVisitor.java:157)
at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCCompilationUnit.accept(JCTree.java:603)
at jdk.compiler/com.sun.source.util.TreePathScanner.scan(TreePathScanner.java:82)
at com.google.googlejavaformat.java.JavaInputAstVisitor.scan(JavaInputAstVisitor.java:329)
at com.google.googlejavaformat.java.Formatter.format(Formatter.java:170)
at com.google.googlejavaformat.java.Formatter.getFormatReplacements(Formatter.java:291)
at com.google.googlejavaformat.java.Formatter.formatSource(Formatter.java:267)
at com.google.googlejavaformat.java.FormatFileCallable.call(FormatFileCallable.java:45)
at com.google.googlejavaformat.java.FormatFileCallable.call(FormatFileCallable.java:26)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1130)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:630)
at java.base/java.lang.Thread.run(Thread.java:832)
Caused by: java.lang.NoSuchMethodException: com.sun.source.tree.BindingPatternTree.getName()
at java.base/java.lang.Class.getMethod(Class.java:2201)
at com.google.googlejavaformat.java.java14.Java14InputAstVisitor.visitBindingPattern(Java14InputAstVisitor.java:63)
... 42 more
Suppressed: java.lang.NoSuchMethodException: com.sun.source.tree.BindingPatternTree.getVariable()
at java.base/java.lang.Class.getMethod(Class.java:2201)
at com.google.googlejavaformat.java.java14.Java14InputAstVisitor.visitBindingPattern(Java14InputAstVisitor.java:58)
... 42 more
Metadata
Metadata
Assignees
Labels
No labels