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

项目:OpenJSharp    文件:RMIConnector.java   
private static RMIConnection getConnection(RMIServer server,
        Object credentials,
        boolean checkStub)
        throws IOException {
    RMIConnection c = server.newClient(credentials);
    if (checkStub) checkStub(c, rmiConnectionImplStubClass);
    try {
        if (c.getClass() == rmiConnectionImplStubClass)
            return shadowJrmpStub((RemoteObject) c);
        if (c.getClass().getName().equals(iiopConnectionStubClassName))
            return shadowIiopStub(c);
        logger.trace("getConnection",
                "Did not wrap " + c.getClass() + " to foil " +
                "stack search for classes: class loading semantics " +
                "may be incorrect");
    } catch (Exception e) {
        logger.error("getConnection",
                "Could not wrap " + c.getClass() + " to foil " +
                "stack search for classes: class loading semantics " +
                "may be incorrect: " + e);
        logger.debug("getConnection",e);
        // so just return the original stub, which will work for all
        // but the most exotic class loading situations
    }
    return c;
}
项目:jdk8u-jdk    文件:RMIConnector.java   
private static RMIConnection getConnection(RMIServer server,
        Object credentials,
        boolean checkStub)
        throws IOException {
    RMIConnection c = server.newClient(credentials);
    if (checkStub) checkStub(c, rmiConnectionImplStubClass);
    try {
        if (c.getClass() == rmiConnectionImplStubClass)
            return shadowJrmpStub((RemoteObject) c);
        if (c.getClass().getName().equals(iiopConnectionStubClassName))
            return shadowIiopStub(c);
        logger.trace("getConnection",
                "Did not wrap " + c.getClass() + " to foil " +
                "stack search for classes: class loading semantics " +
                "may be incorrect");
    } catch (Exception e) {
        logger.error("getConnection",
                "Could not wrap " + c.getClass() + " to foil " +
                "stack search for classes: class loading semantics " +
                "may be incorrect: " + e);
        logger.debug("getConnection",e);
        // so just return the original stub, which will work for all
        // but the most exotic class loading situations
    }
    return c;
}
项目:jdk8u-jdk    文件:UnrecognizedRefType.java   
private static void test(RemoteObject obj) throws Exception {
    ByteArrayOutputStream bout = new ByteArrayOutputStream();
    ObjectOutputStream out = new ObjectOutputStream(bout);
    out.writeObject(obj);
    ByteArrayInputStream bin =
        new ByteArrayInputStream(bout.toByteArray());
    ObjectInputStream in = new ObjectInputStream(bin);
    try {
        Object obj2 = in.readObject();
        System.err.println(
            "Object unexpectedly deserialized successfully: " + obj2);
        throw new RuntimeException(
            "TEST FAILED: object successfully deserialized");
    } catch (ClassNotFoundException e) {
        System.err.println("ClassNotFoundException as expected:");
        e.printStackTrace();
    } // other exceptions cause test failure
}
项目:openjdk-jdk10    文件:RMIConnector.java   
private static RMIConnection getConnection(RMIServer server,
        Object credentials,
        boolean checkStub)
        throws IOException {
    RMIConnection c = server.newClient(credentials);
    if (checkStub) checkStub(c, rmiConnectionImplStubClass);
    try {
        if (c.getClass() == rmiConnectionImplStubClass)
            return shadowJrmpStub((RemoteObject) c);
        logger.trace("getConnection",
                "Did not wrap " + c.getClass() + " to foil " +
                "stack search for classes: class loading semantics " +
                "may be incorrect");
    } catch (Exception e) {
        logger.error("getConnection",
                "Could not wrap " + c.getClass() + " to foil " +
                "stack search for classes: class loading semantics " +
                "may be incorrect: " + e);
        logger.debug("getConnection",e);
        // so just return the original stub, which will work for all
        // but the most exotic class loading situations
    }
    return c;
}
项目:openjdk-jdk10    文件:UnrecognizedRefType.java   
private static void test(RemoteObject obj) throws Exception {
    ByteArrayOutputStream bout = new ByteArrayOutputStream();
    ObjectOutputStream out = new ObjectOutputStream(bout);
    out.writeObject(obj);
    ByteArrayInputStream bin =
        new ByteArrayInputStream(bout.toByteArray());
    ObjectInputStream in = new ObjectInputStream(bin);
    try {
        Object obj2 = in.readObject();
        System.err.println(
            "Object unexpectedly deserialized successfully: " + obj2);
        throw new RuntimeException(
            "TEST FAILED: object successfully deserialized");
    } catch (ClassNotFoundException e) {
        System.err.println("ClassNotFoundException as expected:");
        e.printStackTrace();
    } // other exceptions cause test failure
}
项目:openjdk9    文件:RMIConnector.java   
private static RMIConnection getConnection(RMIServer server,
        Object credentials,
        boolean checkStub)
        throws IOException {
    RMIConnection c = server.newClient(credentials);
    if (checkStub) checkStub(c, rmiConnectionImplStubClass);
    try {
        if (c.getClass() == rmiConnectionImplStubClass)
            return shadowJrmpStub((RemoteObject) c);
        logger.trace("getConnection",
                "Did not wrap " + c.getClass() + " to foil " +
                "stack search for classes: class loading semantics " +
                "may be incorrect");
    } catch (Exception e) {
        logger.error("getConnection",
                "Could not wrap " + c.getClass() + " to foil " +
                "stack search for classes: class loading semantics " +
                "may be incorrect: " + e);
        logger.debug("getConnection",e);
        // so just return the original stub, which will work for all
        // but the most exotic class loading situations
    }
    return c;
}
项目:openjdk9    文件:UnrecognizedRefType.java   
private static void test(RemoteObject obj) throws Exception {
    ByteArrayOutputStream bout = new ByteArrayOutputStream();
    ObjectOutputStream out = new ObjectOutputStream(bout);
    out.writeObject(obj);
    ByteArrayInputStream bin =
        new ByteArrayInputStream(bout.toByteArray());
    ObjectInputStream in = new ObjectInputStream(bin);
    try {
        Object obj2 = in.readObject();
        System.err.println(
            "Object unexpectedly deserialized successfully: " + obj2);
        throw new RuntimeException(
            "TEST FAILED: object successfully deserialized");
    } catch (ClassNotFoundException e) {
        System.err.println("ClassNotFoundException as expected:");
        e.printStackTrace();
    } // other exceptions cause test failure
}
项目:Java8CN    文件:RMIConnector.java   
private static RMIConnection getConnection(RMIServer server,
        Object credentials,
        boolean checkStub)
        throws IOException {
    RMIConnection c = server.newClient(credentials);
    if (checkStub) checkStub(c, rmiConnectionImplStubClass);
    try {
        if (c.getClass() == rmiConnectionImplStubClass)
            return shadowJrmpStub((RemoteObject) c);
        if (c.getClass().getName().equals(iiopConnectionStubClassName))
            return shadowIiopStub(c);
        logger.trace("getConnection",
                "Did not wrap " + c.getClass() + " to foil " +
                "stack search for classes: class loading semantics " +
                "may be incorrect");
    } catch (Exception e) {
        logger.error("getConnection",
                "Could not wrap " + c.getClass() + " to foil " +
                "stack search for classes: class loading semantics " +
                "may be incorrect: " + e);
        logger.debug("getConnection",e);
        // so just return the original stub, which will work for all
        // but the most exotic class loading situations
    }
    return c;
}
项目:jdk8u_jdk    文件:RMIConnector.java   
private static RMIConnection getConnection(RMIServer server,
        Object credentials,
        boolean checkStub)
        throws IOException {
    RMIConnection c = server.newClient(credentials);
    if (checkStub) checkStub(c, rmiConnectionImplStubClass);
    try {
        if (c.getClass() == rmiConnectionImplStubClass)
            return shadowJrmpStub((RemoteObject) c);
        if (c.getClass().getName().equals(iiopConnectionStubClassName))
            return shadowIiopStub(c);
        logger.trace("getConnection",
                "Did not wrap " + c.getClass() + " to foil " +
                "stack search for classes: class loading semantics " +
                "may be incorrect");
    } catch (Exception e) {
        logger.error("getConnection",
                "Could not wrap " + c.getClass() + " to foil " +
                "stack search for classes: class loading semantics " +
                "may be incorrect: " + e);
        logger.debug("getConnection",e);
        // so just return the original stub, which will work for all
        // but the most exotic class loading situations
    }
    return c;
}
项目:jdk8u_jdk    文件:UnrecognizedRefType.java   
private static void test(RemoteObject obj) throws Exception {
    ByteArrayOutputStream bout = new ByteArrayOutputStream();
    ObjectOutputStream out = new ObjectOutputStream(bout);
    out.writeObject(obj);
    ByteArrayInputStream bin =
        new ByteArrayInputStream(bout.toByteArray());
    ObjectInputStream in = new ObjectInputStream(bin);
    try {
        Object obj2 = in.readObject();
        System.err.println(
            "Object unexpectedly deserialized successfully: " + obj2);
        throw new RuntimeException(
            "TEST FAILED: object successfully deserialized");
    } catch (ClassNotFoundException e) {
        System.err.println("ClassNotFoundException as expected:");
        e.printStackTrace();
    } // other exceptions cause test failure
}
项目:lookaside_java-1.8.0-openjdk    文件:RMIConnector.java   
private static RMIConnection getConnection(RMIServer server,
        Object credentials,
        boolean checkStub)
        throws IOException {
    RMIConnection c = server.newClient(credentials);
    if (checkStub) checkStub(c, rmiConnectionImplStubClass);
    try {
        if (c.getClass() == rmiConnectionImplStubClass)
            return shadowJrmpStub((RemoteObject) c);
        if (c.getClass().getName().equals(iiopConnectionStubClassName))
            return shadowIiopStub(c);
        logger.trace("getConnection",
                "Did not wrap " + c.getClass() + " to foil " +
                "stack search for classes: class loading semantics " +
                "may be incorrect");
    } catch (Exception e) {
        logger.error("getConnection",
                "Could not wrap " + c.getClass() + " to foil " +
                "stack search for classes: class loading semantics " +
                "may be incorrect: " + e);
        logger.debug("getConnection",e);
        // so just return the original stub, which will work for all
        // but the most exotic class loading situations
    }
    return c;
}
项目:lookaside_java-1.8.0-openjdk    文件:UnrecognizedRefType.java   
private static void test(RemoteObject obj) throws Exception {
    ByteArrayOutputStream bout = new ByteArrayOutputStream();
    ObjectOutputStream out = new ObjectOutputStream(bout);
    out.writeObject(obj);
    ByteArrayInputStream bin =
        new ByteArrayInputStream(bout.toByteArray());
    ObjectInputStream in = new ObjectInputStream(bin);
    try {
        Object obj2 = in.readObject();
        System.err.println(
            "Object unexpectedly deserialized successfully: " + obj2);
        throw new RuntimeException(
            "TEST FAILED: object successfully deserialized");
    } catch (ClassNotFoundException e) {
        System.err.println("ClassNotFoundException as expected:");
        e.printStackTrace();
    } // other exceptions cause test failure
}
项目:javify    文件:UnicastRef.java   
/**
 * @deprecated
 */
