8217997: Better socket support

Reviewed-by: alanb, ahgross, chegar, igerasim
This commit is contained in:
Michael McMahon 2019-03-25 17:15:27 +00:00
parent 67a0aa7960
commit e4553cb2fa
4 changed files with 45 additions and 1 deletions

View file

@ -32,6 +32,7 @@ import java.util.Objects;
import java.util.Set;
import java.util.Collections;
import sun.security.util.SecurityConstants;
import sun.net.PlatformSocketImpl;
/**
@ -73,13 +74,25 @@ class ServerSocket implements java.io.Closeable {
*
* @throws NullPointerException if impl is {@code null}.
*
* @throws SecurityException if a security manager is set and
* its {@code checkPermission} method doesn't allow
* {@code NetPermission("setSocketImpl")}.
* @since 12
*/
protected ServerSocket(SocketImpl impl) {
Objects.requireNonNull(impl);
checkPermission();
this.impl = impl;
}
private static Void checkPermission() {
SecurityManager sm = System.getSecurityManager();
if (sm != null) {
sm.checkPermission(SecurityConstants.SET_SOCKETIMPL_PERMISSION);
}
return null;
}
/**
* Creates an unbound server socket.
*