Modern Java does not use JavaBeans getter name conventions (at least for Record types). Is there any compiler option or compiler plugin, so that all getters names be generated w/o noisy get-prefix: I want size(), not getSize() for all classes. As you understand JvmName is not an option at all as it is terribly verbose and noisy. Per-class annotation would be better (if there is one), but global compiler option would be even better…
This is not exactly what you ask, but note that if you use recent Java versions then you can annotate a data class with @JvmRecord. Then it will behave as you expect.
I don’t use Java for almost 3 years, so I’m not up to date with it. Is there really a shift towards names like foo()
instead of getFoo()
, even for regular classes? Or is it only for records? Because I think the latter does not imply that we should use this everywhere.
Many Java libs use this no-get convention for eternity such as Netty and even java collections itself. Such convention makes properties much less needed because size() vs size is not too bad (but getSize is verbose garbage!). Of course, I could use funs instead of vals for such getters - but that would be not very Kotlin-style.