I am seeing this warning in my JNI code:
JNI WARNING: 0x44be7258 is not a valid JNI reference
I am assigning a LocalReference returned by FindClass method in JNI to my class member variable within the constructor:
Header:
...
jclass m_class;
Cpp:
m_class = env->FindClass( classSignature );
Does FindClass return a LocalReference and storing it in my class member variable is invalid?
From the Liang book, chapter 5.1.1 "Local References"
Followed by an illegal code example which uses exactly your method
FindClass
. In other words, yes,FindClass
returns a local reference. In the following chapter is an example of creating a global reference which is usable in the way you wanted. Don't forget toDeleteGlobalRef
when you don't need it anymore. Otherwise JVM cannot GC it and your program will leak.