javaeclipselombokspring-tool-suite

Eclipse @NonNullByDefault error with lombok class using @Value


I am using Spring Tool Suite 4.18.0 (based on Eclipse) with Lombok v1.18.26 with this configuration in lombok.config:

config.stopBubbling = true 
lombok.addLombokGeneratedAnnotation = true
lombok.noArgsConstructor.extraPrivate = false
lombok.addNullAnnotations = eclipse

In my package-info.java I have:

@org.eclipse.jdt.annotation.NonNullByDefault
package bb.b;

In the package bb.b I have the following class:

package bb.b;

import lombok.Value;

@Value
public class Test {

}

And I am getting the following error:

Illegal redefinition of parameter o, inherited method from Object does not constrain this parameter

How can I configure Eclipse Null checking to play nicely with Lombok?


Solution

  • Unfortunately, I don't think there is a good solution to your problem...

    HEADSUP: We've changed how this is going to work. We're not going to hunt for @NonNullByDefault annotations; these are more usually found on the package and that'd take rather a lot of time and complication to find, so now whether lombok generates the annotation or not is too 'voodoo magical' (it is hard to explain that we see it on classes but not on packages!). Also, more generally, sometimes we need to generate the 'other' annotation (non-null), in which case there's nothing we can see anywhere to tip us off that we need to do that.Therefore, instead, there is a lombok.config key where you configure what kind of 'flavour' of nullity annotations you want, and then lombok will generate them everywhere that it is relevant (toString, equals, canEqual, withX, and plural forms of @Singular properties for a builder). This also covers nullity annotations relevant for issue 2221.

    @cf : https://github.com/projectlombok/lombok/issues/788#issuecomment-579276102

    Lombok's developer seems to have thrown in the towel... He thinks this is a bad idea to generate non null checks on package level...

    @cf: https://github.com/projectlombok/lombok/issues/788#issuecomment-318316538

    Even I'm globally agree that he seems a bad idea to systematically do a non null check, I think you may have legit need and you probably could see how create your own annotation and add it in lombok.config with a CUSTOM:fully.qualified.NonNullAnnotation value in lombok.addNullAnnotations parameter (This feature was added in lombok v1.18.12).

    @cf : Global config keys in https://projectlombok.org/features/configuration

    GLHF ;)