Skip to content

Instantly share code, notes, and snippets.

Created December 5, 2010 20:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/729449 to your computer and use it in GitHub Desktop.
Save anonymous/729449 to your computer and use it in GitHub Desktop.
Resolve problems with Java interop
Given the following:
(defn test-function []
(.info logger "hello test"))
(defn -testResolve [this]
(let [fn (resolve (symbol "test-function"))]
(apply fn [])))
And an interface with:
void testResolve();
If I call this from the REPL:
com.pegby.service.clj.boardUpdate=> (-testResolve nil)
1512720 [main] INFO com.pegby.service.clj.boardUpdate - hello test
1512720 [main] INFO com.pegby.service.clj.boardUpdate - hello test
nil
Great!
However, from my unit test:
BoardUpdateFunctions f = new BoardUpdateFunctions();
f.testResolve();
java.lang.NullPointerException
at clojure.core$apply.invoke(core.clj:540)
at com.pegby.service.clj.boardUpdate$_testResolve.invoke(boardUpdate.clj:299)
at com.pegby.service.clj.BoardUpdateFunctions.testResolve(Unknown Source)
at com.pegby.service.BoardUpdateServiceTest.editCardWithAction(BoardUpdateServiceTest.java:12)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at org.junit.internal.runners.TestMethodRunner.executeMethodBody(TestMethodRunner.java:99)
at org.junit.internal.runners.TestMethodRunner.runUnprotected(TestMethodRunner.java:81)
at org.junit.internal.runners.BeforeAndAfterRunner.runProtected(BeforeAndAfterRunner.java:34)
at org.junit.internal.runners.TestMethodRunner.runMethod(TestMethodRunner.java:75)
at org.junit.internal.runners.TestMethodRunner.run(TestMethodRunner.java:45)
at org.junit.internal.runners.TestClassMethodsRunner.invokeTestMethod(TestClassMethodsRunner.java:71)
at org.junit.internal.runners.TestClassMethodsRunner.run(TestClassMethodsRunner.java:35)
at org.junit.internal.runners.TestClassRunner$1.runUnprotected(TestClassRunner.java:42)
at org.junit.internal.runners.BeforeAndAfterRunner.runProtected(BeforeAndAfterRunner.java:34)
at org.junit.internal.runners.TestClassRunner.run(TestClassRunner.java:52)
at org.junit.runner.JUnitCore.run(JUnitCore.java:121)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:64)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment