Symbian
Symbian OS Library

FAQ-0238 I changed a JNI method to "static" and now I can't get it to link

[Index][spacer] [Previous] [Next]



 

Classification: Java Category: JNI
Created: 06/24/99 Modified: 09/04/2001
Number: FAQ-0238
Platform: Not Applicable

Question:
My project based on the PowerInfo example linked successfully until I changed the signature of a JNI method to make it static. The code (Java and native) continues to compile successfully but an "unresolved external symbol" error keeps occurring because the native method cannot for some reason be found at link time. What might be going wrong?

Answer:
Check that you have changed the second argument in the native method definition from type jobject to type jclass. Failure to do this will not generate a compilation error because the corresponding header file in \CClassHeaders will probably be generated correctly following recompilation of the Java. The problem will only surface at link time.
In general it is worth checking, whenever a native method fails to link, that its signature is in synch between the .cpp file where it is defined and the generated .h file.