Java 类java.rmi.server.RMISocketFactory 实例源码

项目:jdk8u-jdk    文件:CloseServerSocketOnTermination.java   
public static void main(String[] args) throws Exception {
    System.err.println("\nRegression test for bug 4924577\n");

    RMISocketFactory.setFailureHandler(new RMIFailureHandler() {
        public boolean failure(Exception e) { return false; }
    });

    tryWith(new IOException());
    tryWith(new NullPointerException());
    tryWith(new OutOfMemoryError());
    tryWith(new NoClassDefFoundError());
    tryWith(new InternalError());
    tryWith(new Throwable());

    System.err.println("TEST PASSED");
}
项目:jdk8u-jdk    文件:SetFactoryPermission.java   
public static void main (String[] args) throws Exception {
    if (args.length > 0) {
        success = System.getSecurityManager() == null || args[0].equals("success");
    }

    doTest(()->{
        System.out.println("Verify URLConnection.setContentHandlerFactor()");
        URLConnection.setContentHandlerFactory(null);
    });
    doTest(()->{
        System.out.println("Verify URL.setURLStreamHandlerFactory()");
        URL.setURLStreamHandlerFactory(null);
    });
    doTest(()->{
        System.out.println("Verify ServerSocket.setSocketFactory()");
        ServerSocket.setSocketFactory(null);
    });
    doTest(()->{
        System.out.println("Verify Socket.setSocketImplFactory()");
        Socket.setSocketImplFactory(null);
    });
    doTest(()->{
        System.out.println("Verify RMISocketFactory.setSocketFactory()");
        RMISocketFactory.setSocketFactory(null);
    });
}
项目:openjdk-jdk10    文件:CloseServerSocketOnTermination.java   
public static void main(String[] args) throws Exception {
    System.err.println("\nRegression test for bug 4924577\n");

    RMISocketFactory.setFailureHandler(new RMIFailureHandler() {
        public boolean failure(Exception e) { return false; }
    });

    tryWith(new IOException());
    tryWith(new NullPointerException());
    tryWith(new OutOfMemoryError());
    tryWith(new NoClassDefFoundError());
    tryWith(new InternalError());
    tryWith(new Throwable());

    System.err.println("TEST PASSED");
}
项目:openjdk-jdk10    文件:SetFactoryPermission.java   
public static void main (String[] args) throws Exception {
    if (args.length > 0) {
        success = System.getSecurityManager() == null || args[0].equals("success");
    }

    doTest(()->{
        System.out.println("Verify URLConnection.setContentHandlerFactor()");
        URLConnection.setContentHandlerFactory(null);
    });
    doTest(()->{
        System.out.println("Verify URL.setURLStreamHandlerFactory()");
        URL.setURLStreamHandlerFactory(null);
    });
    doTest(()->{
        System.out.println("Verify ServerSocket.setSocketFactory()");
        ServerSocket.setSocketFactory(null);
    });
    doTest(()->{
        System.out.println("Verify Socket.setSocketImplFactory()");
        Socket.setSocketImplFactory(null);
    });
    doTest(()->{
        System.out.println("Verify RMISocketFactory.setSocketFactory()");
        RMISocketFactory.setSocketFactory(null);
    });
}
项目:openjdk9    文件:CloseServerSocketOnTermination.java   
public static void main(String[] args) throws Exception {
    System.err.println("\nRegression test for bug 4924577\n");

    RMISocketFactory.setFailureHandler(new RMIFailureHandler() {
        public boolean failure(Exception e) { return false; }
    });

    tryWith(new IOException());
    tryWith(new NullPointerException());
    tryWith(new OutOfMemoryError());
    tryWith(new NoClassDefFoundError());
    tryWith(new InternalError());
    tryWith(new Throwable());

    System.err.println("TEST PASSED");
}
项目:openjdk9    文件:SetFactoryPermission.java   
public static void main (String[] args) throws Exception {
    if (args.length > 0) {
        success = System.getSecurityManager() == null || args[0].equals("success");
    }

    doTest(()->{
        System.out.println("Verify URLConnection.setContentHandlerFactor()");
        URLConnection.setContentHandlerFactory(null);
    });
    doTest(()->{
        System.out.println("Verify URL.setURLStreamHandlerFactory()");
        URL.setURLStreamHandlerFactory(null);
    });
    doTest(()->{
        System.out.println("Verify ServerSocket.setSocketFactory()");
        ServerSocket.setSocketFactory(null);
    });
    doTest(()->{
        System.out.println("Verify Socket.setSocketImplFactory()");
        Socket.setSocketImplFactory(null);
    });
    doTest(()->{
        System.out.println("Verify RMISocketFactory.setSocketFactory()");
        RMISocketFactory.setSocketFactory(null);
    });
}
项目:jdk8u_jdk    文件:CloseServerSocketOnTermination.java   
public static void main(String[] args) throws Exception {
    System.err.println("\nRegression test for bug 4924577\n");

    RMISocketFactory.setFailureHandler(new RMIFailureHandler() {
        public boolean failure(Exception e) { return false; }
    });

    tryWith(new IOException());
    tryWith(new NullPointerException());
    tryWith(new OutOfMemoryError());
    tryWith(new NoClassDefFoundError());
    tryWith(new InternalError());
    tryWith(new Throwable());

    System.err.println("TEST PASSED");
}
项目:jdk8u_jdk    文件:SetFactoryPermission.java   
public static void main (String[] args) throws Exception {
    if (args.length > 0) {
        success = System.getSecurityManager() == null || args[0].equals("success");
    }

    doTest(()->{
        System.out.println("Verify URLConnection.setContentHandlerFactor()");
        URLConnection.setContentHandlerFactory(null);
    });
    doTest(()->{
        System.out.println("Verify URL.setURLStreamHandlerFactory()");
        URL.setURLStreamHandlerFactory(null);
    });
    doTest(()->{
        System.out.println("Verify ServerSocket.setSocketFactory()");
        ServerSocket.setSocketFactory(null);
    });
    doTest(()->{
        System.out.println("Verify Socket.setSocketImplFactory()");
        Socket.setSocketImplFactory(null);
    });
    doTest(()->{
        System.out.println("Verify RMISocketFactory.setSocketFactory()");
        RMISocketFactory.setSocketFactory(null);
    });
}
项目:lookaside_java-1.8.0-openjdk    文件:CloseServerSocketOnTermination.java   
public static void main(String[] args) throws Exception {
    System.err.println("\nRegression test for bug 4924577\n");

    RMISocketFactory.setFailureHandler(new RMIFailureHandler() {
        public boolean failure(Exception e) { return false; }
    });

    tryWith(new IOException());
    tryWith(new NullPointerException());
    tryWith(new OutOfMemoryError());
    tryWith(new NoClassDefFoundError());
    tryWith(new InternalError());
    tryWith(new Throwable());

    System.err.println("TEST PASSED");
}
项目:lookaside_java-1.8.0-openjdk    文件:SetFactoryPermission.java   
public static void main (String[] args) throws Exception {
    if (args.length > 0) {
        success = System.getSecurityManager() == null || args[0].equals("success");
    }

    doTest(()->{
        System.out.println("Verify URLConnection.setContentHandlerFactor()");
        URLConnection.setContentHandlerFactory(null);
    });
    doTest(()->{
        System.out.println("Verify URL.setURLStreamHandlerFactory()");
        URL.setURLStreamHandlerFactory(null);
    });
    doTest(()->{
        System.out.println("Verify ServerSocket.setSocketFactory()");
        ServerSocket.setSocketFactory(null);
    });
    doTest(()->{
        System.out.println("Verify Socket.setSocketImplFactory()");
        Socket.setSocketImplFactory(null);
    });
    doTest(()->{
        System.out.println("Verify RMISocketFactory.setSocketFactory()");
        RMISocketFactory.setSocketFactory(null);
    });
}
项目:infobip-open-jdk-8    文件:CloseServerSocketOnTermination.java   
public static void main(String[] args) throws Exception {
    System.err.println("\nRegression test for bug 4924577\n");

    RMISocketFactory.setFailureHandler(new RMIFailureHandler() {
        public boolean failure(Exception e) { return false; }
    });

    tryWith(new IOException());
    tryWith(new NullPointerException());
    tryWith(new OutOfMemoryError());
    tryWith(new NoClassDefFoundError());
    tryWith(new InternalError());
    tryWith(new Throwable());

    System.err.println("TEST PASSED");
}
项目:jdk8u-dev-jdk    文件:CloseServerSocketOnTermination.java   
public static void main(String[] args) throws Exception {
    System.err.println("\nRegression test for bug 4924577\n");

    RMISocketFactory.setFailureHandler(new RMIFailureHandler() {
        public boolean failure(Exception e) { return false; }
    });

    tryWith(new IOException());
    tryWith(new NullPointerException());
    tryWith(new OutOfMemoryError());
    tryWith(new NoClassDefFoundError());
    tryWith(new InternalError());
    tryWith(new Throwable());

    System.err.println("TEST PASSED");
}
项目:haox    文件:Test.java   
public static void main(String[] args) throws Exception {
    System.setProperty(RMISocketFactoryImpl.RMI_HOSTNAME_KEY, "localhost");
    RMISocketFactoryImpl impl = new RMISocketFactoryImpl();
    RMISocketFactory.setSocketFactory(impl);

    if (args.length > 0) {

    } else {
        Test.requireNameServer();
        Test.rebindTest();

        IntegerRMI remoteInt = new IntegerRMI();
        Test.rebind(TEST_INT_NAME, remoteInt);
    }

    Object o = Test.lookup(TEST_DATE_NAME);
    RemoteDate rd = (RemoteDate) o;
    System.out.println("The remote-date is: " + rd.getDate());

    o = Test.lookup(TEST_INT_NAME);
    RemoteInteger ri = (RemoteInteger) o;
    System.out.println("The remote-int  is: " + ri.getInt());

}
项目:jdk7-jdk    文件:CloseServerSocketOnTermination.java   
public static void main(String[] args) throws Exception {
    System.err.println("\nRegression test for bug 4924577\n");

    RMISocketFactory.setFailureHandler(new RMIFailureHandler() {
        public boolean failure(Exception e) { return false; }
    });

    tryWith(new IOException());
    tryWith(new NullPointerException());
    tryWith(new OutOfMemoryError());
    tryWith(new NoClassDefFoundError());
    tryWith(new InternalError());
    tryWith(new Throwable());

    System.err.println("TEST PASSED");
}
项目:openjdk-source-code-learn    文件:CloseServerSocketOnTermination.java   
public static void main(String[] args) throws Exception {
    System.err.println("\nRegression test for bug 4924577\n");

    RMISocketFactory.setFailureHandler(new RMIFailureHandler() {
        public boolean failure(Exception e) { return false; }
    });

    tryWith(new IOException());
    tryWith(new NullPointerException());
    tryWith(new OutOfMemoryError());
    tryWith(new NoClassDefFoundError());
    tryWith(new InternalError());
    tryWith(new Throwable());

    System.err.println("TEST PASSED");
}
项目:OLD-OpenJDK8    文件:CloseServerSocketOnTermination.java   
public static void main(String[] args) throws Exception {
    System.err.println("\nRegression test for bug 4924577\n");

    RMISocketFactory.setFailureHandler(new RMIFailureHandler() {
        public boolean failure(Exception e) { return false; }
    });

    tryWith(new IOException());
    tryWith(new NullPointerException());
    tryWith(new OutOfMemoryError());
    tryWith(new NoClassDefFoundError());
    tryWith(new InternalError());
    tryWith(new Throwable());

    System.err.println("TEST PASSED");
}
项目:JAVA_UNIT    文件:CloseServerSocketOnTermination.java   
public static void main(String[] args) throws Exception {
    System.err.println("\nRegression test for bug 4924577\n");

    RMISocketFactory.setFailureHandler(new RMIFailureHandler() {
        public boolean failure(Exception e) { return false; }
    });

    tryWith(new IOException());
    tryWith(new NullPointerException());
    tryWith(new OutOfMemoryError());
    tryWith(new NoClassDefFoundError());
    tryWith(new InternalError());
    tryWith(new Throwable());

    System.err.println("TEST PASSED");
}
项目:openjdk-jdk7u-jdk    文件:CloseServerSocketOnTermination.java   
public static void main(String[] args) throws Exception {
    System.err.println("\nRegression test for bug 4924577\n");

    RMISocketFactory.setFailureHandler(new RMIFailureHandler() {
        public boolean failure(Exception e) { return false; }
    });

    tryWith(new IOException());
    tryWith(new NullPointerException());
    tryWith(new OutOfMemoryError());
    tryWith(new NoClassDefFoundError());
    tryWith(new InternalError());
    tryWith(new Throwable());

    System.err.println("TEST PASSED");
}
项目:freeVM    文件:ClientConnectionFactory.java   
static final AbstractClientConnection getClientConnection(Endpoint ep)
        throws IOException, UnknownHostException, ConnectException,
        ConnectIOException {
    Socket sock = null;
    AbstractClientConnection ret;

    RMIClientSocketFactory csf = (ep.getCsf() != null) ? ep.getCsf()
            : RMISocketFactory.getSocketFactory();
    if (csf == null) {
        csf = RMISocketFactory.getDefaultSocketFactory();
    }
    sock = csf.createSocket(ep.getEndpointID().getHost(), ep.getPort());
    if (SO_TIME_OUT != 0) {
        sock.setSoTimeout(SO_TIME_OUT);
    }
    sock.setTcpNoDelay(true);
    if (sock instanceof HttpSocketClientSide) {
        ret = new SingleOpClientConnection(sock, ep);
    } else {
        ret = new StreamClientConnection(sock, ep);
    }
    return ret;
}
项目:freeVM    文件:Util.java   
public static RMISocketFactory getSunSocketFactory(String type) {
    if (type.equalsIgnoreCase("default")) {
        System.out.println("No forced SocketFactory, enabled DefaultSocketFactory supporting Fallback mode");
        return new RMIDirectSocketFactory();
    } else if (type.equalsIgnoreCase("cgi")) {
        System.out.println("RMIToCGISocketFactory enabled...");
        return new RMIHttpToCGISocketFactory();    
    } else if (type.equalsIgnoreCase("http")) {
        System.out.println("RMIHttpToPortSocketFactory enabled...");
        return new RMIHttpToPortSocketFactory();
    } else if (type.equalsIgnoreCase("direct")) {
        System.out.println("RMIDirectSocketFactory enabled...");
        return new RMIDirectSocketFactory();
    }
    return new RMIDirectSocketFactory(); // if null returns default socket factory
}
项目:freeVM    文件:ClientConnectionFactory.java   
static final AbstractClientConnection getClientConnection(Endpoint ep)
        throws IOException, UnknownHostException, ConnectException,
        ConnectIOException {
    Socket sock = null;
    AbstractClientConnection ret;

    RMIClientSocketFactory csf = (ep.getCsf() != null) ? ep.getCsf()
            : RMISocketFactory.getSocketFactory();
    if (csf == null) {
        csf = RMISocketFactory.getDefaultSocketFactory();
    }
    sock = csf.createSocket(ep.getEndpointID().getHost(), ep.getPort());
    if (SO_TIME_OUT != 0) {
        sock.setSoTimeout(SO_TIME_OUT);
    }
    sock.setTcpNoDelay(true);
    if (sock instanceof HttpSocketClientSide) {
        ret = new SingleOpClientConnection(sock, ep);
    } else {
        ret = new StreamClientConnection(sock, ep);
    }
    return ret;
}
项目:openjdk-icedtea7    文件:CloseServerSocketOnTermination.java   
public static void main(String[] args) throws Exception {
    System.err.println("\nRegression test for bug 4924577\n");

    RMISocketFactory.setFailureHandler(new RMIFailureHandler() {
        public boolean failure(Exception e) { return false; }
    });

    tryWith(new IOException());
    tryWith(new NullPointerException());
    tryWith(new OutOfMemoryError());
    tryWith(new NoClassDefFoundError());
    tryWith(new InternalError());
    tryWith(new Throwable());

    System.err.println("TEST PASSED");
}
项目:OpenJSharp    文件:RMIMasterSocketFactory.java   
/**
 * Remember a successful factory for connecting to host.
 * Currently, excess hosts are removed from the remembered list
 * using a Least Recently Created strategy.
 */
