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 ?

  • aartakaB
    link
    fedilink
    English
    arrow-up
    1
    ·
    1 年前

    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, while jstatic is to call a static method using a class. Math.sqrt happens to be a static method of Math class, so use jstatic. Once this static/regular distinction is cleared up, ABCL interface becomes quite usable.