For the benefit of others, since this took me a while to understand...

When using gen-class to extend or implement a superclass with
overloaded methods, use a single multi-arity function to override the
overloaded methods in the superclass:

expmeth/ClassA.java:
package expmeth;
public class ClassA {
    public void hello() {
        System.err.println("hello from Java!");
    }
    public void hello(int x) {
        System.err.println("hello from Java " + x);
    }
}

expmeth/TestMe.clj:
(ns expmeth.TestMe
  (:gen-class
   :extends expmeth.ClassA
   :exposes-methods {hello helloSuper}))
(defn -hello
  ([this]
     (.helloSuper this)
     (println "hello from clojure!"))
  ([this x]
     (.helloSuper this x)
     (println "hello from clojure..." x)))

testing:
(.hello (expmeth.TestMe.) 17)
(.hello (expmeth.TestMe.) )
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to 
clojure+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to