void rememberFactory(String host, RMISocketFactory factory) {
    synchronized (successTable) {
        while (hostList.size() >= MaxRememberedHosts) {
            successTable.remove(hostList.elementAt(0));
            hostList.removeElementAt(0);
        }
        hostList.addElement(host);
        successTable.put(host, factory);
    }
}
项目:OpenJSharp    文件:RMIMasterSocketFactory.java   
/**
 * Create a new asynchronous connector object.
 */
AsyncConnector(RMISocketFactory factory, String host, int port,
               AccessControlContext acc)
{
    this.factory = factory;
    this.host    = host;
    this.port    = port;
    this.acc     = acc;
    SecurityManager security = System.getSecurityManager();
    if (security != null) {
        security.checkConnect(host, port);
    }
}
项目:OpenJSharp    文件:TCPEndpoint.java   
private static RMISocketFactory chooseFactory() {
    RMISocketFactory sf = RMISocketFactory.getSocketFactory();
    if (sf == null) {
        sf = TCPTransport.defaultSocketFactory;
    }
    return sf;
}
项目:OpenJSharp    文件:TCPTransport.java   
/**
 * Returns true if the accept loop should continue after the
 * specified exception has been caught, or false if the accept
 * loop should terminate (closing the server socket).  If
 * there is an RMIFailureHandler, this method returns the
 * result of passing the specified exception to it; otherwise,
 * this method always returns true, after sleeping to throttle
 * the accept loop if necessary.
 **/
