I'm trying to use gen-class to override the compare(WriteableComparable a, WriteableComparable b) method in this class in clojure. The complication comes from the fact that this method is overloaded 3 times:
int compare(WritableComparable a, WritableComparable b)int compare(Object a, Object b)int compare(byte[] b1, int s1, int l1, byte[] b2, int s2, int l2)
So far my attempt looks like this:
(gen-class
:name comparators.MyWriteableComparator
:extends org.apache.hadoop.io.WritableComparator
:exposes-methods {compare superCompare}
:prefix "interop-")
(defn interop-compare
([this a b c d e f]
(.superCompare this a b c d e f))
([this ^WritableComparable w1 ^WritableComparable w2]
(.compareTo (.getSymbol ^SymbolPair w1)
(.getSymbol ^SymbolPair w2))))
Everything compiles, but when I run it, I'm getting a null pointer exception, and I suspect that it is because I overrode the wrong method (i.e. the compare(Object a, Object b) instead of the intended compare(WritableComparable a, WritableComparable b)). For reference, the Object version of compare calls through to the WriteableComparable version.
It's totally possible that the NPE is coming from something else, but I've at least narrowed it down to this clojure code (when I run it with the corresponding Java version, things work well).
Is there a way to specify which overloaded version of the method should be used?
(I tried adding a :methods clause into the gen-class call, but I learned that one should declare only new methods, not superclass methods.)