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

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

Closed
lombokissues opened this issue Jul 14, 2015 · 12 comments

Comments

@lombokissues
Copy link

Migrated from Google Code (issue 457)

@lombokissues
Copy link
Author

👤 egor@technoparkcorp.com   🕗 Mar 03, 2013 at 16:49 UTC

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)
}}}

@lombokissues
Copy link
Author

👤 r.spilker   🕗 Mar 04, 2013 at 08:43 UTC

Can you specify the exact version number of javac?

@lombokissues
Copy link
Author

👤 egor@technoparkcorp.com   🕗 Mar 04, 2013 at 09:29 UTC

$ 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)

@lombokissues
Copy link
Author

👤 egor@technoparkcorp.com   🕗 Mar 04, 2013 at 09:29 UTC

$ javac -version
javac 1.7.0_12-ea

@lombokissues
Copy link
Author

👤 reinierz   🕗 Mar 18, 2013 at 23:04 UTC

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:

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

@lombokissues
Copy link
Author

👤 reinierz   🕗 Mar 18, 2013 at 23:05 UTC

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.

@lombokissues
Copy link
Author

👤 lamshing   🕗 Apr 12, 2013 at 08:42 UTC

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)

@lombokissues
Copy link
Author

👤 uimffr129   🕗 Aug 26, 2014 at 13:22 UTC

Could this be a JDK 64bit bug?

@lombokissues
Copy link
Author

End of migration

lianhaijun pushed a commit to lianhaijun/lombok that referenced this issue May 8, 2020
* added example for issue projectlombok#512

* fix removing of field annotations during delombok

* cleanup code

* added to changelog projectlombok#530

* added support for ImplicitResourceCloser extension point for @cleanup projectlombok#287

* master is now for: up from 2018.1 IntelliJ builds
@melany-chavez-17
Copy link

i have this problem:
java: java.lang.NoSuchFieldError: Class com.sun.tools.javac.tree.JCTree$JCImport does not have member field 'com.sun.tools.javac.tree.JCTree qualid'

@rspilker
Copy link
Collaborator

@melany-chavez-17 I guess you switched to JDK21 and did not used the latest versin of lombok.

@rspilker
Copy link
Collaborator

Closing this issue, too old to still be relevant

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

No branches or pull requests

3 participants