Clojure: How to create a Java Object at Compile time, but not Load Time or Run Time

222 Views Asked by At

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.

0

There are 0 best solutions below