src/java.base/share/classes/java/net/ServerSocket.java
changeset 55750 6f60cfd502c3
parent 55323 fc4042870cc4
child 57877 eebdf6aa4907
equal deleted inserted replaced
55749:cff8aad2593f 55750:6f60cfd502c3
    25 
    25 
    26 package java.net;
    26 package java.net;
    27 
    27 
    28 import java.io.FileDescriptor;
    28 import java.io.FileDescriptor;
    29 import java.io.IOException;
    29 import java.io.IOException;
    30 import java.lang.reflect.Constructor;
       
    31 import java.lang.reflect.InvocationTargetException;
       
    32 import java.nio.channels.ServerSocketChannel;
    30 import java.nio.channels.ServerSocketChannel;
    33 import java.security.AccessController;
       
    34 import java.security.PrivilegedExceptionAction;
       
    35 import java.util.Objects;
    31 import java.util.Objects;
    36 import java.util.Set;
    32 import java.util.Set;
    37 import java.util.Collections;
    33 import java.util.Collections;
    38 
    34 
    39 import jdk.internal.access.JavaNetSocketAccess;
       
    40 import jdk.internal.access.SharedSecrets;
       
    41 import sun.net.PlatformSocketImpl;
    35 import sun.net.PlatformSocketImpl;
    42 
    36 
    43 /**
    37 /**
    44  * This class implements server sockets. A server socket waits for
    38  * This class implements server sockets. A server socket waits for
    45  * requests to come in over the network. It performs some operation
    39  * requests to come in over the network. It performs some operation
  1114         } catch (IOException e) {
  1108         } catch (IOException e) {
  1115             options = Collections.emptySet();
  1109             options = Collections.emptySet();
  1116         }
  1110         }
  1117         return options;
  1111         return options;
  1118     }
  1112     }
  1119 
       
  1120     static {
       
  1121         SharedSecrets.setJavaNetSocketAccess(
       
  1122             new JavaNetSocketAccess() {
       
  1123                 @Override
       
  1124                 public ServerSocket newServerSocket(SocketImpl impl) {
       
  1125                     return new ServerSocket(impl);
       
  1126                 }
       
  1127 
       
  1128                 @Override
       
  1129                 public SocketImpl newSocketImpl(Class<? extends SocketImpl> implClass) {
       
  1130                     try {
       
  1131                         Constructor<? extends SocketImpl> ctor =
       
  1132                             implClass.getDeclaredConstructor();
       
  1133                         return ctor.newInstance();
       
  1134                     } catch (NoSuchMethodException | InstantiationException |
       
  1135                              IllegalAccessException | InvocationTargetException e) {
       
  1136                         throw new AssertionError(e);
       
  1137                     }
       
  1138                 }
       
  1139             }
       
  1140         );
       
  1141     }
       
  1142 }
  1113 }