Search code examples
javadoclombok

Unable to generate JavaDoc on lombok setters/getters with onmethod attribute


I am attempting to generate JavaDoc for a project that leverage lombok and having problems for a situation where I am annotations on the generated setters and getters.

Code:

public class Car {
  @Getter(onMethod = @__(@Sensitive))
  @Setter(onMethod = @__(@Sensitive))
  @Sensitive
  @ToString.Exclude
  @Transient
  protected transient String instanceKeyId;

And, I am running:

mvn javadoc:attach-javadocs

When I do that, I get this error:

[ERROR] Exit code: 1 - Car.java:26: error: cannot find symbol
[ERROR]   @Getter(onMethod = @__(@Sensitive))

I am on Java 11 - my projects do build and run. I have the latest version of the javadoc plugin, am I missing something else here?

It sounds like I need to heed the advice here 1 and setup delombok and then do javadoc on that which seems a bit extraneous. Is that the required workflow here, or is there another way to do this?


Solution

  • The short answer is: No, at best you can script this, for example with a plugin in your build system that first delomboks and then javadocs.

    Is there hope for the future? The onMethod bit of lombok is an unfortunate hack, working around bugs in javac (bugs which the oracle dev team does not acknowledge, so they are unlikely to ever be fixed, and there's no TCK rule to prove them; the TCK is rather light on annotations in general). Team lombok also attempted to address this by adding the 'any annotation' feature as a really tiny upgrade to the java lang spec but it was rejected for unclear reasons (specifically, the reason: There is no time left (this was before the new 6 months cadence), even though the multi annotation feature was proposed and built later, proving that was an incorrect reason. If I had to guess, the reason is 'nobody within oracle finds this important').

    NB: I did manage to talk to a few openjdk engineers so perhaps anyannotation may make it one day at which point odds would go up significantly that you can avoid the two-step workflow, but we're still talking JDK15 at the very earliest, and given the frustrating way things went the last time we (core contributors to Project Lombok) attempted to include a small feature in java itself, not sure trying again is a good way to spend contributor time.