Extract KFunction
from Method
/ Constructor
of Java
.
You can do this by calling the following Method.kotlinFunction
/ Constructor <T> .kotlinFunction
from Java
.
Specifically, it is as follows.
KFunction<?> function = ReflectJvmMapping.getKotlinFunction(Foo.class.getConstructors()[0]);
Since the generic type parameter is often not set to get the Method
/ Constructor
from the Class
, if you want to include the type parameter, you need to cast it in Java
.
KFunction<Foo> function = ReflectJvmMapping.getKotlinFunction((Constructor<Foo>) Foo.class.getConstructors()[0]);
Recommended Posts