public RemoteCall newCall(RemoteObject obj, Operation[] op, int opnum,
                          long hash) throws RemoteException
{
  UnicastConnection conn;

  try
    {
      conn = manager.getConnection();
    }
  catch (IOException e1)
    {
      throw new ConnectException("connection failed to host: "
                                 + manager.serverName, e1);
    }

  // obj: useless?

  return (new UnicastRemoteCall(conn, objid, opnum, hash));
}
项目:jvm-stm    文件:UnicastRef.java   
/**
 * @deprecated
 */
public RemoteCall newCall(RemoteObject obj, Operation[] op, int opnum,
                          long hash) throws RemoteException
{
  UnicastConnection conn;

  try
    {
      conn = manager.getConnection();
    }
  catch (IOException e1)
    {
      throw new ConnectException("connection failed to host: "
                                 + manager.serverName, e1);
    }

  // obj: useless?

  return (new UnicastRemoteCall(conn, objid, opnum, hash));
}
项目:digdag    文件:JmxAgent.java   
private static int getJmxRegistryPort(int defaultPort)
{
    try {
        Object jmxServer = getField(sun.management.Agent.class, "jmxServer");
        if (jmxServer == null) {
            logger.warn("Failed to determine JMX port: sun.management.Agent.jmxServer field is null");
        }
        else {
            Object registry = getField(sun.management.jmxremote.ConnectorBootstrap.class, "registry");
            if (registry == null) {
                logger.warn("Failed to determine JMX port: sun.management.jmxremote.ConnectorBootstrap.registry field is null");
            }
            else {
                return sun.rmi.server.UnicastRef.class.cast(RemoteObject.class.cast(registry).getRef()).getLiveRef().getPort();
            }
        }
        return defaultPort;
    }
    catch (Exception e) {
        logger.warn("Failed to determine JMX port", e);
        return defaultPort;
    }
}
项目:infobip-open-jdk-8    文件:RMIConnector.java   
private static RMIConnection getConnection(RMIServer server,
        Object credentials,
        boolean checkStub)
        throws IOException {
    RMIConnection c = server.newClient(credentials);
    if (checkStub) checkStub(c, rmiConnectionImplStubClass);
    try {
        if (c.getClass() == rmiConnectionImplStubClass)
            return shadowJrmpStub((RemoteObject) c);
        if (c.getClass().getName().equals(iiopConnectionStubClassName))
            return shadowIiopStub(c);
        logger.trace("getConnection",
                "Did not wrap " + c.getClass() + " to foil " +
                "stack search for classes: class loading semantics " +
                "may be incorrect");
    } catch (Exception e) {
        logger.error("getConnection",
                "Could not wrap " + c.getClass() + " to foil " +
                "stack search for classes: class loading semantics " +
                "may be incorrect: " + e);
        logger.debug("getConnection",e);
        // so just return the original stub, which will work for all
        // but the most exotic class loading situations
    }
    return c;
}
项目:infobip-open-jdk-8    文件:UnrecognizedRefType.java   
private static void test(RemoteObject obj) throws Exception {
    ByteArrayOutputStream bout = new ByteArrayOutputStream();
    ObjectOutputStream out = new ObjectOutputStream(bout);
    out.writeObject(obj);
    ByteArrayInputStream bin =
        new ByteArrayInputStream(bout.toByteArray());
    ObjectInputStream in = new ObjectInputStream(bin);
    try {
        Object obj2 = in.readObject();
        System.err.println(
            "Object unexpectedly deserialized successfully: " + obj2);
        throw new RuntimeException(
            "TEST FAILED: object successfully deserialized");
    } catch (ClassNotFoundException e) {
        System.err.println("ClassNotFoundException as expected:");
        e.printStackTrace();
    } // other exceptions cause test failure
}
项目:jdk8u-dev-jdk    文件:RMIConnector.java   
private static RMIConnection getConnection(RMIServer server,
        Object credentials,
        boolean checkStub)
        throws IOException {
    RMIConnection c = server.newClient(credentials);
    if (checkStub) checkStub(c, rmiConnectionImplStubClass);
    try {
        if (c.getClass() == rmiConnectionImplStubClass)
            return shadowJrmpStub((RemoteObject) c);
        if (c.getClass().getName().equals(iiopConnectionStubClassName))
            return shadowIiopStub(c);
        logger.trace("getConnection",
                "Did not wrap " + c.getClass() + " to foil " +
                "stack search for classes: class loading semantics " +
                "may be incorrect");
    } catch (Exception e) {
        logger.error("getConnection",
                "Could not wrap " + c.getClass() + " to foil " +
                "stack search for classes: class loading semantics " +
                "may be incorrect: " + e);
        logger.debug("getConnection",e);
        // so just return the original stub, which will work for all
        // but the most exotic class loading situations
    }
    return c;
}
项目:jdk8u-dev-jdk    文件:UnrecognizedRefType.java   
private static void test(RemoteObject obj) throws Exception {
    ByteArrayOutputStream bout = new ByteArrayOutputStream();
    ObjectOutputStream out = new ObjectOutputStream(bout);
    out.writeObject(obj);
    ByteArrayInputStream bin =
        new ByteArrayInputStream(bout.toByteArray());
    ObjectInputStream in = new ObjectInputStream(bin);
    try {
        Object obj2 = in.readObject();
        System.err.println(
            "Object unexpectedly deserialized successfully: " + obj2);
        throw new RuntimeException(
            "TEST FAILED: object successfully deserialized");
    } catch (ClassNotFoundException e) {
        System.err.println("ClassNotFoundException as expected:");
        e.printStackTrace();
    } // other exceptions cause test failure
}
项目:jdk7-jdk    文件:RMIConnector.java   
private static RMIConnection getConnection(RMIServer server,
        Object credentials,
        boolean checkStub)
        throws IOException {
    RMIConnection c = server.newClient(credentials);
    if (checkStub) checkStub(c, rmiConnectionImplStubClass);
    try {
        if (c.getClass() == rmiConnectionImplStubClass)
            return shadowJrmpStub((RemoteObject) c);
        if (c.getClass().getName().equals(iiopConnectionStubClassName))
            return shadowIiopStub(c);
        logger.trace("getConnection",
                "Did not wrap " + c.getClass() + " to foil " +
                "stack search for classes: class loading semantics " +
                "may be incorrect");
    } catch (Exception e) {
        logger.error("getConnection",
                "Could not wrap " + c.getClass() + " to foil " +
                "stack search for classes: class loading semantics " +
                "may be incorrect: " + e);
        logger.debug("getConnection",e);
        // so just return the original stub, which will work for all
        // but the most exotic class loading situations
    }
    return c;
}
项目:jdk7-jdk    文件:UnrecognizedRefType.java   
private static void test(RemoteObject obj) throws Exception {
    ByteArrayOutputStream bout = new ByteArrayOutputStream();
    ObjectOutputStream out = new ObjectOutputStream(bout);
    out.writeObject(obj);
    ByteArrayInputStream bin =
        new ByteArrayInputStream(bout.toByteArray());
    ObjectInputStream in = new ObjectInputStream(bin);
    try {
        Object obj2 = in.readObject();
        System.err.println(
            "Object unexpectedly deserialized successfully: " + obj2);
        throw new RuntimeException(
            "TEST FAILED: object successfully deserialized");
    } catch (ClassNotFoundException e) {
        System.err.println("ClassNotFoundException as expected:");
        e.printStackTrace();
    } // other exceptions cause test failure
}
项目:openjdk-source-code-learn    文件:RMIConnector.java   
private static RMIConnection getConnection(RMIServer server,
        Object credentials,
        boolean checkStub)
        throws IOException {
    RMIConnection c = server.newClient(credentials);
    if (checkStub) checkStub(c, rmiConnectionImplStubClass);
    try {
        if (c.getClass() == rmiConnectionImplStubClass)
            return shadowJrmpStub((RemoteObject) c);
        if (c.getClass().getName().equals(iiopConnectionStubClassName))
            return shadowIiopStub(c);
        logger.trace("getConnection",
                "Did not wrap " + c.getClass() + " to foil " +
                "stack search for classes: class loading semantics " +
                "may be incorrect");
    } catch (Exception e) {
        logger.error("getConnection",
                "Could not wrap " + c.getClass() + " to foil " +
                "stack search for classes: class loading semantics " +
                "may be incorrect: " + e);
        logger.debug("getConnection",e);
        // so just return the original stub, which will work for all
        // but the most exotic class loading situations
    }
    return c;
}
项目:openjdk-source-code-learn    文件:UnrecognizedRefType.java   
private static void test(RemoteObject obj) throws Exception {
    ByteArrayOutputStream bout = new ByteArrayOutputStream();
    ObjectOutputStream out = new ObjectOutputStream(bout);
    out.writeObject(obj);
    ByteArrayInputStream bin =
        new ByteArrayInputStream(bout.toByteArray());
    ObjectInputStream in = new ObjectInputStream(bin);
    try {
        Object obj2 = in.readObject();
        System.err.println(
            "Object unexpectedly deserialized successfully: " + obj2);
        throw new RuntimeException(
            "TEST FAILED: object successfully deserialized");
    } catch (ClassNotFoundException e) {
        System.err.println("ClassNotFoundException as expected:");
        e.printStackTrace();
    } // other exceptions cause test failure
}
项目:OLD-OpenJDK8    文件:RMIConnector.java   
private static RMIConnection getConnection(RMIServer server,
        Object credentials,
        boolean checkStub)
        throws IOException {
    RMIConnection c = server.newClient(credentials);
    if (checkStub) checkStub(c, rmiConnectionImplStubClass);
    try {
        if (c.getClass() == rmiConnectionImplStubClass)
            return shadowJrmpStub((RemoteObject) c);
        if (c.getClass().getName().equals(iiopConnectionStubClassName))
            return shadowIiopStub(c);
        logger.trace("getConnection",
                "Did not wrap " + c.getClass() + " to foil " +
                "stack search for classes: class loading semantics " +
                "may be incorrect");
    } catch (Exception e) {
        logger.error("getConnection",
                "Could not wrap " + c.getClass() + " to foil " +
                "stack search for classes: class loading semantics " +
                "may be incorrect: " + e);
        logger.debug("getConnection",e);
        // so just return the original stub, which will work for all
        // but the most exotic class loading situations
    }
    return c;
}
项目:OLD-OpenJDK8    文件:UnrecognizedRefType.java   
private static void test(RemoteObject obj) throws Exception {
    ByteArrayOutputStream bout = new ByteArrayOutputStream();
    ObjectOutputStream out = new ObjectOutputStream(bout);
    out.writeObject(obj);
    ByteArrayInputStream bin =
        new ByteArrayInputStream(bout.toByteArray());
    ObjectInputStream in = new ObjectInputStream(bin);
    try {
        Object obj2 = in.readObject();
        System.err.println(
            "Object unexpectedly deserialized successfully: " + obj2);
        throw new RuntimeException(
            "TEST FAILED: object successfully deserialized");
    } catch (ClassNotFoundException e) {
        System.err.println("ClassNotFoundException as expected:");
        e.printStackTrace();
    } // other exceptions cause test failure
}
项目:cn1    文件:ActivationID.java   
private void writeObject(ObjectOutputStream out) throws IOException, ClassNotFoundException {
    // rmi.log.0C=ActivationID.writeObject:
    rlog.log(RMILog.VERBOSE, Messages.getString("rmi.log.0C")); //$NON-NLS-1$
    try {
        out.writeObject(uid);
        // rmi.log.0D=activator = {0}
        rlog.log(RMILog.VERBOSE, Messages.getString("rmi.log.0D", activator)); //$NON-NLS-1$
        RemoteRef ref = ((RemoteObject) activator).getRef();
        // rmi.log.09=ref = {0}
        rlog.log(RMILog.VERBOSE, Messages.getString("rmi.log.09", ref)); //$NON-NLS-1$
        String refType = ref.getRefClass(out);
        // rmi.log.08=refType={0}
        rlog.log(RMILog.VERBOSE, Messages.getString("rmi.log.08", refType)); //$NON-NLS-1$
        out.writeUTF(refType);
        ref.writeExternal(out);
        // rmi.log.04=ActivationID.writeObject COMPLETED.
        rlog.log(RMILog.VERBOSE, Messages.getString("rmi.log.04")); //$NON-NLS-1$
    } catch (Throwable t) {
        // rmi.0A=Unable to serialize ActivationID: {0}
        throw new IOException(Messages.getString("rmi.0A", t.getMessage()));//$NON-NLS-1$
    }
}
项目:cn1    文件:Activatable.java   
public static Remote exportObject(Remote robj, ActivationID aid, int port)
        throws RemoteException {
    // rmi.log.10=Activatable >>> exportObject
    rlog.log(RMILog.VERBOSE, Messages.getString("rmi.log.10")); //$NON-NLS-1$
    ActivatableServerRef asr = new ActivatableServerRef(aid, port);
    if (robj instanceof Activatable) {
        ((Activatable) robj).ref = asr;
    }
    // rmi.log.11=Activatable >>> ActivatableServerRef={0}
    rlog.log(RMILog.VERBOSE, Messages.getString("rmi.log.11", asr)); //$NON-NLS-1$
    ExportManager.exportObject(robj, asr, false, true, true);
    // rmi.log.12=Activatable >>> asr after export: {0}
    rlog.log(RMILog.VERBOSE, Messages.getString("rmi.log.12", asr)); //$NON-NLS-1$
    Remote rmt = RemoteObject.toStub(robj);
    // rmi.log.13=Activatable.exportObject: stub = {0}
    rlog.log(RMILog.VERBOSE, Messages.getString("rmi.log.13", rmt)); //$NON-NLS-1$
    return rmt;
}
项目:JamVM-PH    文件:UnicastRef.java   
/**
 * @deprecated
 */
