I want to call the square root of 9 from Math:
I tried the following, but it does not work:
(defun main
(format t "~a~%"
(JAVA:JCALL (JAVA:JMETHOD "java.lang.Math" "sqrt" 9.0))))
(main)
Can someone provide a working “.lisp” file which calls the java sqrt function from 9 and prints the result 3 for the abcl implementation ?
You must log in or # to comment.
CL-USER> (java:jstatic "sqrt" "java.lang.Math" 17.0d0) 4.123105625617661d0
To add more context to this response: Java has this notion of static methods that belong to classes, compared to the regular methods that belong/act on instances. So ABCL’s
jmethod
is to call a method using an instance, whilejstatic
is to call a static method using a class.Math.sqrt
happens to be a static method ofMath
class, so usejstatic
. Once this static/regular distinction is cleared up, ABCL interface becomes quite usable.