diff --git a/transport-native-epoll/src/main/c/io_netty_channel_epoll_Native.c b/transport-native-epoll/src/main/c/io_netty_channel_epoll_Native.c index aa755c234a..4dcb293fda 100644 --- a/transport-native-epoll/src/main/c/io_netty_channel_epoll_Native.c +++ b/transport-native-epoll/src/main/c/io_netty_channel_epoll_Native.c @@ -351,6 +351,18 @@ jint JNI_OnLoad(JavaVM* vm, void* reserved) { if ((*vm)->GetEnv(vm, (void**) &env, JNI_VERSION_1_6) != JNI_OK) { return JNI_ERR; } 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" ); if (localNetUtilClass == NULL) { // pending exception... @@ -386,17 +398,6 @@ jint JNI_OnLoad(JavaVM* vm, void* reserved) { throwRuntimeException(env, "failed to get method ID: ClosedChannelException.()"); 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"); if (localIoExceptionClass == NULL) {