Is there a way to reference the Java class for a Kotlin top-level function?

后端 未结 5 1058

I want to load a resource in a top level function using Class.getResourceAsStream().

Is there any way to get a reference to the class that the top level

5条回答
  •  既然无缘
    2020-11-29 09:44

    In the absence of a way to get a reference directly, I've fallen back on creating an anonymous object in the current package

    val myThing = object: Any() {}.javaClass.getResourceAsStream(...)
    

提交回复
热议问题