Created
September 27, 2017 00:04
-
-
Save nfisher/94f31de6728e149ea45ae2b4e0328fdb to your computer and use it in GitHub Desktop.
Call clojure FN from JAR file
This file contains hidden or 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
public class Call { | |
public void printPlus() { | |
final ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); | |
final Class c = Class.forName("clojure.lang.RT", true, classLoader); | |
final Method method = c.getDeclaredMethod("var", String.class, String.class); | |
Object var = method.invoke(null, "clojure.core", "+"); | |
Class<?> varClass = var.getClass(); | |
final Method plus = varClass.getDeclaredMethod("invoke", Object.class, Object.class, Object.class); | |
System.out.println(plus.invoke(var, 1, 2, 3)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment