hi, Is there a way to use a native JNI method as the run method of a Thread object?
The following example works with the Sun JDK but it won't work with kaffe. If I use kaffe in the example below, the start method of the Thread object will never return. Test.java: -=-= -=-= -=-= -=-= -=-= -=-= -=-= -=-= -=-= -=-= -=-= -=-= -=-= -=-= class Test extends Thread { public native void run (); static { try { System.loadLibrary ("test"); } catch (Exception e) { System.err.println ("System.loadLibrary (): " + e); System.exit (1); } } } class Main { public static void main (String args[]) { Test test = new Test (); test.start (); System.out.println ("## ok"); try { while (true) { System.out.println ("main"); Thread.sleep (1000); } } catch (Exception e) { System.err.println (e); System.exit (1); } } } -=-= -=-= -=-= -=-= -=-= -=-= -=-= -=-= -=-= -=-= -=-= -=-= -=-= -=-= test_jni.c: -=-= -=-= -=-= -=-= -=-= -=-= -=-= -=-= -=-= -=-= -=-= -=-= -=-= -=-= #include <stdio.h> #include <errno.h> #include <unistd.h> #include <jni.h> #include "Test.h" JNIEXPORT void JNICALL Java_Test_run (JNIEnv *env, jobject object) { for (;;) { printf ("run\n"); sleep (2); } } -=-= -=-= -=-= -=-= -=-= -=-= -=-= -=-= -=-= -=-= -=-= -=-= -=-= -=-= This is how I build the example with kaffe: -=-= -=-= -=-= -=-= -=-= -=-= -=-= -=-= -=-= -=-= -=-= -=-= -=-= -=-= zero:~$ export PATH=~/kaffe-cvs/bin:$PATH zero:~$ export CLASSPATH=.:~/kaffe-cvs/lib/Klasses.jar zero:~$ javac Test.java zero:~$ kaffeh -jni Test zero:~$ gcc -Wall -I$HOME/kaffe-cvs/include/ \ -I$HOME/kaffe-cvs/include/kaffe/ \ -c test_jni.c zero:~$ gcc -shared -Wl,-soname,libtest.so -o libtest.so test_jni.o -=-= -=-= -=-= -=-= -=-= -=-= -=-= -=-= -=-= -=-= -=-= -=-= -=-= -=-= kaffe produces the following output: -=-= -=-= -=-= -=-= -=-= -=-= -=-= -=-= -=-= -=-= -=-= -=-= -=-= -=-= zero:~$ export LD_LIBRARY_PATH=. zero:~$ kaffe Main run run run run run run ^C zero:~$ -=-= -=-= -=-= -=-= -=-= -=-= -=-= -=-= -=-= -=-= -=-= -=-= -=-= -=-= Sun JDK 1.3.1/1.4.0: -=-= -=-= -=-= -=-= -=-= -=-= -=-= -=-= -=-= -=-= -=-= -=-= -=-= -=-= zero:~$ export LD_LIBRARY_PATH=. zero:~$ java Main ## ok run main main run main main run main main run ^C zero:~$ -=-= -=-= -=-= -=-= -=-= -=-= -=-= -=-= -=-= -=-= -=-= -=-= -=-= -=-= -- _______________________________________________ kaffe mailing list [EMAIL PROTECTED] http://kaffe.org/cgi-bin/mailman/listinfo/kaffe