First load RuntimeException to prevent segfault on error
Motivation: When an error happens during loading the native library it may try to generate a new RuntimeException before the RuntimeException is loaded. Modifications: - Load RuntimeException as first Result: No more segfaults possible
This commit is contained in:
parent
44615f6cb2
commit
c7827dc16a
@ -351,6 +351,18 @@ jint JNI_OnLoad(JavaVM* vm, void* reserved) {
|
|||||||
if ((*vm)->GetEnv(vm, (void**) &env, JNI_VERSION_1_6) != JNI_OK) {
|
if ((*vm)->GetEnv(vm, (void**) &env, JNI_VERSION_1_6) != JNI_OK) {
|
||||||
return JNI_ERR;
|
return JNI_ERR;
|
||||||
} else {
|
} else {
|
||||||
|
jclass localRuntimeExceptionClass = (*env)->FindClass(env, "java/lang/RuntimeException");
|
||||||
|
if (localRuntimeExceptionClass == NULL) {
|
||||||
|
// pending exception...
|
||||||
|
return JNI_ERR;
|
||||||
|
}
|
||||||
|
runtimeExceptionClass = (jclass) (*env)->NewGlobalRef(env, localRuntimeExceptionClass);
|
||||||
|
if (runtimeExceptionClass == NULL) {
|
||||||
|
// out-of-memory!
|
||||||
|
throwOutOfMemoryError(env);
|
||||||
|
return JNI_ERR;
|
||||||
|
}
|
||||||
|
|
||||||
jclass localNetUtilClass = (*env)->FindClass(env, "io/netty/util/NetUtil" );
|
jclass localNetUtilClass = (*env)->FindClass(env, "io/netty/util/NetUtil" );
|
||||||
if (localNetUtilClass == NULL) {
|
if (localNetUtilClass == NULL) {
|
||||||
// pending exception...
|
// pending exception...
|
||||||
@ -386,17 +398,6 @@ jint JNI_OnLoad(JavaVM* vm, void* reserved) {
|
|||||||
throwRuntimeException(env, "failed to get method ID: ClosedChannelException.<init>()");
|
throwRuntimeException(env, "failed to get method ID: ClosedChannelException.<init>()");
|
||||||
return JNI_ERR;
|
return JNI_ERR;
|
||||||
}
|
}
|
||||||
jclass localRuntimeExceptionClass = (*env)->FindClass(env, "java/lang/RuntimeException");
|
|
||||||
if (localRuntimeExceptionClass == NULL) {
|
|
||||||
// pending exception...
|
|
||||||
return JNI_ERR;
|
|
||||||
}
|
|
||||||
runtimeExceptionClass = (jclass) (*env)->NewGlobalRef(env, localRuntimeExceptionClass);
|
|
||||||
if (runtimeExceptionClass == NULL) {
|
|
||||||
// out-of-memory!
|
|
||||||
throwOutOfMemoryError(env);
|
|
||||||
return JNI_ERR;
|
|
||||||
}
|
|
||||||
|
|
||||||
jclass localIoExceptionClass = (*env)->FindClass(env, "java/io/IOException");
|
jclass localIoExceptionClass = (*env)->FindClass(env, "java/io/IOException");
|
||||||
if (localIoExceptionClass == NULL) {
|
if (localIoExceptionClass == NULL) {
|
||||||
|
Loading…
Reference in New Issue
Block a user