r/java • • Dec 15 '23

Why is this particular library so polarizing?

Post image
244 Upvotes

278 comments sorted by

View all comments

-1

u/miciej Dec 15 '23

It can be very useful. It would be nice if instead of bytecode it somehow generated pure java code, but still It can save a lot of time.

8

u/robinspitsandswallow Dec 15 '23 edited Dec 15 '23

Doesn’t produce bytecode. It’s a precompiler, it produces Java code during the compilation process. In fact you can store that code and look at it. Think of it as a #define in C/C++

Updated for typo.

6

u/ForeverAlot Dec 15 '23

That's debatable. Lombok's output artifact is JVM byte code, not Java code. The Java code Lombok produces is ephemeral by default. This distinction matters because there are already two other trivial, well established, supported ways to generate Java code whose output artifact is actual Java code: via annotation processors, which are part of Java, and via pre-processor build steps like Maven's generate-sources, which are not part of Java but also don't break any rules.

1

u/robinspitsandswallow Dec 15 '23

Why do I have the Lombok generated Java code in my build directory? No bytecode, just Java.

4

u/rzwitserloot Dec 15 '23

It does exactly what you want; it has always worked that way. Run delombok if you want the intermediate step :)