I’m trying to understand how Kotlin selects which java constructor to call based on the arguments passed.
I’m trying to call org.json.
JSONObject(java.util.Map map) constructor from kotlin, but fail to do so. Everything I try and pass the constructor ends-up calling the
For example, I would expect the following sample code to call the map constructor, but it does not :
val javaMap = java.util.HashMap<String, Object>() javaMap.put("hello", "world" as java.lang.Object) val jsonObject = JSONObject(javaMap as Map<String, Object>)
Is this the expected behavior ? What way would I have to explicitly call the map constructor (other than reflection) ?
I’ve put up a small git repos with a test that demonstrate my issue : https://github.com/jvelo/kotlin-java-constructors
Thanks in advance.