ここで説明されているアプローチを使用しようとすると、最終的に次の単純化された絞り込みコードにたどり着きましたが、それでも例外が発生します。
import clojure.lang.RT;
public class FooMain {
public static void main(String [] args) {
RT.var("clojure.core", "read-string").invoke("(+ 1 2)"); // line-6
}
}
投稿の最後に追加するトレースで実行時に失敗します。Clojure 1.4 または 1.5 Ivy deps で試してみました。
<dependency org="org.clojure" name="clojure" rev="1.4.0"/>
また:
<dependency org="org.clojure" name="clojure" rev="1.5.1"/>
痕跡
run:
[echo] ant.java.version=1.7
[echo] running the app with classpath = /home/mperdikeas/esavo-reg/playground/calling-clojure-from-Java/lib-ivy/clojure-1.4.0-javadoc.jar:/home/mperdikeas/esavo-reg/playground/calling-clojure-from-Java/lib-ivy/clojure-1.4.0-sources.jar:/home/mperdikeas/esavo-reg/playground/calling-clojure-from-Java/lib-ivy/clojure-1.4.0.jar:/home/mperdikeas/esavo-reg/playground/calling-clojure-from-Java/dist/foo.jar
[java] java.lang.ExceptionInInitializerError
[java] at org.apache.tools.ant.taskdefs.ExecuteJava.execute(ExecuteJava.java:194)
[java] at org.apache.tools.ant.taskdefs.Java.run(Java.java:771)
[java] at org.apache.tools.ant.taskdefs.Java.executeJava(Java.java:221)
[java] at org.apache.tools.ant.taskdefs.Java.executeJava(Java.java:135)
[java] at org.apache.tools.ant.taskdefs.Java.execute(Java.java:108)
[java] at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:291)
[java] at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)
[java] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[java] at java.lang.reflect.Method.invoke(Method.java:601)
[java] at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
[java] at org.apache.tools.ant.Task.perform(Task.java:348)
[java] at org.apache.tools.ant.taskdefs.Sequential.execute(Sequential.java:68)
[java] at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:291)
[java] at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)
[java] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[java] at java.lang.reflect.Method.invoke(Method.java:601)
[java] at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
[java] at org.apache.tools.ant.Task.perform(Task.java:348)
[java] at org.apache.tools.ant.taskdefs.MacroInstance.execute(MacroInstance.java:398)
[java] at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:291)
[java] at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)
[java] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[java] at java.lang.reflect.Method.invoke(Method.java:601)
[java] at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
[java] at org.apache.tools.ant.Task.perform(Task.java:348)
[java] at org.apache.tools.ant.Target.execute(Target.java:390)
[java] at org.apache.tools.ant.Target.performTasks(Target.java:411)
[java] at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1399)
[java] at org.apache.tools.ant.Project.executeTarget(Project.java:1368)
[java] at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
[java] at org.apache.tools.ant.Project.executeTargets(Project.java:1251)
[java] at org.apache.tools.ant.Main.runBuild(Main.java:809)
[java] at org.apache.tools.ant.Main.startAnt(Main.java:217)
[java] at org.apache.tools.ant.launch.Launcher.run(Launcher.java:280)
[java] at org.apache.tools.ant.launch.Launcher.main(Launcher.java:109)
[java] Caused by: java.lang.ExceptionInInitializerError
[java] at java.lang.Class.forName0(Native Method)
[java] at java.lang.Class.forName(Class.java:266)
[java] at clojure.lang.RT.loadClassForName(RT.java:2056)
[java] at clojure.lang.RT.load(RT.java:419)
[java] at clojure.lang.RT.load(RT.java:400)
[java] at clojure.lang.RT.doInit(RT.java:436)
[java] at clojure.lang.RT.<clinit>(RT.java:318)
[java] at FooMain.main(FooMain.java:6)
[java] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[java] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
[java] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[java] at java.lang.reflect.Method.invoke(Method.java:601)
[java] at org.apache.tools.ant.taskdefs.ExecuteJava.run(ExecuteJava.java:217)
[java] at org.apache.tools.ant.taskdefs.ExecuteJava.execute(ExecuteJava.java:152)
[java] ... 34 more
[java] Caused by: java.lang.NumberFormatException: null
[java] at java.lang.Integer.parseInt(Integer.java:454)
[java] at java.lang.Integer.valueOf(Integer.java:582)
[java] at clojure.core$fn__6145.invoke(core.clj:6247)
[java] at clojure.core__init.load(Unknown Source)
[java] at clojure.core__init.<clinit>(Unknown Source)
[java] ... 48 more
[java] Java Result: -1