Created
March 6, 2013 17:04
-
-
Save timmc/5100962 to your computer and use it in GitHub Desktop.
Compiling Java against a class with abstract methods
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; 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 | |
*compile-path* | |
;;=> "/home/timmc/tmp/clj/target/classes" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// In /home/timmc/tmp/clj/ | |
public class Test { | |
public static void main(String[] args) { | |
System.out.println(new clj.core$eval1062$reify__1063().size()); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# In /home/timmc/tmp/clj/ | |
javac -cp target/classes/ Test.java | |
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