projectlombok / lombok

Very spicy additions to the Java programming language.
https://projectlombok.org/
Other
12.85k stars 2.38k forks source link

lombok.eclipse.handlers.HandleConstructor$HandleRequiredArgsConstructor failed [BUG] #3606

Closed gernhan closed 7 months ago

gernhan commented 7 months ago

Describe the bug

[ERROR][2024-02-15 13:21:48] ...lsp/handlers.lua:535    "Feb 15, 2024, 1:21:48 PM Lombok annotation handler class lombok.eclipse.handlers.HandleConstructor$HandleRequiredArgsConstructor failed\n'java.lang.StringBuffer org.eclipse.jdt.internal.compiler.ast.Expression.print(int, java.lang.StringBuffer)'\njava.lang.NoSuchMethodError: 'java.lang.StringBuffer org.eclipse.jdt.internal.compiler.ast.Expression.print(int, java.lang.StringBuffer)'\n\tat lombok.eclipse.handlers.EclipseHandlerUtil.createAnnotation(EclipseHandlerUtil.java:1335)\n\tat lombok.eclipse.HandlerLibrary$AnnotationHandlerContainer.handle(HandlerLibrary.java:105)\n\tat lombok.eclipse.HandlerLibrary.handleAnnotation(HandlerLibrary.java:237)\n\tat lombok.eclipse.TransformEclipseAST$AnnotationVisitor.visitAnnotationOnType(TransformEclipseAST.java:265)\n\tat lombok.eclipse.EclipseNode.traverse(EclipseNode.java:107)\n\tat lombok.eclipse.EclipseAST.traverseChildren(EclipseAST.java:231)\n\tat lombok.eclipse.EclipseNode.traverse(EclipseNode.java:74)\n\tat lombok.eclipse.EclipseAST.traverseChildren(EclipseAST.java:231)\n\tat lombok.eclipse.EclipseNode.traverse(EclipseNode.java:69)\n\tat lombok.eclipse.EclipseAST.traverse(EclipseAST.java:224)\n\tat lombok.eclipse.TransformEclipseAST.go(TransformEclipseAST.java:222)\n\tat lombok.eclipse.TransformEclipseAST.transform(TransformEclipseAST.java:183)\n\tat lombok.eclipse.TransformEclipseAST.transform_swapped(TransformEclipseAST.java:107)\n\tat jdk.internal.reflect.GeneratedMethodAccessor18.invoke(Unknown Source)\n\tat java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)\n\tat java.base/java.lang.reflect.Method.invoke(Method.java:568)\n\tat lombok.launch.PatchFixesHider$Util.invokeMethod(PatchFixesHider.java:133)\n\tat lombok.launch.PatchFixesHider$Transform.transform_swapped(PatchFixesHider.java:256)\n\tat org.eclipse.jdt.internal.compiler.parser.Parser.endParse(Parser.java:12067)\n\tat org.eclipse.jdt.internal.core.util.CommentRecorderParser.endParse(CommentRecorderParser.java:131)\n\tat org.eclipse.jdt.internal.compiler.SourceElementParser.endParse(SourceElementParser.java:830)\n\tat org.eclipse.jdt.internal.compiler.parser.Parser.parse(Parser.java:13269)\n\tat org.eclipse.jdt.internal.compiler.parser.Parser.parse(Parser.java:13499)\n\tat org.eclipse.jdt.internal.compiler.parser.Parser.parse(Parser.java:13456)\n\tat org.eclipse.jdt.internal.compiler.SourceElementParser.parseCompilationUnit(SourceElementParser.java:1122)\n\tat org.eclipse.jdt.internal.core.CompilationUnit.buildStructure(CompilationUnit.java:196)\n\tat org.eclipse.jdt.internal.core.Openable.generateInfos(Openable.java:266)\n\tat org.eclipse.jdt.internal.core.SourceRefElement.generateInfos(SourceRefElement.java:113)\n\tat org.eclipse.jdt.internal.core.JavaElement.openWhenClosed(JavaElement.java:572)\n\tat org.eclipse.jdt.internal.core.JavaElement.getElementInfo(JavaElement.java:303)\n\tat org.eclipse.jdt.internal.core.JavaElement.getElementInfo(JavaElement.java:289)\n\tat org.eclipse.jdt.internal.core.SourceType.getAnnotations(SourceType.java:218)\n\tat org.eclipse.jdt.internal.core.search.matching.MatchLocator.createHandle(MatchLocator.java:703)\n\tat org.eclipse.jdt.internal.core.search.matching.MatchLocator.reportMatching(MatchLocator.java:2725)\n\tat org.eclipse.jdt.internal.core.search.matching.MatchLocator.reportMatching(MatchLocator.java:3181)\n\tat org.eclipse.jdt.internal.core.search.matching.MatchLocator.reportMatching(MatchLocator.java:2887)\n\tat org.eclipse.jdt.internal.core.search.matching.MatchLocator.process(MatchLocator.java:2059)\n\tat org.eclipse.jdt.internal.core.search.matching.MatchLocator.locateMatches(MatchLocator.java:1370)\n\tat org.eclipse.jdt.internal.core.search.matching.MatchLocator.locateMatches(MatchLocator.java:1407)\n\tat org.eclipse.jdt.internal.core.search.matching.MatchLocator.locateMatches(MatchLocator.java:1550)\n\tat org.eclipse.jdt.internal.core.search.JavaSearchParticipant.locateMatches(JavaSearchParticipant.java:135)\n\tat org.eclipse.jdt.internal.core.search.BasicSearchEngine.findMatches(BasicSearchEngine.java:254)\n\tat org.eclipse.jdt.internal.core.search.BasicSearchEngine.search(BasicSearchEngine.java:600)\n\tat org.eclipse.jdt.core.search.SearchEngine.search(SearchEngine.java:669)\n\tat org.eclipse.jdt.ls.core.internal.handlers.CodeLensHandler.findReferences(CodeLensHandler.java:147)\n\tat org.eclipse.jdt.ls.core.internal.handlers.CodeLensHandler.resolve(CodeLensHandler.java:100)\n\tat org.eclipse.jdt.ls.core.internal.handlers.JDTLanguageServer.lambda$17(JDTLanguageServer.java:819)\n\tat org.eclipse.jdt.ls.core.internal.BaseJDTLanguageServer.lambda$0(BaseJDTLanguageServer.java:87)\n\tat java.base/java.util.concurrent.CompletableFuture$UniApply.tryFire(CompletableFuture.java:646)\n\tat java.base/java.util.concurrent.CompletableFuture$Completion.exec(CompletableFuture.java:483)\n\tat java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:373)\n\tat java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1182)\n\tat java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1655)\n\tat java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1622)\n\tat java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:165)\n"

