Is it possible to reference MainKt file?

Let’s say I have a file main.kt with a single function main. This file compiles to MainKt.class file containing MainKt class. Is it possible to get a java.lang.Class for this class from Kotlin code? E.g. to load resources or get classloader instance. Of course I can easily create dummy class and use it as an anchor, but is it possible to do it without that dummy class? I tried to reference MainKt or my.pckg.MainKt, but neither option works.

No, that’s currently not possible. The workaround is to define a class that you can use as “anchor”. See discussion here.