diff --git a/common/src/main/java/io/netty/util/internal/NativeLibraryLoader.java b/common/src/main/java/io/netty/util/internal/NativeLibraryLoader.java index e7099d792f..ab607f0240 100644 --- a/common/src/main/java/io/netty/util/internal/NativeLibraryLoader.java +++ b/common/src/main/java/io/netty/util/internal/NativeLibraryLoader.java @@ -181,7 +181,10 @@ public final class NativeLibraryLoader { /** * Load the given library with the specified {@link ClassLoader} */ - public static void load(String name, ClassLoader loader) { + public static void load(String originalName, ClassLoader loader) { + // Adjust expected name to support shading of native libraries. + String name = SystemPropertyUtil.get("io.netty.packagePrefix", "").replace('.', '-') + originalName; + String libname = System.mapLibraryName(name); String path = NATIVE_RESOURCE_HOME + libname; diff --git a/transport-native-epoll/src/main/java/io/netty/channel/epoll/Native.java b/transport-native-epoll/src/main/java/io/netty/channel/epoll/Native.java index 30557d01b7..8a00159e7e 100644 --- a/transport-native-epoll/src/main/java/io/netty/channel/epoll/Native.java +++ b/transport-native-epoll/src/main/java/io/netty/channel/epoll/Native.java @@ -188,8 +188,7 @@ public final class Native { if (!name.startsWith("linux")) { throw new IllegalStateException("Only supported on Linux"); } - NativeLibraryLoader.load(SystemPropertyUtil.get("io.netty.packagePrefix", "").replace('.', '-') + - "netty-transport-native-epoll", PlatformDependent.getClassLoader(Native.class)); + NativeLibraryLoader.load("netty-transport-native-epoll", PlatformDependent.getClassLoader(Native.class)); } private Native() { diff --git a/transport-native-kqueue/src/main/java/io/netty/channel/kqueue/Native.java b/transport-native-kqueue/src/main/java/io/netty/channel/kqueue/Native.java index 432a650147..c97b69d0c8 100644 --- a/transport-native-kqueue/src/main/java/io/netty/channel/kqueue/Native.java +++ b/transport-native-kqueue/src/main/java/io/netty/channel/kqueue/Native.java @@ -100,8 +100,7 @@ final class Native { if (!name.startsWith("mac") && !name.contains("bsd") && !name.startsWith("darwin")) { throw new IllegalStateException("Only supported on BSD"); } - NativeLibraryLoader.load(SystemPropertyUtil.get("io.netty.packagePrefix", "").replace('.', '-') + - "netty-transport-native-kqueue", PlatformDependent.getClassLoader(Native.class)); + NativeLibraryLoader.load("netty-transport-native-kqueue", PlatformDependent.getClassLoader(Native.class)); } private Native() {