Hello,
I'm experimenting with compiling some code using javac and the following example:
https://github.com/slyrus/abcl/blob/master/examples/pure-lisp-to-java/Main.j...
I have one doubt regarding LispObject (what we get from Function.execute): I have read some introspection in the manual but my use-case is slightly different since the I will use the return value of the Lisp call and that value is actually a Java class (from a non-standard library which I use) that will be the return value of the main method of the Main class.
Is this feasible? Perhaps I'm missing something obvious, especially since my Java is hardly the strongest.
Best regards,
Hello,
Solved it help from ferada in the IRC channel, it's trivial now that I look at it but I'll leave it here anyway, maybe it helps someone.
Frederico Munoz fsmunoz@sdf.org wrote:
I have one doubt regarding LispObject (what we get from Function.execute): I have read some introspection in the manual but my use-case is slightly different since the I will use the return value of the Lisp call and that value is actually a Java class (from a non-standard library which I use) that will be the return value of the main method of the Main class.
Assuming somethins like this in the Lisp file:
--- (defun say-hello (&optional name) (let ((response (java:jnew "com.google.gson.JsonObject"))) response)) --- ... this works from the Java side:
--- LispObject result = voidFunction.execute(new JavaObject(thisObject)); JavaObject jo = ((JavaObject) result); JsonObject json = ((JsonObject) jo.getObject()); json.addProperty("greet", "Hi!"); System.out.println(json.get("greet")); // => "Hi!" System.out.println("Class: " + json.getClass().getName()); // => Class: com.google.gson.JsonObject ---
Best regards,
armedbear-devel@common-lisp.net