The following built-ins are available for calling Java methods or setting fields of a Java object. The exception java_exception(Goal) is raised if the Java method or field does not exist, or if the Java method throws any exception.
- javaMethod(ClassOrInstance, Method, Return):
Invoke a Java method, where
- ClassOrInstance: is either an atom that represents a Java class's name, or a term $addr(I1,I2) that represents a Java object. Java objects are passed to Prolog from Java . It is meaningless to construct an object term by any other means.
- Method: is an atom or a structure in the form f(t1,...,tn) where f is the method name, and t1,...,tn are arguments.
- Return: is a variable that will be bound to the returned object by the method.
This method throws an exception named java_exception if the Java method is terminated by an exception.
- javaMethod(ClassOrInstance, Method):
The same as javeMethod/3 but does not require a return value.
- javaGetField(ClassOrInstance, Field, Value):
Get the value of Field of ClassOrInstance and bind it to Value. A field must be an atom.
- javaSetField(ClassOrInstance, Field, Value):
Set Field of ClassOrInstance to be Value.
Neng-Fa Zhou
2011-05-12