title: Get class reference from top level function in kotlin
body: <p>I wrote a short program which does not require any classes and in turn consits of top level functions only.</p>
  
  <p>To find your jar's location from java code you write</p>
  
  <pre><code>MyClass.class.getProtectionDomain().getCodeSource().getLocation().toURI().getPath()
  </code></pre>
  
  <p>But as I did not declare any classes in my kotlin code I don't know how to get a class reference.  </p>
  
  <p>My current implementation is this</p>
  
  <pre><code>class Ref
  val jarPath = Ref::class.java.protectionDomain.codeSource.location.toURI().path
  </code></pre>
  
  <p>which is obviously very bad code.</p>
  
  <p>So my question is, how do I obtain a class reference in kotlin without declaring any unneccesary classes.
  Any hints appreciated :)</p>