@Target(value=METHOD) @Retention(value=RUNTIME) public @interface MethodMessage
JavaInterop.asJavaObject(java.lang.Class, com.oracle.truffle.api.interop.TruffleObject)
wrapper interfaces. The interface created by
JavaInterop.asJavaObject(java.lang.Class, com.oracle.truffle.api.interop.TruffleObject)
method implements its methods by sending messsages to TruffleObject
provided at the time of construction. There is a default sequence of operations for each method,
which is good enough to read fields or invoke methods. However the
Interop API is far richer and supports additional
messages (not only the well known ones, but also arbitrary custom ones). To
control which Message is sent one can annotate each method by this annotation.
var obj = { 'x' : 5 }
one can define the appropriate wrapper interface as:
interface ObjInterop {
@MethodMessage(message = "WRITE")
void x(int value);
}
Then one can change the value of field x in obj from Java by calling:
JavaInterop.asJavaObject(ObjInterop.class, obj).x(10);
the value of the x field is going to be 10 then.
public static boolean isNullValue(TruffleObjectobj) { returnJavaInterop.isNull(obj); }
public abstract String message
message to send. Well known messages include fields of
the Message class (e.g. "READ", "WRITE", "UNBOX",
IS_NULL) or slightly mangled names of Message class factory methods (
EXECUTE, INVOKE). For more details on the string encoding of message names
see Message.valueOf(java.lang.String) method.Message.valueOf(java.lang.String)