Add fallback for android when trying to access the filedescriptor via JNI
Motivation: Android seems to use a different field name so we should also try to access it with the name used by android. Modifications: Try first fd and if this fails try descriptor as field name Result: Workaround for android.
This commit is contained in:
parent
ab340e1de0
commit
fdf09ee243
@ -780,8 +780,11 @@ jint netty_epoll_linuxsocket_JNI_OnLoad(JNIEnv* env, const char* packagePrefix)
|
|||||||
NETTY_JNI_UTIL_GET_FIELD(env, fileChannelCls, fileDescriptorFieldId, "fd", "Ljava/io/FileDescriptor;", done);
|
NETTY_JNI_UTIL_GET_FIELD(env, fileChannelCls, fileDescriptorFieldId, "fd", "Ljava/io/FileDescriptor;", done);
|
||||||
|
|
||||||
NETTY_JNI_UTIL_FIND_CLASS(env, fileDescriptorCls, "java/io/FileDescriptor", done);
|
NETTY_JNI_UTIL_FIND_CLASS(env, fileDescriptorCls, "java/io/FileDescriptor", done);
|
||||||
NETTY_JNI_UTIL_GET_FIELD(env, fileDescriptorCls, fdFieldId, "fd", "I", done);
|
NETTY_JNI_UTIL_TRY_GET_FIELD(env, fileDescriptorCls, fdFieldId, "fd", "I");
|
||||||
|
if (fdFieldId == NULL) {
|
||||||
|
// Android uses a different field name, let's try it.
|
||||||
|
NETTY_JNI_UTIL_GET_FIELD(env, fileDescriptorCls, fdFieldId, "descriptor", "I", done);
|
||||||
|
}
|
||||||
ret = NETTY_JNI_UTIL_JNI_VERSION;
|
ret = NETTY_JNI_UTIL_JNI_VERSION;
|
||||||
done:
|
done:
|
||||||
netty_jni_util_free_dynamic_methods_table(dynamicMethods, fixed_method_table_size, dynamicMethodsTableSize());
|
netty_jni_util_free_dynamic_methods_table(dynamicMethods, fixed_method_table_size, dynamicMethodsTableSize());
|
||||||
|
Loading…
Reference in New Issue
Block a user