akshattandon / projectlombok

Automatically exported from code.google.com/p/projectlombok
0 stars 0 forks source link

com.sun.tools.javac.tree.JCTree$JCTypeApply cannot be cast to com.sun.tools.javac.tree.JCTree$JCArrayTypeTree #457

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
This code: 

{{{
@ToString
final class Foo {
    private transient String format;
    private transient List<Object> arguments;
}
}}}

Leads to (with OpenJDK 7):

{{{
java.lang.ClassCastException: com.sun.tools.javac.tree.JCTree$JCTypeApply 
cannot be cast to com.sun.tools.javac.tree.JCTree$JCArrayTypeTree
    at lombok.javac.handlers.HandleToString.createToString(HandleToString.java:207)
    at lombok.javac.handlers.HandleToString.generateToString(HandleToString.java:153)
    at lombok.javac.handlers.HandleToString.handle(HandleToString.java:94)
    at lombok.javac.HandlerLibrary$AnnotationHandlerContainer.handle(HandlerLibrary.java:105)
    at lombok.javac.HandlerLibrary.handleAnnotation(HandlerLibrary.java:242)
    at lombok.javac.JavacTransformer$AnnotationVisitor.visitAnnotationOnType(JavacTransformer.java:86)
    at lombok.javac.JavacNode.traverse(JavacNode.java:104)
    at lombok.javac.JavacAST.traverseChildren(JavacAST.java:122)
    at lombok.javac.JavacNode.traverse(JavacNode.java:67)
    at lombok.javac.JavacAST.traverseChildren(JavacAST.java:122)
    at lombok.javac.JavacNode.traverse(JavacNode.java:62)
    at lombok.javac.JavacAST.traverse(JavacAST.java:117)
    at lombok.javac.JavacTransformer.transform(JavacTransformer.java:70)
    at lombok.javac.apt.Processor.process(Processor.java:256)
    at lombok.core.AnnotationProcessor$JavacDescriptor.process(AnnotationProcessor.java:117)
    at lombok.core.AnnotationProcessor.process(AnnotationProcessor.java:169)
    at com.sun.tools.javac.processing.JavacProcessingEnvironment.callProcessor(JavacProcessingEnvironment.java:793)
    at com.sun.tools.javac.processing.JavacProcessingEnvironment.discoverAndRunProcs(JavacProcessingEnvironment.java:722)
    at com.sun.tools.javac.processing.JavacProcessingEnvironment.access$1700(JavacProcessingEnvironment.java:97)
    at com.sun.tools.javac.processing.JavacProcessingEnvironment$Round.run(JavacProcessingEnvironment.java:1029)
    at com.sun.tools.javac.processing.JavacProcessingEnvironment.doProcessing(JavacProcessingEnvironment.java:1163)
    at com.sun.tools.javac.main.JavaCompiler.processAnnotations(JavaCompiler.java:1108)
    at com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:824)
    at com.sun.tools.javac.main.Main.compile(Main.java:439)
    at com.sun.tools.javac.api.JavacTaskImpl.call(JavacTaskImpl.java:132)
}}}

Original issue reported on code.google.com by egor@technoparkcorp.com on 3 Mar 2013 at 4:49

GoogleCodeExporter commented 9 years ago
Can you specify the exact version number of javac?

Original comment by r.spilker on 4 Mar 2013 at 8:43

GoogleCodeExporter commented 9 years ago
$ java -version
java version "1.7.0_12-ea"
Java(TM) SE Runtime Environment (build 1.7.0_12-ea-b08)
Java HotSpot(TM) 64-Bit Server VM (build 24.0-b28, mixed mode)

Original comment by egor@technoparkcorp.com on 4 Mar 2013 at 9:29

GoogleCodeExporter commented 9 years ago
$ javac -version
javac 1.7.0_12-ea

Original comment by egor@technoparkcorp.com on 4 Mar 2013 at 9:29

GoogleCodeExporter commented 9 years ago
This is not reproducible for us (but we don't have an openjdk 1.7.0_12-ea lying 
around). Looking at line 207, this would happen if you have a method named 
.getArguments() which returns an array. We fixed that in edge, can you download 
that and see if this problem still occurs for you?

edge is at:

http://projectlombok.org/download-edge.html

Original comment by reini...@gmail.com on 18 Mar 2013 at 11:04

GoogleCodeExporter commented 9 years ago
NB: Also, just so you know, if you have a field named arguments and a method 
named .getArguments(), then toString() and equals() and hashCode() will all use 
.getArguments() instead, and thus also whatever type that method returns. Just 
FYI. You can override this behaviour with an argument on @ToString and company.

Original comment by reini...@gmail.com on 18 Mar 2013 at 11:05

GoogleCodeExporter commented 9 years ago
I can replicate it here with ToString

I'm using jdk 7u17 from sun/oracle though

java version "1.7.0_17"
Java(TM) SE Runtime Environment (build 1.7.0_17-b02)
Java HotSpot(TM) Client VM (build 23.7-b01, mixed mode, sharing)

Original comment by lamsh...@gmail.com on 12 Apr 2013 at 8:42

GoogleCodeExporter commented 9 years ago
Could this be a JDK 64bit bug?

Original comment by uimffr...@googlemail.com on 26 Aug 2014 at 1:22