Hi,
I'm trying embed clojure into a proprietary system.
That system can be configured to create instances of specified Java classes
and calling specified methods.
So I want to use gen-class to create these proxies.
The only problem is that both clojure and my proprietary system handle
class loading differently, so I need to set clojure class loader to that
provided by the system before trying to load any application namespaces.
It would be nice to add an option to gen-class, say :use-system-loader, so
the class created with the following declaration
(gen-class
:name a.b.C
:use-system-loader true)
has code generated in the very beginning of <clinit> method:
clojure.lang.Compiler.LOADER.bindRoot(a.b.C.getClassLoader());
to implement this feature, the following changes have be done th the
genclass.clj:
1. The option name shall be listed among other options
2. The following block shall be added at beginning of the section for
<clinit> method:
(when use-system-loader
(doto gen
(.getStatic (Type/getType clojure.lang.Compiler) "LOADER"
var-type)
(.push ctype)
(.invokeVirtual class-type (Method/getMethod "ClassLoader
getClassLoader()"))
(.invokeVirtual var-type (Method/getMethod "void
bindRoot(Object)"))
))
Regards,
Vladimir
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your
first post.
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en