title: Errors extending a Java Interface in Clojure
body: <p>I have a basic Java interface defined as follows:</p>
  
  <pre class="lang-java prettyprint-override"><code>public interface Action {
      void execute(Metadata var1, Parameter var2);
  }
  </code></pre>
  
  <p>I'm trying to extend it in Clojure but keep getting errors. After importing the class into my namespace, I've tried using <code>reify</code> as follows:</p>
  
  <pre class="lang-clj prettyprint-override"><code>(defn action [action-fn]
    (reify Action
      (execute [metadata parameter] (action-fn metadata parameter))))
  </code></pre>
  
  <p>but that throws a compiler illegal argument exception:</p>
  
  <pre><code>CompilerException java.lang.IllegalArgumentException: Can't define method not in interfaces: execute
  </code></pre>
  
  <p>Next I tried using <code>proxy</code></p>
  
  <pre class="lang-clj prettyprint-override"><code>(defn action [action-fn]
    (proxy [Action] []
      (execute [metadata parameter] (action-fn metadata parameter))))
  </code></pre>
  
  <p>That compiles successfully, and my editor (IntelliJ + Cursive) navigates to the interface definition via a border decoration, but trying to invoke execute on a generate proxy fails:</p>
  
  <pre class="lang-clj prettyprint-override"><code>(.execute (action (fn [_ _] "Test action")))
  </code></pre>
  
  <p>throws the following:</p>
  
  <pre><code>IllegalArgumentException No matching field found: execute for class
  </code></pre>
  
  <p>Finally I tried using deftype as follows:
  </p>
  
  <pre><code>(deftype cljAction [action-fn]
    Action
    (execute [metadata parameter] (action-fn metadata parameter)))
  </code></pre>
  
  <p>which throws the same compiler error as for <code>reify</code>, e.g:</p>
  
  <pre><code>CompilerException java.lang.IllegalArgumentException: Can't define method not in interfaces: execute
  </code></pre>
  
  <p>Trawling through various blog posts and SO answers seems to suggest it's a problem with the arity of arguments, but I'm not sure how to resolve it. What am I doing wrong??</p>