开发者

Generating Java Classes

I understand that one can use gen-class to generate a java class, however, I'm confused as to how I can开发者_开发问答 generate a java class with constructors. Is it possible to generate a java class with a constructor, that does not extend or implement another class?


I just generated following class with constructor:

(ns test.t1
  (:import (java.util HashMap))
  (:gen-class
   :main false
   :state state
   :init init
   :constructors {[java.util.HashMap] []}))
(defn -init [^HashMap tmapref]
  [[] tmapref])

and I able to create instance of it:

user> (test.t1. (java.util.HashMap.))
#<t1 test.t1@7d6ac92e>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