Could you please check this into 3.0.1, too?

Bryce McKinlay bryce@waitaki.otago.ac.nz
Thu Sep 27 15:09:00 GMT 2001


Tom Tromey wrote:
>Martin> PS: Has there been any progress in the implementation of the
>Martin> invocation API?
>>Nope. Nobody is working on it.
>
So pessimistic, Tom! ;-)
The invocation interface is now implemented and does actually work. It 
may well need some more testing and debugging, but a simple example like 
the following does run:
// invoke.cpp
#include <jni.h>
int main(int argc, char **argv)
{
 JavaVM *jvm;
 JNIEnv *env;
 JavaVMInitArgs vm_args;
 vm_args.version = JNI_VERSION_1_2;
 JNI_GetDefaultJavaVMInitArgs(&vm_args);
 JNI_CreateJavaVM(&jvm, &env, &vm_args);
 jclass cls = env->FindClass("Test");
 jmethodID mid = env->GetStaticMethodID(cls, "test", "(I)V");
 env->CallStaticVoidMethod(cls, mid, 567);
 jvm->DestroyJavaVM();
}
public class Test
{
 public static void test(int i)
 {
 System.out.println ("Hello from Java: " + i);
 }
}
$ gcj -c Test.java
$ gcj Test.o invoke.cpp -fjni -o invoke -I /home/bryce/gcc/include/ -g
$ ./invoke
Hello from Java: 567
It may work even better if JNI_CreateJavaVM actually called 
_Jv_CreateJavaVM from somewhere ;-)
regards
Bryce.


More information about the Java mailing list

AltStyle によって変換されたページ (->オリジナル) /