How to stop lombok from copying annotations to getters/setters in Eclipse?

Viewed 69

We have a problem with running Lombok > 1.18.18 as an Eclipse Agent (2022-06 or v4.24.0)... it started copying JSR-303 Bean Validation constraints to the setters generated. We were surprised because this isn't backwards compatible; annotating functions that weren't previously annotated definitely is a breaking change :/

This is confusing the Apache BVal implementation (v2.0.5), as normally you wouldn't have both the field and the setter annotated. I actually don't know if the jsr303 spec allows for this, but my guess would be it is an invalid because it doesn't follow DRY principles.

There is a configuration key lombok.copyableAnnotations to control the behavior, but we can't seem to get Eclipse/Lombok to care about it. We put a lombok.config in the project root with this content:

config.stopBubbling = true
lombok.copyableAnnotations =

And it is still copying the annotations:

// output of `javap -v -p -l -constants FileName.class`
  public void setUserName(java.lang.String);
    descriptor: (Ljava/lang/String;)V
    flags: (0x0001) ACC_PUBLIC
    RuntimeVisibleParameterAnnotations:
      parameter 0:
        0: #26()
          javax.validation.constraints.NotNull
    Code:
      stack=2, locals=2, args_size=2
         0: aload_0
         1: aload_1
         2: putfield      #66                 // Field userName:Ljava/lang/String;
         5: return
      LineNumberTable:
        line 43: 0
      LocalVariableTable:
        Start  Length  Slot  Name   Signature
            0       6     0  this   Lcom/xxx/xxx/xxx/xxx/xxx/xxx/LoginPage;
            0       6     1 userName   Ljava/lang/String;
    RuntimeVisibleTypeAnnotations:
      0: #26(): METHOD_FORMAL_PARAMETER, param_index=0
        javax.validation.constraints.NotNull
    MethodParameters:
      Name                           Flags
      userName                       final

Any help preventing this would be much appreciated! Thank you!

EDIT

Original stacktrace:

Caused by: java.lang.ClassCastException: class org.apache.bval.jsr.descriptor.ComposedD$ForProperty cannot be cast to class org.apache.bval.jsr.descriptor.ElementD (org.apache.bval.jsr.descriptor.ComposedD$ForProperty and org.apache.bval.jsr.descriptor.ElementD are in unnamed module of loader java.net.URLClassLoader @1fbc7afb)
    at org.apache.bval.jsr.job.ValidateProperty$DescriptorWrapper.<init>(ValidateProperty.java:159)
    at org.apache.bval.jsr.job.ValidateProperty$FindDescriptor.handleProperty(ValidateProperty.java:219)
    at org.apache.bval.jsr.job.ValidateProperty$WalkGraph.handleProperty(ValidateProperty.java:312)
    at org.apache.bval.jsr.util.PathNavigation$PathPosition.handleProperty(PathNavigation.java:324)
    at org.apache.bval.jsr.util.PathNavigation.parse(PathNavigation.java:218)
    at org.apache.bval.jsr.util.PathNavigation.navigateAndReturn(PathNavigation.java:176)
    ... 86 more
0 Answers
Related