java:handle
(java:handle value text &optional hash order class)
Makes a Java object that stands for value, a Lisp value Java has no value of (a symbol, a
list, ...). Java sees text as the object's toString. Two handles of one class and one
text are equals; the object's hashCode is hash's low 32 bits (the text's hashCode
without one), and a handle orders a handle of its class by order (the text without one),
so a handle keys a java.util.HashMap and sorts in a java.util.TreeSet. Wherever Java
hands the handle back -- a method's result, an array's element, a callback's argument --
java: answers value. Part of the JVM-only java interop package — available on the
interpreter and in JVM-compiled classes, not on the WASM backend. See the Java interop
guide.
- A nil
hashmakes a handle equal only to a handle of the very samevalue(eq), itshashCodethe value's identity hash. Itstextmay then be nil: itstoStringisObject's spelling, the class and the hex hash (my.Cell@1b6d3586). ordermay be a function:compareTocalls it with the value and the Lisp value of the object compared with, and answers the sign of the real number it answers. A nilordermakes the handle order nothing. A handle that does not order the object, or meets a handle of anotherclass, throws theClassCastExceptiona cast would (class S cannot be cast to class K).classnames the class Java's messages give the handle, and splits equality and order: handles of two classes are neverequalsand never compare.- A handle of a real number is a
java.lang.Numberof it:doubleValue(a ratio'sDECIMAL64quotient),longValue,intValue.
A text that is no string (or nil with a hash), a hash that is no integer or nil, an
order that is no string, function or nil, or a class that is no string or nil is an
error: java:handle expects (java:handle value text [hash [order ["class"]]]), got 2. The
object is of am.ik.rontolisp.runtime.RontoJavaHandle (RontoJavaNumberHandle for a
number), a class the interpreter uses too and a compiled program ships beside it, made with
no reflection. See also java:view.