Use netty-jni-util 0.0.3.Final (#11115)

netty-jni-util 0.0.2.Final is incompatible with static linking. Before
the netty-jni-util dependency was introduced netty-tcnative supported
static linking via NETTY_BUILD_STATIC. netty-jni-util 0.0.3.Final adds
static linking compatibility.

Modifications:

Bump netty-jni-util to version 0.0.3.Final and update to its new API
which requires the caller to manage packagePrefix.

Result:

Using latest version of netty-jni-util and restored static linking
compatibility.
This commit is contained in:
Norman Maurer 2021-03-25 11:40:22 +01:00 committed by GitHub
parent 72d7ec9d8c
commit 7ed840e62a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 26 additions and 14 deletions

View File

@ -456,7 +456,7 @@
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-jni-util</artifactId>
<version>0.0.2.Final</version>
<version>0.0.3.Final</version>
<classifier>sources</classifier>
<optional>true</optional>
</dependency>

View File

@ -36,6 +36,7 @@ static jclass dnsResolverClass = NULL;
static jclass byteArrayClass = NULL;
static jclass stringClass = NULL;
static jmethodID dnsResolverMethodId = NULL;
static char* staticPackagePrefix = NULL;
// JNI Registered Methods Begin
@ -150,10 +151,15 @@ static JNINativeMethod* createDynamicMethodsTable(const char* packagePrefix) {
// JNI Method Registration Table End
static void netty_resolver_dns_native_macos_JNI_OnUnLoad(JNIEnv* env, const char* packagePrefix) {
static void netty_resolver_dns_native_macos_JNI_OnUnLoad(JNIEnv* env) {
NETTY_JNI_UTIL_UNLOAD_CLASS(env, byteArrayClass);
NETTY_JNI_UTIL_UNLOAD_CLASS(env, stringClass);
netty_jni_util_unregister_natives(env, packagePrefix, STREAM_CLASSNAME);
netty_jni_util_unregister_natives(env, staticPackagePrefix, STREAM_CLASSNAME);
if (staticPackagePrefix != NULL) {
free((void *) staticPackagePrefix);
staticPackagePrefix = NULL;
}
}
static jint netty_resolver_dns_native_macos_JNI_OnLoad(JNIEnv* env, const char* packagePrefix) {
@ -183,6 +189,10 @@ static jint netty_resolver_dns_native_macos_JNI_OnLoad(JNIEnv* env, const char*
NETTY_JNI_UTIL_LOAD_CLASS(env, byteArrayClass, "[B", done);
NETTY_JNI_UTIL_LOAD_CLASS(env, stringClass, "java/lang/String", done);
if (packagePrefix != NULL) {
staticPackagePrefix = strdup(packagePrefix);
}
ret = NETTY_JNI_UTIL_JNI_VERSION;
done:
if (ret == JNI_ERR) {

View File

@ -722,13 +722,17 @@ done:
return ret;
}
static void netty_epoll_native_JNI_OnUnload(JNIEnv* env, const char* packagePrefix) {
netty_epoll_linuxsocket_JNI_OnUnLoad(env, packagePrefix);
static void netty_epoll_native_JNI_OnUnload(JNIEnv* env) {
netty_epoll_linuxsocket_JNI_OnUnLoad(env, staticPackagePrefix);
if (register_unix_called == 1) {
register_unix_called = 0;
netty_unix_unregister(env, staticPackagePrefix);
}
netty_jni_util_unregister_natives(env, staticPackagePrefix, STATICALLY_CLASSNAME);
netty_jni_util_unregister_natives(env, staticPackagePrefix, NATIVE_CLASSNAME);
if (staticPackagePrefix != NULL) {
free((void *) staticPackagePrefix);
staticPackagePrefix = NULL;
@ -741,9 +745,6 @@ static void netty_epoll_native_JNI_OnUnload(JNIEnv* env, const char* packagePref
packetPortFieldId = NULL;
packetMemoryAddressFieldId = NULL;
packetCountFieldId = NULL;
netty_jni_util_unregister_natives(env, packagePrefix, STATICALLY_CLASSNAME);
netty_jni_util_unregister_natives(env, packagePrefix, NATIVE_CLASSNAME);
}
// Invoked by the JVM when statically linked

View File

@ -341,21 +341,22 @@ error:
return JNI_ERR;
}
static void netty_kqueue_native_JNI_OnUnload(JNIEnv* env, const char* packagePrefix) {
netty_kqueue_bsdsocket_JNI_OnUnLoad(env, packagePrefix);
netty_kqueue_eventarray_JNI_OnUnLoad(env, packagePrefix);
static void netty_kqueue_native_JNI_OnUnload(JNIEnv* env) {
netty_kqueue_bsdsocket_JNI_OnUnLoad(env, staticPackagePrefix);
netty_kqueue_eventarray_JNI_OnUnLoad(env, staticPackagePrefix);
if (register_unix_called == 1) {
register_unix_called = 0;
netty_unix_unregister(env, staticPackagePrefix);
}
netty_jni_util_unregister_natives(env, staticPackagePrefix, STATICALLY_CLASSNAME);
netty_jni_util_unregister_natives(env, staticPackagePrefix, NATIVE_CLASSNAME);
if (staticPackagePrefix != NULL) {
free((void *) staticPackagePrefix);
staticPackagePrefix = NULL;
}
netty_jni_util_unregister_natives(env, packagePrefix, STATICALLY_CLASSNAME);
netty_jni_util_unregister_natives(env, packagePrefix, NATIVE_CLASSNAME);
}
// We build with -fvisibility=hidden so ensure we mark everything that needs to be visible with JNIEXPORT