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

[BUG] @Builder with Javadoc causes error markers in Java editor with Eclipse 2024-09 (4.33.0) #3757

Open
meldorq opened this issue Sep 27, 2024 · 4 comments

Comments

@meldorq
Copy link

meldorq commented Sep 27, 2024

Describe the bug

Since the upgrade to Eclipse 2024-09 (4.33) the @Builder annotation leads to error markers in the Java editor under special circumstances.

To Reproduce

Create a simple maven project in Eclipse containing these two classes:

MyClass.java

package test;

import lombok.Builder;
import lombok.Data;

@Data
@Builder
public class MyClass {

    /**
     * .
     */
    private String name;

}

MyClass2.java

package test;

public class MyClass2 {

    public void myMethod() {

        MyClass x = MyClass.builder().build();
    }

}

The reference to builder() in MyClass2 is underlined red with the error message 'The method builder() is undefined for the type MyClass'

When I remove the Javadoc comment from name in MyClass, the error goes away.

Expected behavior

There shouldn't be an error.

Version info (please complete the following information):

  • Lombok version: 1.18.34
  • Platform: Eclipse 2024-09 (4.33)
@mduggen
Copy link

mduggen commented Oct 2, 2024

Also with:

  • Lombok version: 1.18.34
  • Platform: Eclipse 2024-06 (4.32)

@cxfly
Copy link

cxfly commented Oct 10, 2024

Lombok version: 1.18.34
Eclipse Platform 4.33.0.v20240903-0618

There is an error log in the eclipse background, which should be caused by the incompatibility of the new eclipse version.
This can be solved by annotating the type with @NoArgsConstructor @AllArgsConstructor

eclipse error log:
!MESSAGE Lombok annotation handler class lombok.eclipse.handlers.HandleBuilder failed
!STACK 0
java.lang.NullPointerException: Cannot invoke "Object.getClass()" because "compilationUnit" is null
at lombok.eclipse.handlers.EclipseHandlerUtil.setDocComment(EclipseHandlerUtil.java:2841)
at lombok.eclipse.handlers.EclipseHandlerUtil.setDocComment(EclipseHandlerUtil.java:2830)

image

org.eclipse.jdt.internal.core.CompilationUnit

@H-Lo
Copy link

H-Lo commented Oct 11, 2024

I'm joining the error club. Compilation works, but in editor I get red error marks on my builder calls.

Spring Tool Suite 4
Version: 4.25.0.RELEASE
Build Id: 202409101855
Revision: a82190b58c93608a59d9bda759d6df93d9e84ca1

Lombok version: 1.18.34


How to reproduce:

SearchReqOk.java

package lomboktest;
import org.apache.commons.lang3.StringUtils;
import lombok.Builder;
import lombok.Getter;
@Builder @Getter public class SearchReqOk {
    //
    // No JavaDoc
    //
    private final String q;
    public static class SearchReqOkBuilder {
        public SearchReqOkBuilder q(final String q) { this.q = StringUtils.trimToNull(q); return this; }
    }
}

SearchReqDefective.java

package lomboktest;
import org.apache.commons.lang3.StringUtils;
import lombok.Builder;
import lombok.Getter;
@Builder @Getter public class SearchReqDefective {
    /**
     * JavaDoc
     */
    private final String q;
    public static class SearchReqDefectiveBuilder {
        public SearchReqDefectiveBuilder q(final String q) { this.q = StringUtils.trimToNull(q); return this; }
    }
}

UseBuilder.java

package lomboktest;
import lomboktest.SearchReqDefective.SearchReqDefectiveBuilder;
import lomboktest.SearchReqOk.SearchReqOkBuilder;
public class UseBuilder {
    public static void main(final String[] args) {
        final SearchReqOkBuilder ok = SearchReqOk.builder().q("ok");
        System.out.println(ok.build());
        final SearchReqDefectiveBuilder defective = SearchReqDefective.builder().q("not-ok");
        System.out.println(error.build());
    }
}

lombok-error

@H-Lo
Copy link

H-Lo commented Oct 11, 2024

If you don't like this error, quick fix is to convert JavaDoc to a normal Java comment:

/**
 * Do not use JavaDoc comment style. Or Javadoc, don't know should I use camel case or not.
 */

/*
 * Such a comment does not trigger an error in Eclipse.
 */

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

4 participants