To be prettier:

[ERROR][2024-02-15 13:21:48] ...lsp/handlers.lua:535    "Feb 15, 2024, 1:21:48 PM Lombok annotation handler class lombok.eclipse.handlers.HandleConstructor$HandleRequiredArgsConstructor failed
'java.lang.StringBuffer org.eclipse.jdt.internal.compiler.ast.Expression.print(int, java.lang.StringBuffer)'
java.lang.NoSuchMethodError: 'java.lang.StringBuffer org.eclipse.jdt.internal.compiler.ast.Expression.print(int, java.lang.StringBuffer)'
     lombok.eclipse.handlers.EclipseHandlerUtil.createAnnotation(EclipseHandlerUtil.java:1335)
     lombok.eclipse.HandlerLibrary$AnnotationHandlerContainer.handle(HandlerLibrary.java:105)
     lombok.eclipse.HandlerLibrary.handleAnnotation(HandlerLibrary.java:237)
     lombok.eclipse.TransformEclipseAST$AnnotationVisitor.visitAnnotationOnType(TransformEclipseAST.java:265)
     lombok.eclipse.EclipseNode.traverse(EclipseNode.java:107)
     lombok.eclipse.EclipseAST.traverseChildren(EclipseAST.java:231)
     lombok.eclipse.EclipseNode.traverse(EclipseNode.java:74)
     lombok.eclipse.EclipseAST.traverseChildren(EclipseAST.java:231)
     lombok.eclipse.EclipseNode.traverse(EclipseNode.java:69)
     lombok.eclipse.EclipseAST.traverse(EclipseAST.java:224)
     lombok.eclipse.TransformEclipseAST.go(TransformEclipseAST.java:222)
     lombok.eclipse.TransformEclipseAST.transform(TransformEclipseAST.java:183)
     lombok.eclipse.TransformEclipseAST.transform_swapped(TransformEclipseAST.java:107)
     jdk.internal.reflect.GeneratedMethodAccessor18.invoke(Unknown Source)
     java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
     java.base/java.lang.reflect.Method.invoke(Method.java:568)
     lombok.launch.PatchFixesHider$Util.invokeMethod(PatchFixesHider.java:133)
     lombok.launch.PatchFixesHider$Transform.transform_swapped(PatchFixesHider.java:256)
     org.eclipse.jdt.internal.compiler.parser.Parser.endParse(Parser.java:12067)
     org.eclipse.jdt.internal.core.util.CommentRecorderParser.endParse(CommentRecorderParser.java:131)
     org.eclipse.jdt.internal.compiler.SourceElementParser.endParse(SourceElementParser.java:830)
     org.eclipse.jdt.internal.compiler.parser.Parser.parse(Parser.java:13269)
     org.eclipse.jdt.internal.compiler.parser.Parser.parse(Parser.java:13499)
     org.eclipse.jdt.internal.compiler.parser.Parser.parse(Parser.java:13456)
     org.eclipse.jdt.internal.compiler.SourceElementParser.parseCompilationUnit(SourceElementParser.java:1122)
     org.eclipse.jdt.internal.core.CompilationUnit.buildStructure(CompilationUnit.java:196)
     org.eclipse.jdt.internal.core.Openable.generateInfos(Openable.java:266)
     org.eclipse.jdt.internal.core.SourceRefElement.generateInfos(SourceRefElement.java:113)
     org.eclipse.jdt.internal.core.JavaElement.openWhenClosed(JavaElement.java:572)
     org.eclipse.jdt.internal.core.JavaElement.getElementInfo(JavaElement.java:303)
     org.eclipse.jdt.internal.core.JavaElement.getElementInfo(JavaElement.java:289)
     org.eclipse.jdt.internal.core.SourceType.getAnnotations(SourceType.java:218)
     org.eclipse.jdt.internal.core.search.matching.MatchLocator.createHandle(MatchLocator.java:703)
     org.eclipse.jdt.internal.core.search.matching.MatchLocator.reportMatching(MatchLocator.java:2725)
     org.eclipse.jdt.internal.core.search.matching.MatchLocator.reportMatching(MatchLocator.java:3181)
     org.eclipse.jdt.internal.core.search.matching.MatchLocator.reportMatching(MatchLocator.java:2887)
     org.eclipse.jdt.internal.core.search.matching.MatchLocator.process(MatchLocator.java:2059)
     org.eclipse.jdt.internal.core.search.matching.MatchLocator.locateMatches(MatchLocator.java:1370)
     org.eclipse.jdt.internal.core.search.matching.MatchLocator.locateMatches(MatchLocator.java:1407)
     org.eclipse.jdt.internal.core.search.matching.MatchLocator.locateMatches(MatchLocator.java:1550)
     org.eclipse.jdt.internal.core.search.JavaSearchParticipant.locateMatches(JavaSearchParticipant.java:135)
     org.eclipse.jdt.internal.core.search.BasicSearchEngine.findMatches(BasicSearchEngine.java:254)
     org.eclipse.jdt.internal.core.search.BasicSearchEngine.search(BasicSearchEngine.java:600)
     org.eclipse.jdt.core.search.SearchEngine.search(SearchEngine.java:669)
     org.eclipse.jdt.ls.core.internal.handlers.CodeLensHandler.findReferences(CodeLensHandler.java:147)
     org.eclipse.jdt.ls.core.internal.handlers.CodeLensHandler.resolve(CodeLensHandler.java:100)
     org.eclipse.jdt.ls.core.internal.handlers.JDTLanguageServer.lambda$17(JDTLanguageServer.java:819)
     org.eclipse.jdt.ls.core.internal.BaseJDTLanguageServer.lambda$0(BaseJDTLanguageServer.java:87)
     java.base/java.util.concurrent.CompletableFuture$UniApply.tryFire(CompletableFuture.java:646)
     java.base/java.util.concurrent.CompletableFuture$Completion.exec(CompletableFuture.java:483)
     java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:373)
     java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1182)
     java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1655)
     java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1622)
     java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:165)
