Call directly ` clojure lang.Compiler. Compile ` to AOT compile clojure from Java

Use clojure lang.Compiler. Is it legal for compile to compile clojure from Java?

Our Java application is used to pass through the interface with proxy macros Use clojure. On the clj source lang.Compiler. Load to create an instance of the clojure object Now we want to use Gen class instead of proxy to AOT compile these objects So you can move Class file, we will instantiate these objects later

The best way I've managed so far is to convince clojure lang.Compiler. Compile generates a loader class file ("my / domain / lib_init. Class") But I didn't seem to get the collateral Class file, one for each function in the namespace ("my / domain / lib $fnname_1234. Class") and stub class file for each Gen class This is used in a sandbox http://clojure.org/compilation The very simple first example of I thought I set the compilation path correctly and set it to something in the classpath, but there may be a problem

In any case, our actual applications are based on RCP (eclipse), which may mean that they will be calculated more according to the OSGi classloader classpath At the same time, I just want to know whether to use clojure directly lang.Compiler. Is compile even an effective method?

Editor: so I now get it all generated Class file, but it requires various unrecorded initialization, which tells me clojure The method on lang. compiler is internal I must set * compile path * and * compile files * to true, for example

RT.var("clojure.core","*compile-files*").bindRoot(true);

Solution

You should try clojure Core / compile function You can also see how lein handles it: AOT param does AOT compilation

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>