Hey guys, I'm trying to convert a method reference...
# reflect
g
Hey guys, I'm trying to convert a method reference like
SomeClass::main
into a classname for a
java -mainClass
argument. This is the best I've got
Copy code
private val KFunction<*>.instanceTypeName: String get() {
    return ((this as FunctionReference).boundReceiver::class as KClass<*>).jvmName
}
usage:
Copy code
val mainClass: String = (MyType::main).instanceTypeName
is there a better solution?
b
Why not just do it off of
MyType::class.jvmName
?
g
just so that the
main
function has a user
u
FunctionReference
is an internal API, so please don’t use it Instead, you can use
instanceParameter!!.type.jvmErasure.jvmName