Class.forName doesn’t work for nested classes?


Hi, I’m using a Java library (Kafka Streams) that internally uses Class.forName to get a class reference to an inner class.

Maybe I’m missing something, but it seems like maybe Kotlin doesn’t support this?

I tried this in the REPL:

>>> Class.forName("java.util.Map$Entry")
error: unresolved reference: Entry

and then I tried it in a Clojure REPL:

user=> (Class/forName "java.util.Map$Entry")

Am I missing something? Or is this a bug?

I’m using kotlinc-jvm 1.1.4-3 (JRE 1.8.0_141-b15) on MacOS 10.12.6 (Darwin 16.7.0).



As described in the documentation the $ character is used in Kotlin for string templates. You need to escape it in this case.




@yole @madmax1028 thanks so much!