r/java • u/Purple_Pie4589 • Sep 01 '26
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
View all comments
Show parent comment
2
u/rzwitserloot Sep 04 '26
That is for real, and e.g. reflections (fairly commonly used!) relies on this stuff.
I'm guessing that 95%+ of all java coders wouldn't agree with that characterisation. Specifically, that e.g. "reflections is not java!", especially if that is immediately followed up by an insinuation that 'reflections' is fine, as long as they develop their own compiler, runtime, ecosystem, and so forth. I haven't gone around with a mike, I might be off on my own little cloud, but surely this isn't a contentious view, right?
Anything that captures signals: Unspecced. Relying on streams self-closing resources: Unspecced. Essentially everything about marshalling ('serialization') libraries delves into unspecced territory and with it, 95%+ of all java-written web apps which uses something along those lines. For a very long time: The very command line switches of the
javactool: Unspecced.And if we add on top of the pile: Specced behaviour, but where the spec is from a source other than the JLS, the next VM release is as likely to break that. For example, the simple idea of 'annotation processors on the classpath during compilation are automatically invoked': That was more or less 'specced', but you had to read between the lines. Casually broken in a recent JVM release, so I guess those kinds of between the lines specs should be treated as Unspecced for the purposes of 'Is not java!'.