1

I'm using a java library with Clojure. The java library requires an object to be created at compile-time only. When the app is deployed via an uberjar (created with leiningen), this configuration object cannot be created properly without an error.

I can create the object at compile-time-only via a macro. The problem is that it is not Serializable. How do I make this object available to the jvm when the app is run via the uberjar? Putting the object into an atom doesn't work, because the atom is reset at load time / run time for the new jvm instance that is running the jar. The compile-time jvm needs a way to put this object into one of the aot compiled classes. (gen-class) doesn't seem to work because it can only initialize state at runtime via an initializer.

  • What stops you from creating that one particular object in java? Also, have a look at proxy (http://clojuredocs.org/clojure_core/1.2.0/clojure.core/proxy) it sounds like this does what you need, though without further explanation is hard to tell. How about pasting some of your java code? – dsm Apr 08 '14 at 21:51
  • There is nothing here indicating he has any Java code. I think that an "object" as such is specific to a vm, and as such you really need to create the object in each vm that wants to use it. So the real problem is why the Object can't be made at runtime. – noisesmith Apr 08 '14 at 23:32

0 Answers0