IJavaClassObject.Invoke

Syntax

Invoke(MethodName: String, MethodSig: String, Params: Array): Variant;

Parameters

MethodName. Name of executed method. Parameter value is case sensitive.

MethodSig. JNI signature of method

Params. Array of parameter values sent to method.

Description

The Invoke method executes method for Java class instance and returns result of its work.

Comments

To execute the method, make sure that the file with the *.class extension is located at the path specified using the Options string parameter in the registry key [HKEY_CURRENT_USER\SOFTWARE\Foresight\Foresight Analytics Platform\10.0\DevEnv\Java]. For details see the Connecting External Modules to Foresight Analytics Platform section.

To get a Java class in the file system and convert the file with the *.java extension to the file with the *.class extension, use the IJavaUtils.Compile method.

Example

Executing the example requires the Test.class file. The file should be located in the file system at the specified path in the registry and should contain the compiled version of the following Java code:

public class Test {

    public int nonStaticFunc(int a, int b){

        return a + b;

    }

}

Add a link to the Java system assembly.

Sub UserProc;
Var
    Cls: IJavaClass;
    ObjCls: IJavaClassObject;
    Result: Variant;
Begin
    Cls := New JavaClass.Create("Test");
    ObjCls := Cls.CreateObject("()V");
    Result := ObjCls.Invoke("nonStaticFunc""(II)I"78);
    Debug.WriteLine(Result);
End Sub UserProc;

After executing the example, an instance of Java class will be created. The function that executes mathematical calculation based on the values sent in parameters will be executed for this class. The function execution result will be displayed in the development environment console.

See also:

IJavaClassObject