public RemoteCall newCall(RemoteObject obj, Operation[] op, int opnum,
                          long hash) throws RemoteException
{
  UnicastConnection conn;

  try
    {
      conn = manager.getConnection();
    }
  catch (IOException e1)
    {
      throw new ConnectException("connection failed to host: "
                                 + manager.serverName, e1);
    }

  // obj: useless?

  return (new UnicastRemoteCall(conn, objid, opnum, hash));
}
项目:JAVA_UNIT    文件:UnrecognizedRefType.java   
private static void test(RemoteObject obj) throws Exception {
    ByteArrayOutputStream bout = new ByteArrayOutputStream();
    ObjectOutputStream out = new ObjectOutputStream(bout);
    out.writeObject(obj);
    ByteArrayInputStream bin =
        new ByteArrayInputStream(bout.toByteArray());
    ObjectInputStream in = new ObjectInputStream(bin);
    try {
        Object obj2 = in.readObject();
        System.err.println(
            "Object unexpectedly deserialized successfully: " + obj2);
        throw new RuntimeException(
            "TEST FAILED: object successfully deserialized");
    } catch (ClassNotFoundException e) {
        System.err.println("ClassNotFoundException as expected:");
        e.printStackTrace();
    } // other exceptions cause test failure
}
项目:openjdk-jdk7u-jdk    文件:RMIConnector.java   
private static RMIConnection getConnection(RMIServer server,
        Object credentials,
        boolean checkStub)
        throws IOException {
    RMIConnection c = server.newClient(credentials);
    if (checkStub) checkStub(c, rmiConnectionImplStubClass);
    try {
        if (c.getClass() == rmiConnectionImplStubClass)
            return shadowJrmpStub((RemoteObject) c);
        if (c.getClass().getName().equals(iiopConnectionStubClassName))
            return shadowIiopStub(c);
        logger.trace("getConnection",
                "Did not wrap " + c.getClass() + " to foil " +
                "stack search for classes: class loading semantics " +
                "may be incorrect");
    } catch (Exception e) {
        logger.error("getConnection",
                "Could not wrap " + c.getClass() + " to foil " +
                "stack search for classes: class loading semantics " +
                "may be incorrect: " + e);
        logger.debug("getConnection",e);
        // so just return the original stub, which will work for all
        // but the most exotic class loading situations
    }
    return c;
}
项目:openjdk-jdk7u-jdk    文件:UnrecognizedRefType.java   
private static void test(RemoteObject obj) throws Exception {
    ByteArrayOutputStream bout = new ByteArrayOutputStream();
    ObjectOutputStream out = new ObjectOutputStream(bout);
    out.writeObject(obj);
    ByteArrayInputStream bin =
        new ByteArrayInputStream(bout.toByteArray());
    ObjectInputStream in = new ObjectInputStream(bin);
    try {
        Object obj2 = in.readObject();
        System.err.println(
            "Object unexpectedly deserialized successfully: " + obj2);
        throw new RuntimeException(
            "TEST FAILED: object successfully deserialized");
    } catch (ClassNotFoundException e) {
        System.err.println("ClassNotFoundException as expected:");
        e.printStackTrace();
    } // other exceptions cause test failure
}
项目:classpath    文件:UnicastRef.java   
/**
 * @deprecated
 */
