title: Accessing Kotlin extension functions from Java
body: <p>Is it possible to access extension functions from Java code?</p>
  
  <p>I defined the extension function in a Kotlin file.</p>
  
  <pre><code>package com.test.extensions
  
  import com.test.model.MyModel
  
  /**
   *
   */
  public fun MyModel.bar(): Int {
      return this.name.length()
  }
  </code></pre>
  
  <p>Where <code>MyModel</code> is a (generated) java class.
  Now, I wanted to access it in my normal java code:</p>
  
  <pre><code>MyModel model = new MyModel();
  model.bar();
  </code></pre>
  
  <p>However, that doesn't work. <strong>The IDE won't recognize the <code>bar()</code> method and compilation fails.</strong> </p>
  
  <p>What does work is using with a static function from kotlin:</p>
  
  <pre><code>public fun bar(): Int {
     return 2*2
  }
  </code></pre>
  
  <p>by using <code>import com.test.extensions.ExtensionsPackage</code> so my IDE seems to be configured correctly.</p>
  
  <p>I searched through the whole Java-interop file from the kotlin docs and also googled a lot, but I couldn't find it.</p>
  
  <p>What am I doing wrong? Is this even possible?</p>