private boolean continueAfterAcceptFailure(Throwable t) {
    RMIFailureHandler fh = RMISocketFactory.getFailureHandler();
    if (fh != null) {
        return fh.failure(t instanceof Exception ? (Exception) t :
                          new InvocationTargetException(t));
    } else {
        throttleLoopOnException();
        return true;
    }
}
项目:OpenJSharp    文件:ActivationGroupImpl.java   
public ServerSocket createServerSocket(int port) throws IOException
{
    RMISocketFactory sf = RMISocketFactory.getSocketFactory();
    if (sf == null) {
        sf = RMISocketFactory.getDefaultSocketFactory();
    }
    return sf.createServerSocket(port);
}
项目:jdk8u-jdk    文件:RMIMasterSocketFactory.java   
/**
 * Remember a successful factory for connecting to host.
 * Currently, excess hosts are removed from the remembered list
 * using a Least Recently Created strategy.
 */
void rememberFactory(String host, RMISocketFactory factory) {
    synchronized (successTable) {
        while (hostList.size() >= MaxRememberedHosts) {
            successTable.remove(hostList.elementAt(0));
            hostList.removeElementAt(0);
        }
        hostList.addElement(host);
        successTable.put(host, factory);
    }
}
项目:jdk8u-jdk    文件:RMIMasterSocketFactory.java   
/**
 * Create a new asynchronous connector object.
 */
