JNI UnsatisfiedLinkError, rh7.3 linux, jdk1.4.2

D

david

#pragma FLAME ON //to be read in voice of Col. Potter, MASH
What in blazes is going on HERE. Why is javah creating this bogus prototype?
Who in God's green earth is responsible for NOT DOCUMENTING this confounded
behavior of javah
#pragma FLAME OFF

"javah -jni" creates fn prototype:

JNIEXPORT void JNICALL
Java_home_0002fdavid_0002fsourcecode_0002fSomeClass_doNoth
ing
(JNIEnv *, jobject);

from java code:

package home.david.sourcecode;
static { System load("/path/to/libSomething.so"); }
public Class SomeClass{
public void doNothing(){}
}

libSomething.so is created from 'gcc -ansi -I <path> ...' using the function
prototypes generated by javah (see above)

Some 'java test code' is developed. And when we try to call doNothing() we
get the Unsatisfied Link Error.

After MUCH pain, I realized the Unsatisfied Link Error would go away and I'd
get proper operation by changing the function definitions from what javah
generated to (eliminating the mangle? junk??):

JNIEXPORT void JNICALL Java_home_david_sourcecode_SomeClass_doNothing
(JNIEnv *, jobject);

#pragma FLAME ON HIGH
WHY IS JAVAH DOING THIS? WHAT THE HECK IS GOING ON? IS JAVAH NOT COMPATIBLE
WITH gcc or g++ (I tried both, with and without extern "C" {} stuff.)

WOULD SOMEONE AT SUN PLEASE DOCUMENT THIS!!
RH linux and gcc are not Solaris, but should WHAT THE!!
 
G

Gordon Beaton

#pragma FLAME ON //to be read in voice of Col. Potter, MASH
What in blazes is going on HERE. Why is javah creating this bogus prototype?
Who in God's green earth is responsible for NOT DOCUMENTING this confounded
behavior of javah
#pragma FLAME OFF

"javah -jni" creates fn prototype:

JNIEXPORT void JNICALL
Java_home_0002fdavid_0002fsourcecode_0002fSomeClass_doNothing
(JNIEnv *, jobject);

Pass the fullt qualified *classname* (not its filename) to javah.

Classnames have dots in them, not slashes like filenames.

/gordon
 
D

david

GORDON!! Thanks!!! YOUR one line (below) should be repeated in BOLD in
every document discussing JNI for idiots like me who miss 'man javah'
nuances and lose hours!

I'll repeat it here:

Pass the fully qualified *classname* (not its filename) to javah.
Pass the fully qualified *classname* (not its filename) to javah.
Pass the fully qualified *classname* (not its filename) to javah.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top