jeudi 18 novembre 2021

Kotlin - Get static functions with reflection

I was using this piece of code to map all static functions of a Java class to stuff:

fun staticsFromClass(clazz: Class<*>): List<Something> = clazz.methods
        .filter { method -> Modifier.isStatic(method.modifiers) }
        .map { method ->
           //something
        }

but I found out it only works on Java code. It filters out companion object functions and singleton object functions. How can I fix it?





Aucun commentaire:

Enregistrer un commentaire