Invocation: How to receive a return value from Java?
I wrote a method that takes a java.lang.String and returns a java.lang.String:
publicclass DeleteMe
{
publicstatic String foo( String arg )
{
System.out.println("Class DeleteMe: foo() was called with " + arg );
String bar = arg.toUpperCase();
return bar;
}
}
I've successfully called this method from a C program, briefly (error checking surpressed):
// Start the JVM
res = JNI_CreateJavaVM(&jvm, (void **)&env, &vm_args);
// Get a pointer to the class
cls = (*env)->FindClass(env,"DeleteMe");
// Get method ID for "String foo( String arg )"
methodID = (*env)->GetStaticMethodID(env, cls,"foo","(Ljava/lang/String;)Ljava/lang/String;");
// Create the argument to pass to foo()
jstr = (*env)->NewStringUTF(env," Hola!!!");
// Call the method
(*env)->CallStaticVoidMethod(env, cls, methodID, jstr);
This works, but I don't know how to obtain the return value from foo().
How does a C program "get at" the return value of a Java program with the Invocation API?