AsyncConnector(RMISocketFactory factory, String host, int port,
               AccessControlContext acc)
{
    this.factory = factory;
    this.host    = host;
    this.port    = port;
    this.acc     = acc;
    SecurityManager security = System.getSecurityManager();
    if (security != null) {
        security.checkConnect(host, port);
    }
}
项目:jdk8u-jdk    文件:TCPEndpoint.java   
private static RMISocketFactory chooseFactory() {
    RMISocketFactory sf = RMISocketFactory.getSocketFactory();
    if (sf == null) {
        sf = TCPTransport.defaultSocketFactory;
    }
    return sf;
}
项目:jdk8u-jdk    文件:TCPTransport.java   
/**
 * Returns true if the accept loop should continue after the
 * specified exception has been caught, or false if the accept
 * loop should terminate (closing the server socket).  If
 * there is an RMIFailureHandler, this method returns the
 * result of passing the specified exception to it; otherwise,
 * this method always returns true, after sleeping to throttle
 * the accept loop if necessary.
 **/
private boolean continueAfterAcceptFailure(Throwable t) {
    RMIFailureHandler fh = RMISocketFactory.getFailureHandler();
    if (fh != null) {
        return fh.failure(t instanceof Exception ? (Exception) t :
                          new InvocationTargetException(t));
    } else {
        throttleLoopOnException();
        return true;
    }
}
项目:jdk8u-jdk    文件:ActivationGroupImpl.java   
public ServerSocket createServerSocket(int port) throws IOException
{
    RMISocketFactory sf = RMISocketFactory.getSocketFactory();
    if (sf == null) {
        sf = RMISocketFactory.getDefaultSocketFactory();
    }
    return sf.createServerSocket(port);
}
项目:jdk8u-jdk    文件:UnderscoreHost.java   
public static void main(String args[]) {
    UnderscoreHost t = null;
    try {
        HostVerifyingSocketFactory hvf = new HostVerifyingSocketFactory();
        RMISocketFactory.setSocketFactory(hvf);
        Registry r = TestLibrary.createRegistryOnUnusedPort();
        int port = TestLibrary.getRegistryPort(r);
        t = new UnderscoreHost();
        r.rebind(NAME, t);
        Naming.lookup("rmi://" + HOSTNAME +
                      ":" + port + "/" + NAME);
        /*
         * This test is coded to pass whether java.net.URI obeys
         * RFC 2396 or RFC 3986 (see 5085902, 6394131, etc.).
         *
         * If java.net.URI obeys RFC 3986, so host names may
         * contain underscores, then the Naming.lookup invocation
         * should succeed-- but the host actually connected to
         * must equal HOSTNAME.
         */
        if (!hvf.host.equals(HOSTNAME)) {
            throw new RuntimeException(
                "java.rmi.Naming Parsing error:" +
                hvf.host + ":" + HOSTNAME);
        }
    } catch (MalformedURLException e) {
        /*
         * If java.net.URI obeys RFC 2396, so host names must not
         * contain underscores, then the Naming.lookup invocation
         * should throw MalformedURLException-- so this is OK.
         */
    } catch (IOException ioe) {
        TestLibrary.bomb(ioe);
    } catch (java.rmi.NotBoundException nbe) {
        TestLibrary.bomb(nbe);
    } finally {
        TestLibrary.unexport(t);
    }

}
项目:jdk8u-jdk    文件:ReuseDefaultPort.java   
public static void main(String[] args) throws Exception {
    System.err.println("\nRegression test for bug 6269166\n");
    RMISocketFactory.setSocketFactory(new SF());
    Remote impl = new ReuseDefaultPort();
    Remote stub = UnicastRemoteObject.exportObject(impl, 0);
    System.err.println("- exported object: " + stub);
    try {
        Registry registry = LocateRegistry.createRegistry(PORT);
        System.err.println("- exported registry: " + registry);
        System.err.println("TEST PASSED");
    } finally {
        UnicastRemoteObject.unexportObject(impl, true);
    }
}
项目:openjdk-jdk10    文件:TCPEndpoint.java   
private static RMISocketFactory chooseFactory() {
    RMISocketFactory sf = RMISocketFactory.getSocketFactory();
    if (sf == null) {
        sf = TCPTransport.defaultSocketFactory;
    }
    return sf;
}
项目:openjdk-jdk10    文件:TCPTransport.java   
/**
 * Returns true if the accept loop should continue after the
 * specified exception has been caught, or false if the accept
 * loop should terminate (closing the server socket).  If
 * there is an RMIFailureHandler, this method returns the
 * result of passing the specified exception to it; otherwise,
 * this method always returns true, after sleeping to throttle
 * the accept loop if necessary.
 **/
