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

Problem with Lombok @Builder #7866

Closed
mtbadi39 opened this issue Oct 10, 2024 · 4 comments
Closed

Problem with Lombok @Builder #7866

mtbadi39 opened this issue Oct 10, 2024 · 4 comments
Labels
kind:bug Bug report or fix needs:triage Requires attention from one of the committers

Comments

@mtbadi39
Copy link

mtbadi39 commented Oct 10, 2024

Apache NetBeans version

Apache NetBeans 23

What happened

Exception occured when Rignt Click to Fix Imports in a class that implements org.springframework.security.core.userdetails.UserDetails and annotated with Lombok @Builder

When removing Lombok @DaTa @builder, Rignt Click / Fix Imports works with no exception.


java.lang.NoSuchFieldError: Class com.sun.tools.javac.parser.Tokens$Comment$CommentStyle does not have member field 'com.sun.tools.javac.parser.Tokens$Comment$CommentStyle JAVADOC'
	at lombok.javac.Javac$JavadocOps_8$1.getStyle(Javac.java:364)
	at com.sun.tools.javac.parser.DocCommentParser.getTextKind(DocCommentParser.java:171)
	at com.sun.tools.javac.parser.DocCommentParser.<init>(DocCommentParser.java:164)
	at com.sun.tools.javac.parser.DocCommentParser.<init>(DocCommentParser.java:139)
	at com.sun.tools.javac.api.JavacTrees.getDocCommentTree(JavacTrees.java:1130)
	at com.sun.tools.javac.parser.LazyDocCommentTable.getCommentTree(LazyDocCommentTable.java:101)
	at com.sun.tools.javac.api.JavacTrees.getDocCommentTree(JavacTrees.java:760)
	at org.netbeans.modules.java.editor.base.javadoc.JavadocImports.computeTokensOfReferencedElements(JavadocImports.java:181)
	at org.netbeans.modules.java.editor.base.semantic.FindLocalUsagesQuery.handleJavadoc(FindLocalUsagesQuery.java:93)
	at org.netbeans.modules.java.editor.base.semantic.FindLocalUsagesQuery.visitMethod(FindLocalUsagesQuery.java:114)
	at org.netbeans.modules.java.editor.base.semantic.FindLocalUsagesQuery.visitMethod(FindLocalUsagesQuery.java:55)
	at com.sun.tools.javac.tree.JCTree$JCMethodDecl.accept(JCTree.java:989)
	at com.sun.source.util.TreePathScanner.scan(TreePathScanner.java:92)
	at org.netbeans.api.java.source.support.CancellableTreePathScanner.scan(CancellableTreePathScanner.java:69)
	at org.netbeans.modules.java.editor.base.semantic.FindLocalUsagesQuery.scan(FindLocalUsagesQuery.java:200)
	at org.netbeans.modules.java.editor.base.semantic.FindLocalUsagesQuery.scan(FindLocalUsagesQuery.java:55)
	at com.sun.source.util.TreeScanner.scanAndReduce(TreeScanner.java:95)
	at com.sun.source.util.TreeScanner.scan(TreeScanner.java:110)
	at org.netbeans.api.java.source.support.CancellableTreePathScanner.scan(CancellableTreePathScanner.java:78)
	at com.sun.source.util.TreeScanner.scanAndReduce(TreeScanner.java:118)
	at com.sun.source.util.TreeScanner.visitClass(TreeScanner.java:202)
	at org.netbeans.modules.java.editor.base.semantic.FindLocalUsagesQuery.visitClass(FindLocalUsagesQuery.java:141)
	at org.netbeans.modules.java.editor.base.semantic.FindLocalUsagesQuery.visitClass(FindLocalUsagesQuery.java:55)
	at com.sun.tools.javac.tree.JCTree$JCClassDecl.accept(JCTree.java:896)
	at com.sun.source.util.TreePathScanner.scan(TreePathScanner.java:92)
	at org.netbeans.api.java.source.support.CancellableTreePathScanner.scan(CancellableTreePathScanner.java:69)
	at org.netbeans.modules.java.editor.base.semantic.FindLocalUsagesQuery.scan(FindLocalUsagesQuery.java:200)
	at org.netbeans.modules.java.editor.base.semantic.FindLocalUsagesQuery.scan(FindLocalUsagesQuery.java:55)
	at com.sun.source.util.TreeScanner.scanAndReduce(TreeScanner.java:95)
	at com.sun.source.util.TreeScanner.scan(TreeScanner.java:110)
	at org.netbeans.api.java.source.support.CancellableTreePathScanner.scan(CancellableTreePathScanner.java:78)
	at com.sun.source.util.TreeScanner.scanAndReduce(TreeScanner.java:118)
	at com.sun.source.util.TreeScanner.visitClass(TreeScanner.java:202)
	at org.netbeans.modules.java.editor.base.semantic.FindLocalUsagesQuery.visitClass(FindLocalUsagesQuery.java:141)
	at org.netbeans.modules.java.editor.base.semantic.FindLocalUsagesQuery.visitClass(FindLocalUsagesQuery.java:55)
	at com.sun.tools.javac.tree.JCTree$JCClassDecl.accept(JCTree.java:896)
	at com.sun.source.util.TreePathScanner.scan(TreePathScanner.java:92)
	at org.netbeans.api.java.source.support.CancellableTreePathScanner.scan(CancellableTreePathScanner.java:69)
	at org.netbeans.modules.java.editor.base.semantic.FindLocalUsagesQuery.scan(FindLocalUsagesQuery.java:200)
	at org.netbeans.modules.java.editor.base.semantic.FindLocalUsagesQuery.scan(FindLocalUsagesQuery.java:55)
	at com.sun.source.util.TreeScanner.scan(TreeScanner.java:110)
	at org.netbeans.api.java.source.support.CancellableTreePathScanner.scan(CancellableTreePathScanner.java:78)
	at com.sun.source.util.TreeScanner.scanAndReduce(TreeScanner.java:118)
	at com.sun.source.util.TreeScanner.visitCompilationUnit(TreeScanner.java:151)
	at com.sun.tools.javac.tree.JCTree$JCCompilationUnit.accept(JCTree.java:625)
	at com.sun.source.util.TreePathScanner.scan(TreePathScanner.java:92)
	at org.netbeans.api.java.source.support.CancellableTreePathScanner.scan(CancellableTreePathScanner.java:69)
	at org.netbeans.modules.java.editor.base.semantic.FindLocalUsagesQuery.scan(FindLocalUsagesQuery.java:200)
	at org.netbeans.modules.java.editor.base.semantic.FindLocalUsagesQuery.findUsages(FindLocalUsagesQuery.java:77)
	at org.netbeans.modules.java.editor.base.semantic.MarkOccurrencesHighlighterBase.processImpl(MarkOccurrencesHighlighterBase.java:338)
	at org.netbeans.modules.java.editor.semantic.MarkOccurrencesHighlighter.process(MarkOccurrencesHighlighter.java:93)
	at org.netbeans.modules.java.editor.base.semantic.MarkOccurrencesHighlighterBase.run(MarkOccurrencesHighlighterBase.java:99)
	at org.netbeans.modules.parsing.impl.TaskProcessor.callParserResultTask(TaskProcessor.java:561)
	at org.netbeans.modules.parsing.impl.TaskProcessor$RequestPerformer.run(TaskProcessor.java:786)
	at org.openide.util.lookup.Lookups.executeWith(Lookups.java:288)
	at org.netbeans.modules.parsing.impl.TaskProcessor$RequestPerformer.execute(TaskProcessor.java:702)
