mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-28 15:24:43 +02:00
8165180: Provide a shared secret to access non-public ServerSocket constructor
Reviewed-by: chegar
This commit is contained in:
parent
4a0362efff
commit
b5172ce65e
3 changed files with 80 additions and 0 deletions
|
@ -25,8 +25,13 @@
|
|||
|
||||
package java.net;
|
||||
|
||||
import jdk.internal.misc.JavaNetSocketAccess;
|
||||
import jdk.internal.misc.SharedSecrets;
|
||||
|
||||
import java.io.FileDescriptor;
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.nio.channels.ServerSocketChannel;
|
||||
import java.security.AccessController;
|
||||
import java.security.PrivilegedExceptionAction;
|
||||
|
@ -1011,4 +1016,27 @@ class ServerSocket implements java.io.Closeable {
|
|||
return options;
|
||||
}
|
||||
}
|
||||
|
||||
static {
|
||||
SharedSecrets.setJavaNetSocketAccess(
|
||||
new JavaNetSocketAccess() {
|
||||
@Override
|
||||
public ServerSocket newServerSocket(SocketImpl impl) {
|
||||
return new ServerSocket(impl);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SocketImpl newSocketImpl(Class<? extends SocketImpl> implClass) {
|
||||
try {
|
||||
Constructor<? extends SocketImpl> ctor =
|
||||
implClass.getDeclaredConstructor();
|
||||
return ctor.newInstance();
|
||||
} catch (NoSuchMethodException | InstantiationException |
|
||||
IllegalAccessException | InvocationTargetException e) {
|
||||
throw new AssertionError(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue