I'm trying to write a Clojure library that can be used from Java without users knowing it is written in Clojure. For this, I need my fields to have proper types:
I like that I can do this:
(deftype Point [^double x ^double y])
Which generates a class with proper types for x/y. However, this only seems to work for primitives, not for classes:
(deftype Foo [^String bar])
Generates a:
public final Object bar;
where I would expect a:
public final String bar;
Is there a way to constrain the field types? Is there another option outside of deftype
/defrecord
?