"

I caught this error when jdtls (with nvim-jdtls, and neovim configurations) tried to understand annotation: @RequiredArgsConstructor(staticName = "of")inside class:

import `lombok.extern.log4j.Log4j2;
@Log4j2
@RequiredArgsConstructor(staticName = "of")
public class SomeClass {
  private final Connection conn;
}`

Although It worked well with:

import lombok.Getter;
import lombok.RequiredArgsConstructor;

@RequiredArgsConstructor
@Getter
public class SqlDataType {

  private final String type;
  private final Integer precision;
  private final Integer scale;
}

but when it comes with (staticName = "of"), that error immediately emerged.

Expected behavior jdtls should work well with both @RequiredArgsConstructor and @RequiredArgsConstructor(staticName = "of")

Version info (please complete the following information):

Rawi01 commented 7 months ago

Can you check that you use the latest version (1.18.30) as javaagent for your language server? IIRC this problem was fixed in #3565

gernhan commented 7 months ago

Can you check that you use the latest version (1.18.30) as javaagent for your language server? IIRC this problem was fixed in #3565

I upgrade jdtls to version 1.32.0, override lombok file with version 1.8.30 and then the error still be there lombok_failed jdtls 1 32 0 lombok1 18 302

Rawi01 commented 7 months ago

Sorry, I messed that up. I thought that these changes were already released but I was wrong. The fix is only included in the edge release.

gernhan commented 7 months ago

Sorry, I messed that up. I thought that these changes were already released but I was wrong. The fix is only included in the edge release.

I hope that we will have a better version next time. Thank you so much for your effort 💯

a1dutch commented 7 months ago

@Rawi01 is there a p2 edge release update site?

gernhan commented 7 months ago

@gernhan is there a p2 edge release update site?

I am not sure I understand your question. I am so sorry for that. Anyway, just download the jar file from edge release, then use it as javaagent then everything will be just fine. Thank you 👍

a1dutch commented 7 months ago

sorry @gernhan, this should have been a question for @Rawi01.