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

TestDatagramSocketServlet.java 文件源码 项目:appengine-java-vm-runtime 阅读 19 收藏 0 点赞 0 评论 0
private void testSetDatagramSocketImpl(HttpServletResponse response)
    throws IOException, AssertionFailedException {
  DatagramSocketImplFactory mockFactory =
      new DatagramSocketImplFactory() {
        @Override
        public DatagramSocketImpl createDatagramSocketImpl() {
          return null;
        }
      };

  SocketException caught = null;
  try {
    DatagramSocket.setDatagramSocketImplFactory(mockFactory);
  } catch (SocketException e) {
    caught = e;
  }
  assertNotNull("caught", caught, response);
}
JikesRVMSocketImpl.java 文件源码 项目:HeraJVM 阅读 20 收藏 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");
  }
}


问题


面经


文章

微信
公众号

扫码关注公众号