Original issue created by steven.m.reed on 2013-08-13 at 07:43 PM
What steps will reproduce the problem?
Trigger the PreconditionsExpensiveString pattern by writing a valid line of code similar to:
Preconditions.checkState(foo.isEmpty(), String.format("Foo must be empty, is %s", foo));
compile (I was using maven, configured as per the wiki)
What is the expected output? What do you see instead?
I expect the errorprone compiler to warn me against this usage. However, the compiler itself throws a ClassCastException (included below).
What version of the product are you using? On what operating system?
Using 2.3-SNAPSHOT of plexus-compiler-javac and plexus-compiler-javac-errorprone, and 3.1 of maven-compiler-plugin.
Please provide any additional information below.
An exception has occurred in the compiler (1.7.0_25). Please file a bug at the Java Developer Connection (http://java.sun.com/webapps/bugreport) after checking the Bug Parade for duplicates. Include your program and the following diagnostic in your report. Thank you.
java.lang.ClassCastException: com.sun.tools.javac.tree.JCTree$JCIdent cannot be cast to com.sun.source.tree.MemberSelectTree
at com.google.errorprone.bugpatterns.PreconditionsExpensiveString.matchMethodInvocation(PreconditionsExpensiveString.java:83)
at com.google.errorprone.ErrorProneScanner.visitMethodInvocation(ErrorProneScanner.java:184)
at com.google.errorprone.ErrorProneScanner.visitMethodInvocation(ErrorProneScanner.java:33)
at com.sun.tools.javac.tree.JCTree$JCMethodInvocation.accept(JCTree.java:1333)
at com.sun.source.util.TreePathScanner.scan(TreePathScanner.java:67)
at com.google.errorprone.Scanner.scan(Scanner.java:111)
at com.google.errorprone.Scanner.scan(Scanner.java:44)
at com.sun.source.util.TreeScanner.visitExpressionStatement(TreeScanner.java:240)
at com.sun.tools.javac.tree.JCTree$JCExpressionStatement.accept(JCTree.java:1173)
at com.sun.source.util.TreePathScanner.scan(TreePathScanner.java:67)
at com.google.errorprone.Scanner.scan(Scanner.java:111)
at com.google.errorprone.Scanner.scan(Scanner.java:44)
at com.sun.source.util.TreeScanner.scanAndReduce(TreeScanner.java:80)
at com.sun.source.util.TreeScanner.scan(TreeScanner.java:90)
at com.sun.source.util.TreeScanner.visitBlock(TreeScanner.java:159)
at com.sun.tools.javac.tree.JCTree$JCBlock.accept(JCTree.java:790)
at com.sun.source.util.TreePathScanner.scan(TreePathScanner.java:67)
at com.google.errorprone.Scanner.scan(Scanner.java:111)
at com.google.errorprone.Scanner.scan(Scanner.java:44)
at com.sun.source.util.TreeScanner.scanAndReduce(TreeScanner.java:80)
at com.sun.source.util.TreeScanner.visitEnhancedForLoop(TreeScanner.java:185)
at com.sun.tools.javac.tree.JCTree$JCEnhancedForLoop.accept(JCTree.java:915)
at com.sun.source.util.TreePathScanner.scan(TreePathScanner.java:67)
at com.google.errorprone.Scanner.scan(Scanner.java:111)
at com.google.errorprone.Scanner.scan(Scanner.java:44)
at com.sun.source.util.TreeScanner.scan(TreeScanner.java:90)
at com.sun.source.util.TreeScanner.visitBlock(TreeScanner.java:159)
at com.sun.tools.javac.tree.JCTree$JCBlock.accept(JCTree.java:790)
at com.sun.source.util.TreePathScanner.scan(TreePathScanner.java:67)
at com.google.errorprone.Scanner.scan(Scanner.java:111)
at com.google.errorprone.Scanner.scan(Scanner.java:44)
at com.sun.source.util.TreeScanner.scanAndReduce(TreeScanner.java:80)
at com.sun.source.util.TreeScanner.visitMethod(TreeScanner.java:142)
at com.google.errorprone.ErrorProneScanner.visitMethod(ErrorProneScanner.java:258)
at com.google.errorprone.ErrorProneScanner.visitMethod(ErrorProneScanner.java:33)
at com.sun.tools.javac.tree.JCTree$JCMethodDecl.accept(JCTree.java:690)
at com.sun.source.util.TreePathScanner.scan(TreePathScanner.java:67)
at com.google.errorprone.Scanner.scan(Scanner.java:111)
at com.google.errorprone.Scanner.scan(Scanner.java:44)
at com.sun.source.util.TreeScanner.scanAndReduce(TreeScanner.java:80)
at com.sun.source.util.TreeScanner.scan(TreeScanner.java:90)
at com.sun.source.util.TreeScanner.scanAndReduce(TreeScanner.java:98)
at com.sun.source.util.TreeScanner.visitClass(TreeScanner.java:132)
at com.google.errorprone.ErrorProneScanner.visitClass(ErrorProneScanner.java:299)
at com.google.errorprone.ErrorProneScanner.visitClass(ErrorProneScanner.java:33)
at com.sun.tools.javac.tree.JCTree$JCClassDecl.accept(JCTree.java:618)
at com.sun.source.util.TreePathScanner.scan(TreePathScanner.java:67)
at com.google.errorprone.Scanner.scan(Scanner.java:111)
at com.google.errorprone.Scanner.scan(Scanner.java:44)
Original issue created by steven.m.reed on 2013-08-13 at 07:43 PM
What steps will reproduce the problem?
Trigger the PreconditionsExpensiveString pattern by writing a valid line of code similar to:
Preconditions.checkState(foo.isEmpty(), String.format("Foo must be empty, is %s", foo));
What is the expected output? What do you see instead?
I expect the errorprone compiler to warn me against this usage. However, the compiler itself throws a ClassCastException (included below).
What version of the product are you using? On what operating system?
Using 2.3-SNAPSHOT of plexus-compiler-javac and plexus-compiler-javac-errorprone, and 3.1 of maven-compiler-plugin.
Please provide any additional information below.
An exception has occurred in the compiler (1.7.0_25). Please file a bug at the Java Developer Connection (http://java.sun.com/webapps/bugreport) after checking the Bug Parade for duplicates. Include your program and the following diagnostic in your report. Thank you. java.lang.ClassCastException: com.sun.tools.javac.tree.JCTree$JCIdent cannot be cast to com.sun.source.tree.MemberSelectTree at com.google.errorprone.bugpatterns.PreconditionsExpensiveString.matchMethodInvocation(PreconditionsExpensiveString.java:83) at com.google.errorprone.ErrorProneScanner.visitMethodInvocation(ErrorProneScanner.java:184) at com.google.errorprone.ErrorProneScanner.visitMethodInvocation(ErrorProneScanner.java:33) at com.sun.tools.javac.tree.JCTree$JCMethodInvocation.accept(JCTree.java:1333) at com.sun.source.util.TreePathScanner.scan(TreePathScanner.java:67) at com.google.errorprone.Scanner.scan(Scanner.java:111) at com.google.errorprone.Scanner.scan(Scanner.java:44) at com.sun.source.util.TreeScanner.visitExpressionStatement(TreeScanner.java:240) at com.sun.tools.javac.tree.JCTree$JCExpressionStatement.accept(JCTree.java:1173) at com.sun.source.util.TreePathScanner.scan(TreePathScanner.java:67) at com.google.errorprone.Scanner.scan(Scanner.java:111) at com.google.errorprone.Scanner.scan(Scanner.java:44) at com.sun.source.util.TreeScanner.scanAndReduce(TreeScanner.java:80) at com.sun.source.util.TreeScanner.scan(TreeScanner.java:90) at com.sun.source.util.TreeScanner.visitBlock(TreeScanner.java:159) at com.sun.tools.javac.tree.JCTree$JCBlock.accept(JCTree.java:790) at com.sun.source.util.TreePathScanner.scan(TreePathScanner.java:67) at com.google.errorprone.Scanner.scan(Scanner.java:111) at com.google.errorprone.Scanner.scan(Scanner.java:44) at com.sun.source.util.TreeScanner.scanAndReduce(TreeScanner.java:80) at com.sun.source.util.TreeScanner.visitEnhancedForLoop(TreeScanner.java:185) at com.sun.tools.javac.tree.JCTree$JCEnhancedForLoop.accept(JCTree.java:915) at com.sun.source.util.TreePathScanner.scan(TreePathScanner.java:67) at com.google.errorprone.Scanner.scan(Scanner.java:111) at com.google.errorprone.Scanner.scan(Scanner.java:44) at com.sun.source.util.TreeScanner.scan(TreeScanner.java:90) at com.sun.source.util.TreeScanner.visitBlock(TreeScanner.java:159) at com.sun.tools.javac.tree.JCTree$JCBlock.accept(JCTree.java:790) at com.sun.source.util.TreePathScanner.scan(TreePathScanner.java:67) at com.google.errorprone.Scanner.scan(Scanner.java:111) at com.google.errorprone.Scanner.scan(Scanner.java:44) at com.sun.source.util.TreeScanner.scanAndReduce(TreeScanner.java:80) at com.sun.source.util.TreeScanner.visitMethod(TreeScanner.java:142) at com.google.errorprone.ErrorProneScanner.visitMethod(ErrorProneScanner.java:258) at com.google.errorprone.ErrorProneScanner.visitMethod(ErrorProneScanner.java:33) at com.sun.tools.javac.tree.JCTree$JCMethodDecl.accept(JCTree.java:690) at com.sun.source.util.TreePathScanner.scan(TreePathScanner.java:67) at com.google.errorprone.Scanner.scan(Scanner.java:111) at com.google.errorprone.Scanner.scan(Scanner.java:44) at com.sun.source.util.TreeScanner.scanAndReduce(TreeScanner.java:80) at com.sun.source.util.TreeScanner.scan(TreeScanner.java:90) at com.sun.source.util.TreeScanner.scanAndReduce(TreeScanner.java:98) at com.sun.source.util.TreeScanner.visitClass(TreeScanner.java:132) at com.google.errorprone.ErrorProneScanner.visitClass(ErrorProneScanner.java:299) at com.google.errorprone.ErrorProneScanner.visitClass(ErrorProneScanner.java:33) at com.sun.tools.javac.tree.JCTree$JCClassDecl.accept(JCTree.java:618) at com.sun.source.util.TreePathScanner.scan(TreePathScanner.java:67) at com.google.errorprone.Scanner.scan(Scanner.java:111) at com.google.errorprone.Scanner.scan(Scanner.java:44)