Hi, I’m getting compile errors when trying to invoke a public Java method with the same name as a private property in the same class (specifically, entrySet
in java.util.concurrent.ConcurrentSkipListMap
). Here’s a full example:
package com.andrewberls.cslm
import java.util.concurrent.ConcurrentSkipListMap
object Main {
@JvmStatic
fun main(args: Array<String>) {
val m = ConcurrentSkipListMap<String, String>()
m.put("foo", "bar")
println(m.entrySet())
}
}
This fails to compile with the error:
e: /Users/andrew/code/cslm/src/main/kotlin/com/andrewberls/cslm/Main.kt: (10, 19): Expression 'entrySet' of type 'java.util.concurrent.ConcurrentSkipListMap.EntrySet<kotlin.String!, kotlin.String!>!' cannot be invoked as a function. The function invoke() is not found
e: /Users/andrew/code/cslm/src/main/kotlin/com/andrewberls/cslm/Main.kt: (10, 19): Cannot access 'entrySet': it is 'private' in 'ConcurrentSkipListMap'
:compileKotlin FAILED
Looking at the j.u.c source, it appears that entrySet is both a private transient
property and a public method.
I’m on Kotlin 1.0.0, Java 8.
Thanks!