Fix support for shading native libraries which was broken in b818852cdb
. (#8091)
Motivation:
b818852cdb
broke support for shading the native libraries in netty as it missed to respect the package prefix that is used when shading.
Modifications:
Correctly respect package prefix for constructor argument and include the used classname when logging that we could not find the constructor.
Result:
Be able to shade native libraries of netty again.
This commit is contained in:
parent
253522fc91
commit
7f5e77484c
@ -1010,21 +1010,32 @@ jint netty_unix_socket_JNI_OnLoad(JNIEnv* env, const char* packagePrefix) {
|
|||||||
dynamicMethods = NULL;
|
dynamicMethods = NULL;
|
||||||
char* nettyClassName = netty_unix_util_prepend(packagePrefix, "io/netty/channel/unix/DatagramSocketAddress");
|
char* nettyClassName = netty_unix_util_prepend(packagePrefix, "io/netty/channel/unix/DatagramSocketAddress");
|
||||||
jclass localDatagramSocketAddressClass = (*env)->FindClass(env, nettyClassName);
|
jclass localDatagramSocketAddressClass = (*env)->FindClass(env, nettyClassName);
|
||||||
|
if (localDatagramSocketAddressClass == NULL) {
|
||||||
free(nettyClassName);
|
free(nettyClassName);
|
||||||
nettyClassName = NULL;
|
nettyClassName = NULL;
|
||||||
if (localDatagramSocketAddressClass == NULL) {
|
|
||||||
// pending exception...
|
// pending exception...
|
||||||
return JNI_ERR;
|
return JNI_ERR;
|
||||||
}
|
}
|
||||||
datagramSocketAddressClass = (jclass) (*env)->NewGlobalRef(env, localDatagramSocketAddressClass);
|
datagramSocketAddressClass = (jclass) (*env)->NewGlobalRef(env, localDatagramSocketAddressClass);
|
||||||
if (datagramSocketAddressClass == NULL) {
|
if (datagramSocketAddressClass == NULL) {
|
||||||
|
free(nettyClassName);
|
||||||
|
nettyClassName = NULL;
|
||||||
// out-of-memory!
|
// out-of-memory!
|
||||||
netty_unix_errors_throwOutOfMemoryError(env);
|
netty_unix_errors_throwOutOfMemoryError(env);
|
||||||
return JNI_ERR;
|
return JNI_ERR;
|
||||||
}
|
}
|
||||||
datagramSocketAddrMethodId = (*env)->GetMethodID(env, datagramSocketAddressClass, "<init>", "(Ljava/lang/String;IILio/netty/channel/unix/DatagramSocketAddress;)V");
|
|
||||||
|
// Respect shading...
|
||||||
|
char parameters[1024] = {0};
|
||||||
|
snprintf(parameters, sizeof(parameters), "(Ljava/lang/String;IIL%s;)V", nettyClassName);
|
||||||
|
free(nettyClassName);
|
||||||
|
nettyClassName = NULL;
|
||||||
|
|
||||||
|
datagramSocketAddrMethodId = (*env)->GetMethodID(env, datagramSocketAddressClass, "<init>", parameters);
|
||||||
if (datagramSocketAddrMethodId == NULL) {
|
if (datagramSocketAddrMethodId == NULL) {
|
||||||
netty_unix_errors_throwRuntimeException(env, "failed to get method ID: DatagramSocketAddress.<init>(String, int, int, DatagramSocketAddress)");
|
char msg[1024] = {0};
|
||||||
|
snprintf(msg, sizeof(msg), "failed to get method ID: %s.<init>(String, int, int, %s)", nettyClassName, nettyClassName);
|
||||||
|
netty_unix_errors_throwRuntimeException(env, msg);
|
||||||
return JNI_ERR;
|
return JNI_ERR;
|
||||||
}
|
}
|
||||||
jclass localInetSocketAddressClass = (*env)->FindClass(env, "java/net/InetSocketAddress");
|
jclass localInetSocketAddressClass = (*env)->FindClass(env, "java/net/InetSocketAddress");
|
||||||
|
Loading…
Reference in New Issue
Block a user