Interoperability issues between Java and clojure. Please refer to this document on the clojure official website.
The following materials and examples are from the above document.
Overall, operating Java from clojure is much easier and more convenient. If you want to use Clojure to implement a Java class, it will be a little more troublesome to let Java call it. There is a section in the above document that explains that the method is not pre-compiled:
Use clojure.java.api.Clojure to call clojure functions. For example:
IFn plus = Clojure.var("clojure.core", "+");
plus.invoke(1, 2);
My own experience is that this operation is enough. Generally, a pure static class in Java without instance methods is designed to encapsulate the above functions and provide type information.
Another method is to use aot, which is a bit more complicated. There is a Maven plugin that does this. I haven't used it myself.
Interoperability issues between Java and clojure. Please refer to this document on the clojure official website.
The following materials and examples are from the above document.
Overall, operating Java from clojure is much easier and more convenient. If you want to use Clojure to implement a Java class, it will be a little more troublesome to let Java call it. There is a section in the above document that explains that the method is not pre-compiled:
Use
clojure.java.api.Clojure
to call clojure functions. For example:My own experience is that this operation is enough. Generally, a pure static class in Java without instance methods is designed to encapsulate the above functions and provide type information.
Another method is to use aot, which is a bit more complicated. There is a Maven plugin that does this. I haven't used it myself.