Using Java classes in Kotlin-style


Is there any simple way to use getters like properties? E.g. use exception.message instead of exception.getMessage() ? Only way I can think of is creating intermediate kotlin class with message property, getter calling getMessage() with custom platformName to avoid name clash. Which is a lot of code to get rid of 5 letters ..


Currently this functionality is not supported. We will probably add it later


Subscribe to this issue to receive notifications: KT-400


With Andrey's reply from the mentioned bug, I has been able to create much shorter workaround: val Throwable.message : String   get() = this.getMessage()!! .. along with some namespaces/imports to be able to use it everywhere

Just to be sure - extension functions does not collide with ‘same JVM signature’ accidental override mentioned in M8?


I actually thought this was a feature. You see, Groovy has this feature, but sometimes it clashes with the fact that in Java some "getters" do not actually represent properties e.g.

I can’t find a reference right now, but I do remember someone raising the issue


No, it will be fine.