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

后端 未结 5 1062

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:55

    With Java 7 you can get a reference to the current Java class from a top level function using

    MethodHandles.lookup().lookupClass()
    

提交回复
热议问题