okkero
12/01/2016, 9:37 AMINSTANCE
and get its value:
fun main(args: Array<String>) {
val cls: Class<out A> = A.B::class.java
val a: A = cls.getField("INSTANCE").get(null) as A
a.abc()
}
sealed class A {
abstract fun abc()
object B : A() {
override fun abc() {
println("Hello")
}
}
}
One problem here, though, is that if the Class<out A> variable actually refers to A's class instance, then you'll get an exception.