public RemoteCall newCall(RemoteObject obj, Operation[] op, int opnum,
                          long hash) throws RemoteException
{
  UnicastConnection conn;

  try
    {
      conn = manager.getConnection();
    }
  catch (IOException e1)
    {
      throw new ConnectException("connection failed to host: "
                                 + manager.serverName, e1);
    }

  // obj: useless?

  return (new UnicastRemoteCall(conn, objid, opnum, hash));
}
项目:freeVM    文件:RMIObjectOutputStream.java   
/**
 * Returns a stub if the object to be serialized is a
 * {@link java.rmi.Remote} instance.
 * 
 * @param obj
 *            the object to be replaced if needed be.
 * @return if the argument was a {@link java.rmi.Remote} object locally
 *         exported a stub for that object is returned, in case it is not a
 *         {@link java.rmi.Remote} the object is returned
 * @throws IOException
 *             if the I/O operation fails
 */
@Override
protected final Object replaceObject(Object obj) throws IOException {

    if (obj instanceof Remote) {
        RemoteReferenceManager rrm = RemoteReferenceManager
                .getRemoteReferenceManager();
        if (rrm.isExported((Remote) obj)) {
            writesRemote = true;
            return RemoteObject.toStub((Remote) obj);
        }
        if (obj instanceof RemoteStub) {
            writesRemote = true;
            return obj;
        }
        if (Proxy.isProxyClass(obj.getClass())) {
            InvocationHandler ih = Proxy.getInvocationHandler(obj);
            if (ih instanceof RemoteObjectInvocationHandler) {
                writesRemote = true;
            }
        }
    }
    return obj;
}
项目:freeVM    文件:RMIObjectOutputStream.java   
/**
 * Returns a stub if the object to be serialized is a
 * {@link java.rmi.Remote} instance.
 * 
 * @param obj
 *            the object to be replaced if needed be.
 * @return if the argument was a {@link java.rmi.Remote} object locally
 *         exported a stub for that object is returned, in case it is not a
 *         {@link java.rmi.Remote} the object is returned
 * @throws IOException
 *             if the I/O operation fails
 */
