I guess I don't understand. In the Clojure code below, the double
arity method does in fact override all three of the methods from the
superclass (two of which have the same name and same arity). Isn't
that what you're looking for? Try it out.
|-- build.xml
|-- go.clj
|-- src
| `-- expmeth
| |-- ClassA.java
| `-- TestMe.clj
$ cat src/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. int: " + x);
}
public void hello(String x) {
System.err.println("hello from Java. string: " + x);
}
}
$ cat src/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)))
$ cat go.clj
(import '(expmeth TestMe))
(.hello (TestMe.))
(.hello (TestMe.) 7)
(.hello (TestMe.) "woo")
$ cat build.xml
<project name="expmeth" default="jar" basedir=".">
<property name="src.home" location="src"/>
<property name="build.home" location="build"/>
<property name="jarfile" location="expmeth.jar"/>
<available property="hasclojure" file="${clojure.jar}"/>
<path id="compile.classpath">
</path>
<target name="init">
<mkdir dir="${build.home}"/>
</target>
<target name="compile" depends="init">
<javac srcdir="${src.home}" destdir="${build.home}" debug="on"
includes="**/*.java" deprecation="on" target="1.5"
source="1.5">
<classpath refid="compile.classpath"/>
<compilerarg line="-Xlint:-path"/>
</javac>
</target>
<target name="compile-clojure" depends="compile">
<java classname="clojure.lang.Compile">
<classpath>
<pathelement location="${build.home}"/>
<pathelement location="${src.home}"/>
<path location="${clojure.jar}"/>
</classpath>
<sysproperty key="clojure.compile.path" value="${build.home}"/>
<arg value="expmeth.TestMe"/>
</java>
</target>
<target name="jar" depends="compile-clojure">
<jar jarfile="${jarfile}">
<fileset dir="${src.home}" includes="**/*.clj"/>
<fileset dir="${build.home}" includes="**/*.class"/>
</jar>
</target>
<target name="clean" description="cleanup">
<delete dir="${build.home}"/>
<delete file="${jarfile}"/>
</target>
</project>
$ ant
$ java -cp build:/home/kreg/src/clojure/clojure.jar clojure.main
go.clj
hello from Java!
hello from clojure!
hello from Java. int: 7
hello from clojure... 7
hello from Java. string: woo
hello from clojure... woo