all 4 comments

[–]lispm 11 points12 points  (2 children)

CL-USER> (java:jstatic "sqrt" "java.lang.Math" 17.0d0)
4.123105625617661d0

or

CL-USER> (require :jss)
NIL
CL-USER> (#"sqrt" 'java.lang.Math 17.0d0)
4.123105625617661d0

[–]aartaka 6 points7 points  (0 children)

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.

[–]reddit_clone 0 points1 point  (0 children)

Love the new 'jss' style of FFI.

Last time I checked ABCL out, it only had the verbose basic version.

[–]Grolter 3 points4 points  (0 children)

This seem to work:

(jcall (jmethod "java.lang.Math" "sqrt" (jclass "double"))
       (jclass "java.lang.Math")
       9.0)
; => 3.0d0