@Override
protected final Object replaceObject(Object obj) throws IOException {

    if (obj instanceof Remote) {
        RemoteReferenceManager rrm = RemoteReferenceManager
                .getRemoteReferenceManager();
        if (rrm.isExported((Remote) obj)) {
            writesRemote = true;
            return RemoteObject.toStub((Remote) obj);
        }
        if (obj instanceof RemoteStub) {
            writesRemote = true;
            return obj;
        }
        if (Proxy.isProxyClass(obj.getClass())) {
            InvocationHandler ih = Proxy.getInvocationHandler(obj);
            if (ih instanceof RemoteObjectInvocationHandler) {
                writesRemote = true;
            }
        }
    }
    return obj;
}
项目:freeVM    文件:TestUnicastRemoteObject.java   
/**
 * Unexport an Echo extends UnicastRemoteObject without force in the middle
 * of a call. This methods finishes normally, and the object continuous
 * exported.
 * 
 */

public void testUnexportObjectRemoteBoolean007() throws RemoteException {
    Echo e = new EchoUnicast_Imp() {
        private static final long serialVersionUID = 1L;

        public String echo(String msg) throws RemoteException {
            msgCount += 1;
            try {
                assertFalse("The object can't unexport",
                        UnicastRemoteObject.unexportObject(this, false));
            } catch (Throwable ex) {
                fail("Failed with:" + ex);
            }
            return EchoUnicast_Imp.class + " - Have said: " + msg;
        }
    };

    ((Echo) RemoteObject.toStub(e)).echo("hello");

}
项目:freeVM    文件:TestUnicastRemoteObject.java   
/**
 * Unexport an Echo extends UnicastRemoteObject with stub without force in
 * the middle of a call. This methods finishes normally, and the object
 * continuous exported.
 * 
 */
