Hi Kevin-

Thanks for taking a look, but...

You apparently forgot the "-jni" switch for javah.  You generated a
"test.h" for the old JDK 1.0 native interface, not the 1.1 JNI...

Bob L.

Kevin B. Hendricks wrote:

> Hi,
> 
> I tried your example code and it did not seg-fault.  I received an
> unsatisfied link error.  Upon closer examination, the test.h file generated
> by javah did not seem to be correct (i.e. it did not match your declaration
> or parameter list in hello.C
> 
> Using nm on libhello.so showed this to be the case (some C++ name mangling?)
> 
> I simply copied the declaration from hello.C and replaced the appropriate
> part of test.h with the correct (i.e. matching) declaration
> 
> Then my unsatified link error went away and everything worked fine.
> 
> There seems to be some trouble with javah and C++.  I am not sure exactly
> what is up.
> 
> Anyway, here are my slightly modified pieces of code:
> 
[snip]
> And finally the "fixed" Test.h header file which you can compare to the one
> generated by javah.
> 
> /* DO NOT EDIT THIS FILE - it is machine generated */
> #include <native.h>
> /* Header for class Test */
> 
> #ifndef _Included_Test
> #define _Included_Test
> 
> #pragma pack(4)
> 
> typedef struct ClassTest {
>     char PAD;   /* ANSI C requires structures to have a least one member */
> } ClassTest;
> HandleTo(Test);
> 
> #pragma pack()
> 
> #ifdef __cplusplus
> extern "C" {
> #endif
> 
> JNIEXPORT void JNICALL Java_Test_display(JNIEnv *env, jobject obj);
> 
> #ifdef __cplusplus
> }
> #endif
> #endif
> 
> 
> I hope this helps.
> 
> I don't know why this is happening.  If this solution makes "no sense" to
> you please submit an official bug report to the Blackdown Jitterbug bug
> database.
> 
> Kevin
> Blackdown JDK Poriting Team
> 
> ----------------------------------------------------------
> Kevin B. Hendricks
> Associate Professor, Operations & Information Technology
> School of Business, College of William & Mary
> Williamsburg, VA 23187, [EMAIL PROTECTED]
> http://business.tyler.wm.edu
-- 
Robert Lynch-Berkeley CA [EMAIL PROTECTED]
http://www.best.com/~rmlynch/

Reply via email to