Skip to content

Commit

Permalink
NativeUnixSocket: Preload more classes for JNI
Browse files Browse the repository at this point in the history
FindClass may return null unless we call Class.forName prior to
initialization.

This affects OperationNotSupportedSocketException (a junixsocket class)
and InetSocketAddress, which we now use to detect the "large ports"
capability.
  • Loading branch information
kohlschuetter committed Jun 26, 2023
1 parent 7322d93 commit bf980c5
Showing 1 changed file with 3 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import java.io.FileDescriptor;
import java.io.IOException;
import java.lang.ProcessBuilder.Redirect;
import java.net.InetSocketAddress;
import java.net.ServerSocket;
import java.net.Socket;
import java.net.SocketAddress;
Expand Down Expand Up @@ -131,6 +132,8 @@ static void initPre() {
// in some environments, JNI FindClass won't find these classes unless we resolve them first
tryResolveClass(AbstractSelectableChannel.class.getName());
tryResolveClass("java.lang.ProcessBuilder$RedirectPipeImpl");
tryResolveClass(InetSocketAddress.class.getName());
tryResolveClass(OperationNotSupportedSocketException.class.getName());
}

private static void tryResolveClass(String className) {
Expand Down

0 comments on commit bf980c5

Please sign in to comment.