Hi everyone,
Failing to make clojure work with our commercial java library. I can run the following Java code on my machine and it works fine:
import com.numerix.pro.Application;
import com.numerix.pro.ApplicationCall;
import com.numerix.pro.ApplicationData;
import com.numerix.pro.ApplicationObjectFactory;
import com.numerix.pro.ApplicationWarning;
public final class FxAmericanOption {
public static void main(final String argv[])
{
int rVal = 0; // exit value
try {
System.out.println("Running: " + new Throwable().getStackTrace()[0].getClassName() + "\n");
final Application app = new Application();
{
final ApplicationCall call = new ApplicationCall();
call.addValue("ID", "USD_Curve");
call.addValue("OBJECT", "Curve");
call.addValue("TYPE", "Yield");
call.addValue("Now Date", ApplicationObjectFactory.parseDate("26-Oct-2003"));
call.addValue("CURRENCY", "USD");
call.addValue("RATE", 0.04);
final String[] outHeaders =
new String[] {"Updated", "Timer", "ID"};
final ApplicationWarning warning = new ApplicationWarning();
app.call(call, outHeaders, warning);
I tried porting it to clojure 1.12 like this
(ns hello
(:import (com.numerix.pro Application ApplicationCall
ApplicationWarning
ApplicationObjectFactory)))
(def myapp (new Application))
(def appcall (new ApplicationCall))
(def warning (new ApplicationWarning))
(.addValue ^ApplicationCall appcall "NAME" "Yield Curve")
(.addValue ^ApplicationCall appcall "ID" "MyCurve")
(.addValue ^ApplicationCall appcall "OBJECT" "Curve")
(.addValue ^ApplicationCall appcall "TYPE" "Yield")
(.addValue ^ApplicationCall appcall "Now Date" (ApplicationObjectFactory/parseDate "26-Oct-2023"))
(.addValue ^ApplicationCall appcall "CURRENCY" "USD")
(.addValue ^ApplicationCall appcall "RATE" 0.04)
(def outHeaders (into-array String ["timer" "id"]))
(^[ApplicationCall String/1 ApplicationWarning] Application/.call ^Application myapp
^ApplicationCall appcall
^String/1 outHeaders
^ApplicationWarning warning)
I can inspect appcall object and it looks totally fine - all the .addValue register correctly with it. But when I evaluate the last form with Application/.call I get an error which I don't understand how to address..
Execution error (IllegalAccessError) at hello/eval10370 (REPL:25).
; failed to access class com.numerix.pro.ApplicationCommon from class hello$eval10370 (com.numerix.pro.ApplicationCommon is in unnamed module of loader 'app'; hello$eval10370 is in unnamed module of loader clojure.lang.DynamicClassLoader @cc01572)
Any help much appreciated!