[catch] at org.netbeans.modules.parsing.impl.TaskProcessor$CompilationJob.run(TaskProcessor.java:663)
	at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:572)
	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:317)
	at org.openide.util.RequestProcessor$Task.run(RequestProcessor.java:1403)
	at org.netbeans.modules.openide.util.GlobalLookup.execute(GlobalLookup.java:45)
	at org.openide.util.lookup.Lookups.executeWith(Lookups.java:287)
	at org.openide.util.RequestProcessor$Processor.run(RequestProcessor.java:2018)

Language / Project Type / NetBeans Component

Spring Boot Maven Project

How to reproduce

  • Create class that implements org.springframework.security.core.userdetails.UserDetails
  • Add some other fields
  • Add Lombok @DaTa @builder ..
  • Rignt Click / Fix Imports

Did this work correctly in an earlier version?

No / Don't know

Operating System

Windows 10

JDK

21.0.4; OpenJDK 64-Bit Server VM 21.0.4+7-LTS

Apache NetBeans packaging

Apache NetBeans provided installer

Anything else

My Code

@Slf4j
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@EqualsAndHashCode(callSuper = false, of = {"username"})
public class UserPrincipal implements UserDetails {

    private static final long serialVersionUID = 1L;
    private String username;
    private String dn;
    private String displayName;
    private LocalDateTime lastLogon;
    private LocalDateTime whenCreated;
    private byte[] profilePhoto;
    private boolean enabled;
    private boolean accountNonExpired;
    private boolean credentialsNonExpired;
    private boolean accountNonLocked;
    private Collection<? extends GrantedAuthority> authorities;

    @Override
    public String getUsername() {
        return username;
    }

    @Override
    public String getPassword() {
        return null;
    }

    @Override
    public Collection<? extends GrantedAuthority> getAuthorities() {
        return authorities;
    }

    @Override
    public boolean isAccountNonExpired() {
        return accountNonExpired;
    }

    @Override
    public boolean isAccountNonLocked() {
        return accountNonLocked;
    }

    @Override
    public boolean isCredentialsNonExpired() {
        return credentialsNonExpired;
    }

    @Override
    public boolean isEnabled() {
        return enabled;
    }

}

Are you willing to submit a pull request?

No

@mtbadi39 mtbadi39 added kind:bug Bug report or fix needs:triage Requires attention from one of the committers labels Oct 10, 2024
@neilcsmith-net
Copy link
Member

Probably a duplicate of #7664 and many others. NetBeans 23 uses javac from JDK 23, so you'll need a version of Lombok that supports that. See projectlombok/lombok#3722

@neilcsmith-net neilcsmith-net closed this as not planned Won't fix, can't repro, duplicate, stale Oct 10, 2024
@mtbadi39
Copy link
Author

Probably a duplicate of #7664 and many others. NetBeans 23 uses javac from JDK 23, so you'll need a version of Lombok that supports that. See projectlombok/lombok#3722

is there a workaround !!

@matthiasblaesing
Copy link
Contributor

@mtbadi39 you need to update lombok. We have legacy projects, that use lombok, and for these we defined the lombok version as a property and I have an override for that in my local settings so that I can force usage of a compatible lombok version.

@mtbadi39
Copy link
Author

for me, its fixed when upgrading to Lombok v1.18.36

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind:bug Bug report or fix needs:triage Requires attention from one of the committers
Projects
None yet
Development

No branches or pull requests

3 participants