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

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

Closed
gernhan opened this issue Feb 15, 2024 · 7 comments

Comments

@gernhan
Copy link

gernhan commented Feb 15, 2024

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

  • Lombok version: 1.8.30
  • Platform: java version 17.
  • Configuration:
   local config = {
      cmd = {
        "java",
        "-Declipse.application=org.eclipse.jdt.ls.core.id1",
        "-Dosgi.bundles.defaultStartLevel=4",
        "-Declipse.product=org.eclipse.jdt.ls.core.product",
        "-Dlog.protocol=true",
        "-Dlog.level=ALL",
        "-Xms1g",
        "-Xmx4g",
        "--add-modules=ALL-SYSTEM",
        "--add-opens",
        "java.base/java.util=ALL-UNNAMED",
        "--add-opens",
        "java.base/java.lang=ALL-UNNAMED",
        "-javaagent:" .. lombok,
        "-jar",
        launcher,
        "-configuration",
        os_config,
        "-data",
        workspace_dir,
      },
@gernhan gernhan changed the title R[BUG] lombok.eclipse.handlers.HandleConstructor$HandleRequiredArgsConstructor failed [BUG] Feb 15, 2024
@Rawi01
Copy link
Collaborator

Rawi01 commented Feb 15, 2024

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 gernhan closed this as completed Feb 15, 2024
@gernhan gernhan reopened this Feb 15, 2024
@gernhan
Copy link
Author

gernhan commented Feb 15, 2024

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
Copy link
Collaborator

Rawi01 commented Feb 15, 2024

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
Copy link
Author

gernhan commented Feb 16, 2024

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 💯

@Rawi01 Rawi01 closed this as completed Feb 18, 2024
@a1dutch
Copy link

a1dutch commented Feb 23, 2024

@Rawi01 is there a p2 edge release update site?

@gernhan
Copy link
Author

gernhan commented Feb 23, 2024

@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
Copy link

a1dutch commented Feb 23, 2024

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

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