Accessing Java properties - .getFoo() vs .foo?


It appears that the Kotlin compiler generates methods for var and val properties with the usual Java naming conventions -- getFoo, setFoo, but you can access these as in Kotlin. The same does not work for Java -- if a Java class has a property foo, I need to get it with obj.getFoo().  Is this correct? Or is there a way to use the syntax for Java objects?



Currently there's no property-like syntax for Java getter/setter pairs. We are looking for ways of supporting it.

All you can do for now is define your own extension property for every Java property:

var Int   get() = this.getBar()   set(v) { this.setBar(v) }

// usage:
println( = 1