Serge
11/08/2018, 9:51 PMval o = object{}
val mm = o.javaClass.declaredMethods
but it doesn't return anything. is it possible at all? if so, would the function modifier affect this search (private, public, etc)?diesieben07
11/08/2018, 10:13 PMSerge
11/08/2018, 10:26 PMpackage temp.test
and few functions in it. how this would look like then? I don't have any class declareddiesieben07
11/08/2018, 10:30 PMjava.lang.Method
and then call getDeclaringClass
. However this is a hack and not guaranteed to work in the future.Serge
11/08/2018, 10:51 PMfun main(args: Array<String>) {
val o = object{}
val kc = o::class
val jc = o.javaClass }
unfortunatelydiesieben07
11/08/2018, 10:55 PMfoo
and bar
in com.example
package.
Then you can do ::foo.javaMethod!!.declaringClass.declaredMethods
.
However that would only list the functions declared in that same .kt file.@Metadata
annotation and could be used to obtain more kotlin-esque information about the function (not just Java reflection methods)Serge
11/09/2018, 4:35 PM::main.javaMethod!!.declaringClass.declaredMethods.filter { it.name.startsWith("foo") }.map {it-> it.name}
diesieben07
11/09/2018, 4:36 PM