public void testUnexportObjectRemoteBoolean008() throws RemoteException {
    Echo e = new EchoWithStubUnicast_Imp() {
        private static final long serialVersionUID = 1L;

        public String echo(String msg) throws RemoteException {
            // ("Se recibio mensaje: " + msg);
            msgCount += 1;
            try {
                assertFalse("The object can't unexport",
                        UnicastRemoteObject.unexportObject(this, false));
            } catch (Throwable ex) {
                fail("Failed with:" + ex);
            }
            return EchoUnicast_Imp.class + " - Have said: " + msg;
        }
    };

    ((Echo) RemoteObject.toStub(e)).echo("hello");

}
项目:freeVM    文件:TestRemoteObjectInvocationHandler.java   
public final void testInvoke004() throws RemoteException {
    EchoUnicast_Imp eui = new EchoUnicast_Imp() {
        public String echo(String msg) throws RemoteException {
            return msg;
        }
    };
    RemoteRef ref = eui.getRef();
    Echo proxy = (Echo) RemoteObject.toStub(eui);
    String toSend = "hola invoquer";
    try {
        r = new RemoteObjectInvocationHandler(ref);
        assertEquals("The result is what we expect", toSend, r.invoke(
                proxy, Echo.class.getMethods()[0], new Object[] { toSend }));
    } catch (Throwable e) {
        fail("Failed with:" + e);
    }
}
项目:freeVM    文件:TestRemoteObjectInvocationHandler.java   
public final void testInvoke008() throws RemoteException {
    EchoUnicast_Imp eui = new EchoUnicast_Imp() {
        public String echo(String msg) throws RemoteException {
            return msg;
        }
    };
    RemoteRef ref = eui.getRef();
    Echo proxy = (Echo) RemoteObject.toStub(eui);
    String toSend = "hola invoquer";
    try {
        r = new RemoteObjectInvocationHandler(ref);
        assertEquals("The result is what we expected", toSend, r.invoke(
                proxy, Echo.class.getMethods()[0], new Object[] { toSend,
                        toSend }));
    } catch (Throwable e) {
        fail("Failed with:" + e);
    }
}
项目:freeVM    文件:TestRemoteObjectInvocationHandler.java   
public final void testInvoke011() throws RemoteException {
    BigEcho_imp bei = new BigEcho_imp() {
        public void echo() throws RemoteException {
            throw new RemoteException("Always pass throw here");
        }

        public void echo(Object... objs) throws RemoteException {
            if (objs == null) {
                throw new RemoteException("Objs Null");
            }
        }
    };
    RemoteRef ref = bei.getRef();
    BigEcho proxy = (BigEcho) RemoteObject.toStub(bei);
    try {
        r = new RemoteObjectInvocationHandler(ref);
        assertNull(r.invoke(proxy, BigEcho.class.getMethods()[1],
                new Object[] { new Object[] { 1, 2, 3, 4 } }));
    } catch (Throwable e) {
        fail("Failed with:" + e);
    }
}
项目:freeVM    文件:TestRemoteObjectInvocationHandler.java   
public final void testInvoke012() throws RemoteException {
    BigEcho_imp bei = new BigEcho_imp() {
        public void echo() throws RemoteException {
            throw new RemoteException("Always pass throw here");
        }

        public void echo(Object... objs) throws RemoteException {
            if (objs == null) {
                throw new RemoteException("Objs Null");
            }
        }
    };
    RemoteRef ref = bei.getRef();
    BigEcho proxy = (BigEcho) RemoteObject.toStub(bei);
    try {
        r = new RemoteObjectInvocationHandler(ref);
        assertNull(r.invoke(proxy, BigEcho.class.getMethods()[1],
                new Object[] { new Object[] {} }));
    } catch (Throwable e) {
        fail("Failed with:" + e);
    }
}