@@ -1103,6 +1103,36 @@ TEST(LibraryPatcherSocketStateTest,
11031103 }
11041104}
11051105
1106+ TEST (LibraryPatcherSocketStateTest, AdmitsNettyNativeEpollBySymbolOutsideJdkDirectory) {
1107+ CodeCache netty (" libnetty_transport_native_epoll_x86_64.so" );
1108+ CodeCache netty_shaded (" libio_grpc_netty_shaded_netty_transport_native_epoll_x86_64.so" );
1109+ CodeCache netty_partial (" libnetty_transport_native_epoll_x86_64.so" );
1110+
1111+ char marker_addresses[2 ] = {};
1112+ netty.add (&marker_addresses[0 ], 1 , " JNI_OnLoad_netty_transport_native_epoll" );
1113+ netty.add (&marker_addresses[1 ], 1 , " JNI_OnUnload_netty_transport_native_epoll" );
1114+ netty_shaded.add (&marker_addresses[0 ], 1 , " JNI_OnLoad_netty_transport_native_epoll" );
1115+ netty_shaded.add (&marker_addresses[1 ], 1 , " JNI_OnUnload_netty_transport_native_epoll" );
1116+ netty_partial.add (&marker_addresses[0 ], 1 , " JNI_OnLoad_netty_transport_native_epoll" );
1117+
1118+ // Admitted even though it is not located in the JDK's own lib directory,
1119+ // and regardless of the .so's basename (shading relocates the filename).
1120+ EXPECT_EQ (SOCKET_PATCH_NETTY_NATIVE_EPOLL ,
1121+ LibraryPatcher::socket_patch_target_for_test (
1122+ &netty, " libnetty_transport_native_epoll_x86_64.so" , false ));
1123+ EXPECT_EQ (SOCKET_PATCH_NETTY_NATIVE_EPOLL ,
1124+ LibraryPatcher::socket_patch_target_for_test (
1125+ &netty_shaded,
1126+ " libio_grpc_netty_shaded_netty_transport_native_epoll_x86_64.so" ,
1127+ false ));
1128+
1129+ // Requires both symbols, mirroring the IBM JCL bridge's all-or-nothing check.
1130+ EXPECT_EQ (SOCKET_PATCH_NONE ,
1131+ LibraryPatcher::socket_patch_target_for_test (
1132+ &netty_partial,
1133+ " libnetty_transport_native_epoll_x86_64.so" , false ));
1134+ }
1135+
11061136TEST_F (LibraryPatcherImportTest, PatchesAndRestoresEveryImportLocation) {
11071137 initializeImports (3 );
11081138 void * originals[3 ] = {imports[0 ], imports[1 ], imports[2 ]};
0 commit comments