Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Compiling Java against a class with abstract methods
;; Spit reified class to disk
(alter-var-root #'*compile-files* (constantly true))
;;=> true
;; Create an abstract-ish class
(class (reify java.util.List (size [this] 10)))
;;=> clj.core$eval1062$reify__1063
;; Nope, it's not an "abstract class"
(java.lang.reflect.Modifier/isAbstract (.getModifiers clj.core$eval1062$reify__1063))
;;=> false
;;=> "/home/timmc/tmp/clj/target/classes"
// In /home/timmc/tmp/clj/
public class Test {
public static void main(String[] args) {
System.out.println(new clj.core$eval1062$reify__1063().size());
# In /home/timmc/tmp/clj/
javac -cp target/classes/
mv Test.class target/classes/
java -cp target/classes/:/home/timmc/.m2/repository/org/clojure/clojure/1.4.0/clojure-1.4.0.jar Test
#=> 10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment