The first argument of Clojure functions corresponding to a method generated by gen-class takes the current object whose method is being called.
(defn -exampleMethod [this]
(println (str this)))
In addition to this, you have to add a :methods
option to gen-class
when you define a method which comes from neither a superclass nor interfaces of the generated class. So a complete example would be as follows.
example.clj
(ns example)
(gen-class
:name com.example.Example
:methods [[exampleMethod [] void]])
(defn- -exampleMethod
[this]
(println (str this)))
REPL
user> (compile 'example)
example
user> (.exampleMethod (com.example.Example.))
com.example.Example@73715410
nil