r/java 17h ago

Concise method bodies arrived

https://github.com/verhasi/java-composition

More 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

38 Upvotes

27 comments sorted by

View all comments

12

u/piesou 15h ago

I still can't get over picking "final var" over "val"

1

u/koflerdavid 13h ago

Google Error Prone's Var rule resolves that, and more.

2

u/piesou 13h ago

Thanks. This sounds similar to what you want when Nullable types release (and you'll have to mark everything explicitly as non null.

2

u/TOMZ_EXTRA 3h ago

There are plans to add something like not-nullable-by-default to modules IIRC.

1

u/piesou 17m ago

In the compiler or a separate library?