 ;; java interface
 ;;TODO
 
-(defn method-args-of [m]
-  `~(:arglists m))
-
-(defn method-of [m]
-  `(~(:name m) ~@(method-args-of m))
-  )
+
+
+(defn method-decl-of [fn-map]
+  (let [n (:name fn-map)]
+    `[~n ~@(map #(mapv (fn [_] 'Object) %) (:arglists fn-map)) ~'Object]
+    ))
+(defn method-name-of [n]
+  (symbol (str "-" n)))
+
+(defn method-overload-of [name args]
+  ;(break!)
+  `(~(-> args rest vec) (~name ~@args)))
+
+(defn method-impl-of [fn-map]
+  (let [n (:name fn-map)]
+    `(defn ~(method-name-of n) ~@(map (partial method-overload-of n) (:arglists fn-map)))))
 
 (defmacro def-java-api []
-  `(definterface IBtcRpc
-     ~(map method-of (btc-meta))
-     )
-  )
+  `(do 
+     (gen-class
+       :name bitcoinrpc.BtcJava
+       :state ~'config
+       :methods ~(mapv method-decl-of (btc-meta))
+       :init ~'init
+       :constructors {[java.util.Map] []})
+          
+     ~@(map method-impl-of (btc-meta))
+     (defn ~'-init [config#]
+       [[] config#])))
+;(def-java-api)
+
+
+  
 
 ;;---------------socket repl-------------------------------
 

(ns bitcoinrpc.core
  (:use [clojure.pprint])
  (:require [clojure.data.json :as json]
            [instaparse.core :as insta]
            [clj-http.client :as client]

            [clojure.set :refer [subset?]]
            [clojure.core.server :as sock-repl]
            [clojure.main :as m]
            [com.gfredericks.debug-repl :refer [break! unbreak!]]
            ))

(defmacro dbg [body]
