r/java • u/artpar • Oct 05 '23
How does the lombok magic work underneath?
https://www.unlogged.io/post/how-does-the-lombok-magic-work-underneath
133
Upvotes
r/java • u/artpar • Oct 05 '23
View all comments
Show parent comment
30
u/nekokattt Oct 05 '23 edited Oct 05 '23
They never said it was not open source, they said it was encapsulated (i.e. behind closed JPMS modules like jdk.compiler) whereby you can see the code but the JVM prevents reflective access to it at runtime when the Java compiler is invoked. Some projects use --add-opens and --add-exports for now but there is a good chance this will be removed in the future. OpenJDK devs are not scared of breaking things that are considered bad practise to do. They are planning on deprecating the ability to dynamically attach JVM agents too, which will mean changes are needed in components like Surefire for Mockito to continue working in the future.
Same reason spotbugs broke for a while on Java 17 a year or two ago, that was accessing components within jdk.compiler that are not documented for external usage.
Manifold framework is also in the same boat for this.
IMO pointing out that something is potentially volatile in a changing environment is not FUD. It may be an over-cautious observation, but unless the Lombok devs are also part of the core language design discussions that OpenJDK have, then there is no guarantee it will always be able to work in the way it currently does.
Like any library, it is a very small risk. A risk that is increased slightly due to the use of APIs that clearly have javadocs that say something along the lines of "this API is for internal use and may break/change/go away without warning".
It is similar to apps that make use of kernel32.dll on Windows. Sure, you can see what is in it, but it doesn't mean the API inside is guaranteed to remain as-is.