| A mechanism to extend MINERVA on-the-fly with functionality given in Java classes.
The use of reflection is an alternative to the static addition of
Java extensions to MINERVA via minervax.
Semantics:
Generating a MINERVA predicate from a Java method object,
the follwing holds:
- If the method returns type 'void', then the predicate succeeds.
There is no return term.
- If the method returns type 'boolean', then the predicate succeeds
or fails a accordingly. There is no return term.
- Otherwise the predicate succeeds. The result of the method
is returned as the last argument of the predicate.
- If the method is not 'static', i.e. a class method, then the
predicate additionally takes as first argument the object to
which the method is applied.
Summary:
static void fun(X, Y) => fun(X, Y)
void fun(X, Y) => fun(Object, X, Y)
static boolean fun(X, Y) => fun(X, Y)
boolean fun(X, Y) => fun(Object, X, Y)
static int fun(X, Y) => fun(X, Y, Result)
int fun(X, Y) => fun(Object, X, Y, Result)
The predicate invoke_method/4 can be used to directly invoke a
method, i.e. without using declare_method/2.
invoke_method(+Method, +Object, +ArgumentList, -Result)
Example:
:
get_class('java.lang.String', String),
get_class(int, Integer),
get_method(String, substring, [Integer,Integer], Substring),
invoke_method(Substring, hello, [1,4], Result).
==>
Result = ell
For more usage examples refer to the ExamplePrograms section.
- Examples:
- ExamplePrograms/MinervaFeatures/Reflection
|