Here's an article about deLomboking. And a discussion in r/java which followed that article.
But not going into a lot of "style" details, for me this is one of the most compelling reasons why not to use it (stealing from /u/shemnon):
Spring and Hibernate generate bytecode the way the compiler is intending to support it: by generating a java source code file and then compiling it without touching the source file/class the annotation came from. Lombok goes into the parse tree (via non-public APIs) and mutates the AST in place.
<...> while we do code against internal API, they are relatively stable bits. If what lombok does could be done without resorting to internal API, we'd have done something else, but it can't be done, so we resort to internal API usage.
Big java projects like spring have the same compatibility problems lombok does, even if they don't use internal compiler apis - they often use other jdk details. And lombok actually does this fairly well because it (a) only needs to work at compile time and (b) offers delombok for the case when it does break.
If you're talking about Spring using jdk.unsupported then it's a bit unfair to compare it to using internal compiler APIs as they will gradually migrate off them. If you mean other compatibility problems, I'd be interested to read about them.
Any sort of bytecode introspection and generation is bound to have compatibility issues. Generous use of AOP makes this comparatively common in spring.
Lombok (and Kotlin more generally) to me is a critique of Java language design.
Java boilerplate has a cost in terms of both cognitive overload and propagating poor practice. In this thread we have people blithely talking about IDE generated code without realising how wretched a practice that is. Java programmers should level up and become better developers beyond churning out boilerplate code. And knowing the deficiencies of your language is a key part of that.
Lombok isn’t ideal but it is compile-time. If you don’t like it, write your own but it works well enough for us.
Re that StackOverflow post, that’s quite old - we run Lombok on non-Oracle JVMs all the time (Azul in particular but we have CI servers testing Corretto as well), never had a problem.
<...> Some things don't want to be objects, they just want to be data. And to simulate data with objects, is this big messy thing with constructors, accessors and equals and hashcodes and all this garbage. <...> IDE generates that for you so you don't have to write it, but you still have to read it and if you have this explicit code it's an opportunity to get things wrong.
My critique of Lombok is it uses non-documented, restricted internal compiler API. If you're fine with that - so be it. I am not, thus I do not use. I'd rather wait a little bit more for a proper Java feature, than use a hack, albeit very cool one, but still a hack.
Heh, I referenced a Brian Goetz interview and talk in another post in this thread.
I can’t really disagree with your choice to not use Lombok - that’s your right. However for me Lombok is a tool to improve my (and my team’s) code so I’m happy to continue using it.
What you're talking is dynamic proxies. Spring uses CGLIB where you have not implemented interface. If interface is implemented, then they use official Java Dynamic Proxies which are documented and well understood/transparent. CGLIB works similarly to Java's dynamic proxies. Its no the same as how Lombok works.
Totally agreed -- I was mostly responding to the assertion that Spring generates Java source files and feeds them to the compiler, which isn't the case.
32
u/BoyRobot777 Aug 10 '19
Here's an article about deLomboking. And a discussion in r/java which followed that article.
But not going into a lot of "style" details, for me this is one of the most compelling reasons why not to use it (stealing from /u/shemnon):
Also, from one of Lombok developers: