P
Paul J. Lucas
Given:
jclass findClassOrDie( JNIEnv *env, char const *name ) {
jclass const theClass = env->FindClass( name );
cerr << "FindClass(" << name << ") failed" << endl;
exit( 1 );
}
void throwMyException( JNIEnv *env, char const *msg ) {
static char const MyExceptionClass[] =
"com/mycompany/utils/MyExceptionClass";
env->ThrowNew( findClassOrDie( env, MyExceptionClass ), msg );
}
Any call to throwMyException() and subsequently to findClassOrDie()
always fails because FindClass() never finds MyExceptionClass, but I
have no idea why not. FindClass works fine for standard Java exception
classes like IllegalArgumentException.
So why can't it find my exception class? It's just a simple class
derived from Exception.
- Paul
jclass findClassOrDie( JNIEnv *env, char const *name ) {
jclass const theClass = env->FindClass( name );
cerr << "FindClass(" << name << ") failed" << endl;
exit( 1 );
}
void throwMyException( JNIEnv *env, char const *msg ) {
static char const MyExceptionClass[] =
"com/mycompany/utils/MyExceptionClass";
env->ThrowNew( findClassOrDie( env, MyExceptionClass ), msg );
}
Any call to throwMyException() and subsequently to findClassOrDie()
always fails because FindClass() never finds MyExceptionClass, but I
have no idea why not. FindClass works fine for standard Java exception
classes like IllegalArgumentException.
So why can't it find my exception class? It's just a simple class
derived from Exception.
- Paul