The following built-ins are available for calling Java methods, or for setting the 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 an exception.
- javaMethod(ClassOrInstance, Method, Return):
Invokes 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 the method will bind to the object that is returned.
This method throws an exception, which is named java_exception, if the Java method is terminated by an exception.
- javaMethod(ClassOrInstance, Method):
This is the same as javaMethod/3, except that it does not require a return value.
- javaGetField(ClassOrInstance, Field, Value):
Gets the value of Field of ClassOrInstance, and binds it to Value. A field must be an atom.
- javaSetField(ClassOrInstance, Field, Value):
Sets Field of ClassOrInstance to be Value.
Neng-Fa Zhou
2013-01-25