private boolean continueAfterAcceptFailure(Throwable t) {
    RMIFailureHandler fh = RMISocketFactory.getFailureHandler();
    if (fh != null) {
        return fh.failure(t instanceof Exception ? (Exception) t :
                          new InvocationTargetException(t));
    } else {
        throttleLoopOnException();
        return true;
    }
}
项目:openjdk-jdk10    文件:ActivationGroupImpl.java   
public ServerSocket createServerSocket(int port) throws IOException
{
    RMISocketFactory sf = RMISocketFactory.getSocketFactory();
    if (sf == null) {
        sf = RMISocketFactory.getDefaultSocketFactory();
    }
    return sf.createServerSocket(port);
}
项目:openjdk-jdk10    文件:UnderscoreHost.java   
public static void main(String args[]) {
    UnderscoreHost t = null;
    try {
        HostVerifyingSocketFactory hvf = new HostVerifyingSocketFactory();
        RMISocketFactory.setSocketFactory(hvf);
        Registry r = TestLibrary.createRegistryOnEphemeralPort();
        int port = TestLibrary.getRegistryPort(r);
        t = new UnderscoreHost();
        r.rebind(NAME, t);
        Naming.lookup("rmi://" + HOSTNAME +
                      ":" + port + "/" + NAME);
        /*
         * This test is coded to pass whether java.net.URI obeys
         * RFC 2396 or RFC 3986 (see 5085902, 6394131, etc.).
         *
         * If java.net.URI obeys RFC 3986, so host names may
         * contain underscores, then the Naming.lookup invocation
         * should succeed-- but the host actually connected to
         * must equal HOSTNAME.
         */
        if (!hvf.host.equals(HOSTNAME)) {
            throw new RuntimeException(
                "java.rmi.Naming Parsing error:" +
                hvf.host + ":" + HOSTNAME);
        }
    } catch (MalformedURLException e) {
        /*
         * If java.net.URI obeys RFC 2396, so host names must not
         * contain underscores, then the Naming.lookup invocation
         * should throw MalformedURLException-- so this is OK.
         */
    } catch (IOException ioe) {
        TestLibrary.bomb(ioe);
    } catch (java.rmi.NotBoundException nbe) {
        TestLibrary.bomb(nbe);
    } finally {
        TestLibrary.unexport(t);
    }

}
项目:openjdk-jdk10    文件:ReuseDefaultPort.java   
public static void main(String[] args) throws Exception {
    System.err.println("\nRegression test for bug 6269166\n");
    RMISocketFactory.setSocketFactory(new SF());
    Remote impl = new ReuseDefaultPort();
    Remote stub = UnicastRemoteObject.exportObject(impl, 0);
    System.err.println("- exported object: " + stub);
    try {
        Registry registry = LocateRegistry.createRegistry(rmiPort);
        System.err.println("- exported registry: " + registry);
        System.err.println("TEST PASSED");
    } finally {
        UnicastRemoteObject.unexportObject(impl, true);
    }
}
项目:openjdk-jdk10    文件:TestSocketFactory.java   
@Override
public Socket createSocket(String host, int port) throws IOException {
    Socket socket = RMISocketFactory.getDefaultSocketFactory()
            .createSocket(host, port);
    InterposeSocket s = new InterposeSocket(socket,
            triggerBytes, matchBytes, replaceBytes);
    sockets.add(s);
    return s;
}