Search code examples
javaeclipselombok

Eclipse doesn't copy Lombok's @Delegate from record to generated class


Eclipse fails to propagate Lombok's @Delegate annotation from a record to the generated class so I end up with an error on my IDE.

For context: gradle's compileJava task is totally ok. Also ok if I turn the record into a class. Seems like it's Eclipse being picky.

Is this an Eclipse bug? (If so, where can I report it?)

Is there any way this can be solved by tweaking Eclipse preferences?

Code example:

// Bob.java
public class Bob {
  public String getStuff() {
    return "stuff";
  }
}

// BetterBob.java
public record BetterBob(@Delegate Bob bob) {}

// Main Code
public class BobApp {
  public static void main(String[] args) {
    BetterBob bb = new BetterBob(new Bob());
    bb.getStuff(); // <-- The method getStuff() is undefined for the type BetterBob
  }
}

Eclipse version: 2024-12 (4.34.0)

Lombok v.1.18.36 "Envious Ferret"

Java 21.0.6.7-hotspot


Solution

  • Thanks @howlger for answering in the comments. Basically:

    Is this an Eclipse bug?

    No. It's a Lombok bug. Reported at https://github.com/projectlombok/lombok/issues/3830.

    Is there any way this can be solved by tweaking Eclipse preferences?

    No.