java类java.net.SocketImplFactory的实例源码

MockSocket.java 文件源码 项目:evosuite 阅读 18 收藏 0 点赞 0 评论 0
public static synchronized void setSocketImplFactory(SocketImplFactory fac) throws IOException{

        /*
         * Having a factory would be very tricky, as returned instances are not of type MockSocketImpl.
         * Even if where to change "impl" into SocketImpl, then we wouldn't be able to call all its package
         * level methods used in this class. We could use reflection though.
         * Anyway, as this method is never used in SF110, we just throw a legal exception 
         */
        throw new IOException("Setting of factory is not supported in virtual network");


        /*
        if (factory != null) {
            throw new SocketException("factory already defined");
        }
        SecurityManager security = System.getSecurityManager();
        if (security != null) {
            security.checkSetFactory();
        }
        factory = fac;
         */
    }
TestSocketServlet.java 文件源码 项目:appengine-java-vm-runtime 阅读 17 收藏 0 点赞 0 评论 0
private void testSetSocketImpl(HttpServletResponse response)
    throws IOException, AssertionFailedException {
  SocketImplFactory mockFactory =
      new SocketImplFactory() {
        @Override
        public SocketImpl createSocketImpl() {
          return null;
        }
      };

  SocketException caught = null;
  try {
    Socket.setSocketImplFactory(mockFactory);
  } catch (SocketException e) {
    caught = e;
  }
  assertNotNull("caught", caught, response);
}
JikesRVMSocketImpl.java 文件源码 项目:HeraJVM 阅读 17 收藏 0 点赞 0 评论 0
/**
 * Set up socket factories to use JikesRVMSocketImpl
 */
public static void boot() {
  try {
    Socket.setSocketImplFactory(new SocketImplFactory() {
      public SocketImpl createSocketImpl() { return new JikesRVMSocketImpl(); }
    });
    ServerSocket.setSocketFactory(new SocketImplFactory() {
      public SocketImpl createSocketImpl() { return new JikesRVMSocketImpl(); }
    });
    DatagramSocket.setDatagramSocketImplFactory(new DatagramSocketImplFactory() {
      public DatagramSocketImpl createDatagramSocketImpl() {
        throw new VM_UnimplementedError("Need to implement JikesRVMDatagramSocketImpl");
      }
    });
  } catch (java.io.IOException e) {
    VM.sysFail("trouble setting socket impl factories");
  }
}
MockServerSocket.java 文件源码 项目:evosuite 阅读 20 收藏 0 点赞 0 评论 0
public static synchronized void setSocketFactory(SocketImplFactory fac) throws IOException {
    //for explanation, see MockSocket
    throw new IOException("Setting of factory is not supported in virtual network");
}


问题


面经


文章

微信
公众号

扫码关注公众号