Hi, basic Kotlin Reflection question to call a sta...
# getting-started
k
Hi, basic Kotlin Reflection question to call a static function. I have a function test() defined in Test.kt:
Copy code
package com.test.test

fun test() {
    // Do some stuff
}
How can I call the function test() using Kotlin reflection
h
Just like in Java:
Copy code
Class.forName("com.test.test.TestKt").getDeclaredMethod("test").invoke(null);
The
TestKt
comes from your filename
k
Yes, I thought that I need to use "`KClass*.companionObject" to invoke the static method.` Indeed just do it with the Java way, thanks!