Here are three files, all of which compile with javac:
import java.lang.annotation.ElementType;
import java.lang.annotation.Target;
@Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})
@interface MyTypeAnno {}
public class GjfFailure {
void m(int a @MyTypeAnno []) {}
}
import java.lang.annotation.ElementType;
import java.lang.annotation.Target;
@Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})
@interface MyTypeAnno {}
public class GjfSuccess {
void m(int @MyTypeAnno [] a) {}
}
import java.lang.annotation.ElementType;
import java.lang.annotation.Target;
@Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})
@interface MyTypeAnno {}
public class GjfSuccess2 {
void m(int a[]) {}
}
Running google-java-format (version 1.7) on the first file yields this stack trace:
GjfFailure.java:8:11: error: com.google.common.base.VerifyException
at com.google.common.base.Verify.verify(Verify.java:100)
at com.google.googlejavaformat.java.JavaInputAstVisitor.visitAnnotatedArrayType(JavaInputAstVisitor.java:580)
at com.google.googlejavaformat.java.JavaInputAstVisitor.visitAnnotatedType(JavaInputAstVisitor.java:1322)
at com.google.googlejavaformat.java.JavaInputAstVisitor.visitAnnotatedType(JavaInputAstVisitor.java:156)
at org.openjdk.tools.javac.tree.JCTree$JCAnnotatedType.accept(JCTree.java:2637)
at org.openjdk.source.util.TreePathScanner.scan(TreePathScanner.java:82)
at com.google.googlejavaformat.java.JavaInputAstVisitor.scan(JavaInputAstVisitor.java:328)
at com.google.googlejavaformat.java.JavaInputAstVisitor.declareOne(JavaInputAstVisitor.java:3253)
at com.google.googlejavaformat.java.JavaInputAstVisitor.visitToDeclare(JavaInputAstVisitor.java:2536)
at com.google.googlejavaformat.java.JavaInputAstVisitor.visitFormals(JavaInputAstVisitor.java:2361)
at com.google.googlejavaformat.java.JavaInputAstVisitor.visitMethod(JavaInputAstVisitor.java:1419)
at com.google.googlejavaformat.java.JavaInputAstVisitor.visitMethod(JavaInputAstVisitor.java:156)
at org.openjdk.tools.javac.tree.JCTree$JCMethodDecl.accept(JCTree.java:898)
at org.openjdk.source.util.TreePathScanner.scan(TreePathScanner.java:82)
at com.google.googlejavaformat.java.JavaInputAstVisitor.scan(JavaInputAstVisitor.java:328)
at com.google.googlejavaformat.java.JavaInputAstVisitor.addBodyDeclarations(JavaInputAstVisitor.java:3464)
at com.google.googlejavaformat.java.JavaInputAstVisitor.visitClassDeclaration(JavaInputAstVisitor.java:1962)
at com.google.googlejavaformat.java.JavaInputAstVisitor.visitClass(JavaInputAstVisitor.java:400)
at com.google.googlejavaformat.java.JavaInputAstVisitor.visitClass(JavaInputAstVisitor.java:156)
at org.openjdk.tools.javac.tree.JCTree$JCClassDecl.accept(JCTree.java:808)
at org.openjdk.source.util.TreePathScanner.scan(TreePathScanner.java:82)
at com.google.googlejavaformat.java.JavaInputAstVisitor.scan(JavaInputAstVisitor.java:328)
at com.google.googlejavaformat.java.JavaInputAstVisitor.visitCompilationUnit(JavaInputAstVisitor.java:372)
at com.google.googlejavaformat.java.JavaInputAstVisitor.visitCompilationUnit(JavaInputAstVisitor.java:156)
at org.openjdk.tools.javac.tree.JCTree$JCCompilationUnit.accept(JCTree.java:591)
at org.openjdk.source.util.TreePathScanner.scan(TreePathScanner.java:82)
at com.google.googlejavaformat.java.JavaInputAstVisitor.scan(JavaInputAstVisitor.java:328)
at com.google.googlejavaformat.java.Formatter.format(Formatter.java:155)
at com.google.googlejavaformat.java.Formatter.getFormatReplacements(Formatter.java:258)
at com.google.googlejavaformat.java.Formatter.formatSource(Formatter.java:234)
at com.google.googlejavaformat.java.FormatFileCallable.call(FormatFileCallable.java:45)
at com.google.googlejavaformat.java.FormatFileCallable.call(FormatFileCallable.java:26)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
The code is in bad style as it uses a deprecated placement of array brackets in a variable declaration. However, it's legal code and google-java-format probably shouldn't crash.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4