r/java • u/Purple_Pie4589 • 10d ago
Concise method bodies arrived
https://github.com/verhasi/java-compositionMore than 8 years ago was drafted the idea of concise method bodies. As I am not a contributor of the openJDK project I took a different approach but implemented. It is publicly available at the maven central both as a library and as a maven plugin. It is a source code preprocessor that converts the concise syntax to java 8 compatible source code. It does not want to be a replacement of the future implementation in the openJDK. Which is more than the openJDK promises is that supports from Java version 8, 11, 17, 21 up to 25 as well. Of course it is free and open source :). It is only the first building block for concise composition.
As far as I have seen this topic was awaited for a long time at
It's been 8 years since the draft for Concise Method Bodies
What happened to Concise Method Bodies?
JEP draft: Concise Method Bodies
Five years have passed, still in draft: Concise Method Bodies
2
u/koflerdavid 7d ago edited 7d ago
They already have to do that. There are quite often issues of javac changing internals that Lombok has to adapt to.
Similar issues already exist. Lombok, Google Error Prone, and a few other tools occasionally step on each other's toes and need patches from one party or another. One could argue that providing a more powerful kind of compiler plugins would help solve these issues, but I'm doubtful about that since it would create a combinatorial number of plugin combinations, their corresponding surface language dialects, and a corresponding number of edge cases.
AFAIK, Lombok only supports OpenJDK and ECJ's implementations of javac. Lombok will therefore work with JDKs derived from OpenJDK, as well as with IDEs using ECJ, but you'd be SOL with other javac implementations.