Java 类java.rmi.MarshalException 实例源码

项目:OpenJSharp    文件:StreamRemoteCall.java   
public StreamRemoteCall(Connection c, ObjID id, int op, long hash)
    throws RemoteException
{
    try {
        conn = c;
        Transport.transportLog.log(Log.VERBOSE,
            "write remote call header...");

        // write out remote call header info...
        // call header, part 1 (read by Transport)
        conn.getOutputStream().write(TransportConstants.Call);
        getOutputStream();           // creates a MarshalOutputStream
        id.write(out);               // object id (target of call)
        // call header, part 2 (read by Dispatcher)
        out.writeInt(op);            // method number (operation index)
        out.writeLong(hash);         // stub/skeleton hash
    } catch (IOException e) {
        throw new MarshalException("Error marshaling call header", e);
    }
}
项目:OpenJSharp    文件:RMIConnector.java   
private void rethrowDeserializationException(IOException ioe)
        throws ClassNotFoundException, IOException {
    // specially treating for an UnmarshalException
    if (ioe instanceof UnmarshalException) {
        throw ioe; // the fix of 6937053 made ClientNotifForwarder.fetchNotifs
                   // fetch one by one with UnmarshalException
    } else if (ioe instanceof MarshalException) {
        // IIOP will throw MarshalException wrapping a NotSerializableException
        // when a server fails to serialize a response.
        MarshalException me = (MarshalException)ioe;
        if (me.detail instanceof NotSerializableException) {
            throw (NotSerializableException)me.detail;
        }
    }

    // Not serialization problem, return.
}
项目:jdk8u-jdk    文件:StreamRemoteCall.java   
public StreamRemoteCall(Connection c, ObjID id, int op, long hash)
    throws RemoteException
{
    try {
        conn = c;
        Transport.transportLog.log(Log.VERBOSE,
            "write remote call header...");

        // write out remote call header info...
        // call header, part 1 (read by Transport)
        conn.getOutputStream().write(TransportConstants.Call);
        getOutputStream();           // creates a MarshalOutputStream
        id.write(out);               // object id (target of call)
        // call header, part 2 (read by Dispatcher)
        out.writeInt(op);            // method number (operation index)
        out.writeLong(hash);         // stub/skeleton hash
    } catch (IOException e) {
        throw new MarshalException("Error marshaling call header", e);
    }
}
项目:jdk8u-jdk    文件:RMIConnector.java   
private void rethrowDeserializationException(IOException ioe)
        throws ClassNotFoundException, IOException {
    // specially treating for an UnmarshalException
    if (ioe instanceof UnmarshalException) {
        throw ioe; // the fix of 6937053 made ClientNotifForwarder.fetchNotifs
                   // fetch one by one with UnmarshalException
    } else if (ioe instanceof MarshalException) {
        // IIOP will throw MarshalException wrapping a NotSerializableException
        // when a server fails to serialize a response.
        MarshalException me = (MarshalException)ioe;
        if (me.detail instanceof NotSerializableException) {
            throw (NotSerializableException)me.detail;
        }
    }

    // Not serialization problem, return.
}
项目:openjdk-jdk10    文件:StreamRemoteCall.java   
public StreamRemoteCall(Connection c, ObjID id, int op, long hash)
    throws RemoteException
{
    try {
        conn = c;
        Transport.transportLog.log(Log.VERBOSE,
            "write remote call header...");

        // write out remote call header info...
        // call header, part 1 (read by Transport)
        conn.getOutputStream().write(TransportConstants.Call);
        getOutputStream();           // creates a MarshalOutputStream
        id.write(out);               // object id (target of call)
        // call header, part 2 (read by Dispatcher)
        out.writeInt(op);            // method number (operation index)
        out.writeLong(hash);         // stub/skeleton hash
    } catch (IOException e) {
        throw new MarshalException("Error marshaling call header", e);
    }
}
项目:openjdk9    文件:StreamRemoteCall.java   
public StreamRemoteCall(Connection c, ObjID id, int op, long hash)
    throws RemoteException
{
    try {
        conn = c;
        Transport.transportLog.log(Log.VERBOSE,
            "write remote call header...");

        // write out remote call header info...
        // call header, part 1 (read by Transport)
        conn.getOutputStream().write(TransportConstants.Call);
        getOutputStream();           // creates a MarshalOutputStream
        id.write(out);               // object id (target of call)
        // call header, part 2 (read by Dispatcher)
        out.writeInt(op);            // method number (operation index)
        out.writeLong(hash);         // stub/skeleton hash
    } catch (IOException e) {
        throw new MarshalException("Error marshaling call header", e);
    }
}
项目:Java8CN    文件:RMIConnector.java   
private void rethrowDeserializationException(IOException ioe)
        throws ClassNotFoundException, IOException {
    // specially treating for an UnmarshalException
    if (ioe instanceof UnmarshalException) {
        throw ioe; // the fix of 6937053 made ClientNotifForwarder.fetchNotifs
                   // fetch one by one with UnmarshalException
    } else if (ioe instanceof MarshalException) {
        // IIOP will throw MarshalException wrapping a NotSerializableException
        // when a server fails to serialize a response.
        MarshalException me = (MarshalException)ioe;
        if (me.detail instanceof NotSerializableException) {
            throw (NotSerializableException)me.detail;
        }
    }

    // Not serialization problem, return.
}
项目:jdk8u_jdk    文件:StreamRemoteCall.java   
public StreamRemoteCall(Connection c, ObjID id, int op, long hash)
    throws RemoteException
{
    try {
        conn = c;
        Transport.transportLog.log(Log.VERBOSE,
            "write remote call header...");

        // write out remote call header info...
        // call header, part 1 (read by Transport)
        conn.getOutputStream().write(TransportConstants.Call);
        getOutputStream();           // creates a MarshalOutputStream
        id.write(out);               // object id (target of call)
        // call header, part 2 (read by Dispatcher)
        out.writeInt(op);            // method number (operation index)
        out.writeLong(hash);         // stub/skeleton hash
    } catch (IOException e) {
        throw new MarshalException("Error marshaling call header", e);
    }
}
项目:jdk8u_jdk    文件:RMIConnector.java   
private void rethrowDeserializationException(IOException ioe)
        throws ClassNotFoundException, IOException {
    // specially treating for an UnmarshalException
    if (ioe instanceof UnmarshalException) {
        throw ioe; // the fix of 6937053 made ClientNotifForwarder.fetchNotifs
                   // fetch one by one with UnmarshalException
    } else if (ioe instanceof MarshalException) {
        // IIOP will throw MarshalException wrapping a NotSerializableException
        // when a server fails to serialize a response.
        MarshalException me = (MarshalException)ioe;
        if (me.detail instanceof NotSerializableException) {
            throw (NotSerializableException)me.detail;
        }
    }

    // Not serialization problem, return.
}
项目:lookaside_java-1.8.0-openjdk    文件:StreamRemoteCall.java   
public StreamRemoteCall(Connection c, ObjID id, int op, long hash)
    throws RemoteException
{
    try {
        conn = c;
        Transport.transportLog.log(Log.VERBOSE,
            "write remote call header...");

        // write out remote call header info...
        // call header, part 1 (read by Transport)
        conn.getOutputStream().write(TransportConstants.Call);
        getOutputStream();           // creates a MarshalOutputStream
        id.write(out);               // object id (target of call)
        // call header, part 2 (read by Dispatcher)
        out.writeInt(op);            // method number (operation index)
        out.writeLong(hash);         // stub/skeleton hash
    } catch (IOException e) {
        throw new MarshalException("Error marshaling call header", e);
    }
}
项目:lookaside_java-1.8.0-openjdk    文件:RMIConnector.java   
private void rethrowDeserializationException(IOException ioe)
        throws ClassNotFoundException, IOException {
    // specially treating for an UnmarshalException
    if (ioe instanceof UnmarshalException) {
        throw ioe; // the fix of 6937053 made ClientNotifForwarder.fetchNotifs
                   // fetch one by one with UnmarshalException
    } else if (ioe instanceof MarshalException) {
        // IIOP will throw MarshalException wrapping a NotSerializableException
        // when a server fails to serialize a response.
        MarshalException me = (MarshalException)ioe;
        if (me.detail instanceof NotSerializableException) {
            throw (NotSerializableException)me.detail;
        }
    }

    // Not serialization problem, return.
}
项目:jetstream    文件:SpringBeanSerializer.java   
@Override
public void serialize(Element beanElement, Object object) throws MarshalException {
  if (beanElement.getParentNode().equals(beanElement.getOwnerDocument())) {
    beanElement.setAttribute("id", "e-" + m_count++);
    SpringXMLSerializer serializer = (SpringXMLSerializer) XMLSerializationManager.getSerializer("spring");
    String scope = serializer.getDefaultScope();
    if (scope != null) {
      beanElement.setAttribute("scope", scope);
    }
    beanElement.setAttribute("lazy-init", String.valueOf(serializer.isDefaultLazyInit()));
  }

  if (Proxy.isProxyClass(object.getClass())) {
    String className;
    String[] tokens = object.toString().split("@");
    className = tokens[0];
    beanElement.setAttribute("class", className);
  }
  else
    beanElement.setAttribute("class", object.getClass().getCanonicalName());
  super.serialize(beanElement, object);
}
项目:jetstream    文件:SpringMapSerializer.java   
public void serialize(Element containingElement, Object object) throws MarshalException {
  boolean isProps = object instanceof Properties;
  String entryElementName = isProps ? "prop" : "entry";
  Document doc = containingElement.getOwnerDocument();
  Element mapElement = doc.createElement(isProps ? "props" : "map");
  containingElement.appendChild(mapElement);

  for (Map.Entry<?, ?> entry : ((Map<?, ?>) object).entrySet()) {
    String key = entry.getKey().toString();
    Object value = entry.getValue();

    Element entryElement = doc.createElement(entryElementName);
    entryElement.setAttribute("key", key);
    mapElement.appendChild(entryElement);

    if (isProps) {
      entryElement.appendChild(doc.createTextNode(value.toString()));
    }
    else {
      XMLSerializationManager.getSerializer("spring").serialize(entryElement, value);
    }
  }
}
项目:infobip-open-jdk-8    文件:StreamRemoteCall.java   
public StreamRemoteCall(Connection c, ObjID id, int op, long hash)
    throws RemoteException
{
    try {
        conn = c;
        Transport.transportLog.log(Log.VERBOSE,
            "write remote call header...");

        // write out remote call header info...
        // call header, part 1 (read by Transport)
        conn.getOutputStream().write(TransportConstants.Call);
        getOutputStream();           // creates a MarshalOutputStream
        id.write(out);               // object id (target of call)
        // call header, part 2 (read by Dispatcher)
        out.writeInt(op);            // method number (operation index)
        out.writeLong(hash);         // stub/skeleton hash
    } catch (IOException e) {
        throw new MarshalException("Error marshaling call header", e);
    }
}
项目:infobip-open-jdk-8    文件:RMIConnector.java   
private void rethrowDeserializationException(IOException ioe)
        throws ClassNotFoundException, IOException {
    // specially treating for an UnmarshalException
    if (ioe instanceof UnmarshalException) {
        throw ioe; // the fix of 6937053 made ClientNotifForwarder.fetchNotifs
                   // fetch one by one with UnmarshalException
    } else if (ioe instanceof MarshalException) {
        // IIOP will throw MarshalException wrapping a NotSerializableException
        // when a server fails to serialize a response.
        MarshalException me = (MarshalException)ioe;
        if (me.detail instanceof NotSerializableException) {
            throw (NotSerializableException)me.detail;
        }
    }

    // Not serialization problem, return.
}
项目:jdk8u-dev-jdk    文件:StreamRemoteCall.java   
public StreamRemoteCall(Connection c, ObjID id, int op, long hash)
    throws RemoteException
{
    try {
        conn = c;
        Transport.transportLog.log(Log.VERBOSE,
            "write remote call header...");

        // write out remote call header info...
        // call header, part 1 (read by Transport)
        conn.getOutputStream().write(TransportConstants.Call);
        getOutputStream();           // creates a MarshalOutputStream
        id.write(out);               // object id (target of call)
        // call header, part 2 (read by Dispatcher)
        out.writeInt(op);            // method number (operation index)
        out.writeLong(hash);         // stub/skeleton hash
    } catch (IOException e) {
        throw new MarshalException("Error marshaling call header", e);
    }
}
项目:jdk8u-dev-jdk    文件:RMIConnector.java   
private void rethrowDeserializationException(IOException ioe)
        throws ClassNotFoundException, IOException {
    // specially treating for an UnmarshalException
    if (ioe instanceof UnmarshalException) {
        throw ioe; // the fix of 6937053 made ClientNotifForwarder.fetchNotifs
                   // fetch one by one with UnmarshalException
    } else if (ioe instanceof MarshalException) {
        // IIOP will throw MarshalException wrapping a NotSerializableException
        // when a server fails to serialize a response.
        MarshalException me = (MarshalException)ioe;
        if (me.detail instanceof NotSerializableException) {
            throw (NotSerializableException)me.detail;
        }
    }

    // Not serialization problem, return.
}
项目:jdk7-jdk    文件:StreamRemoteCall.java   
public StreamRemoteCall(Connection c, ObjID id, int op, long hash)
    throws RemoteException
{
    try {
        conn = c;
        Transport.transportLog.log(Log.VERBOSE,
            "write remote call header...");

        // write out remote call header info...
        // call header, part 1 (read by Transport)
        conn.getOutputStream().write(TransportConstants.Call);
        getOutputStream();           // creates a MarshalOutputStream
        id.write(out);               // object id (target of call)
        // call header, part 2 (read by Dispatcher)
        out.writeInt(op);            // method number (operation index)
        out.writeLong(hash);         // stub/skeleton hash
    } catch (IOException e) {
        throw new MarshalException("Error marshaling call header", e);
    }
}
项目:openjdk-source-code-learn    文件:StreamRemoteCall.java   
public StreamRemoteCall(Connection c, ObjID id, int op, long hash)
    throws RemoteException
{
    try {
        conn = c;
        Transport.transportLog.log(Log.VERBOSE,
            "write remote call header...");

        // write out remote call header info...
        // call header, part 1 (read by Transport)
        conn.getOutputStream().write(TransportConstants.Call);
        getOutputStream();           // creates a MarshalOutputStream
        id.write(out);               // object id (target of call)
        // call header, part 2 (read by Dispatcher)
        out.writeInt(op);            // method number (operation index)
        out.writeLong(hash);         // stub/skeleton hash
    } catch (IOException e) {
        throw new MarshalException("Error marshaling call header", e);
    }
}
项目:OLD-OpenJDK8    文件:StreamRemoteCall.java   
public StreamRemoteCall(Connection c, ObjID id, int op, long hash)
    throws RemoteException
{
    try {
        conn = c;
        Transport.transportLog.log(Log.VERBOSE,
            "write remote call header...");

        // write out remote call header info...
        // call header, part 1 (read by Transport)
        conn.getOutputStream().write(TransportConstants.Call);
        getOutputStream();           // creates a MarshalOutputStream
        id.write(out);               // object id (target of call)
        // call header, part 2 (read by Dispatcher)
        out.writeInt(op);            // method number (operation index)
        out.writeLong(hash);         // stub/skeleton hash
    } catch (IOException e) {
        throw new MarshalException("Error marshaling call header", e);
    }
}
项目:cn1    文件:RemoteObject.java   
/**
 * @com.intel.drl.spec_ref
 */
private void writeObject(ObjectOutputStream out)
        throws IOException {
    if (ref == null) {
        // rmi.17=Invalid remote object: RemoteRef = null
        throw new MarshalException(Messages.getString("rmi.17")); //$NON-NLS-1$
    }
    String refType = ref.getRefClass(out);

    if (refType != null && refType.length() != 0) {
        out.writeUTF(refType);
        ref.writeExternal(out);
    } else {
        out.writeUTF(""); //$NON-NLS-1$
        out.writeObject(ref);
    }
}
项目:openjdk-jdk7u-jdk    文件:StreamRemoteCall.java   
public StreamRemoteCall(Connection c, ObjID id, int op, long hash)
    throws RemoteException
{
    try {
        conn = c;
        Transport.transportLog.log(Log.VERBOSE,
            "write remote call header...");

        // write out remote call header info...
        // call header, part 1 (read by Transport)
        conn.getOutputStream().write(TransportConstants.Call);
        getOutputStream();           // creates a MarshalOutputStream
        id.write(out);               // object id (target of call)
        // call header, part 2 (read by Dispatcher)
        out.writeInt(op);            // method number (operation index)
        out.writeLong(hash);         // stub/skeleton hash
    } catch (IOException e) {
        throw new MarshalException("Error marshaling call header", e);
    }
}
项目:freeVM    文件:AbstractServerConnection.java   
/**
 * Receives a {@link Message} object containing the method call
 * request, executes the call, and writes the results to the client.
 * 
 * @param msg The {@link Message} object containing the call execution request.
    *  
 * @throws MarshalException if an exception occurs when writing the result
 * of the call.
 */
protected void handleCall(Message msg) throws MarshalException {
    UID dgcAck = null;
    ReturnMessage methodExecuted = executeMethod(msg);

    try {
        dgcAck = methodExecuted.write(out);
        out.flush();
    } catch (IOException e) {
        throw new MarshalException("Error writing method result", e);
    }
    if (dgcAck != null) {
        dgcAckWaitingMap.put(dgcAck, new Pair<Long, Object>(new Long(System
                .currentTimeMillis()
                + dgcAckMapTimeOut), methodExecuted.getResult()));
    }
}
项目:freeVM    文件:StreamClientConnection.java   
/**
 * Establishes a connection.
 * <li>If {@link #lastUsageTime} is <code>null</code> then starts a
 * connection.
 * <li>If the difference between current time and {@link #lastUsageTime} is
 * bigger or equal than double of the value stored in the table then renew
 * the connection. The multiplied constant 2 is suggested in this
 * {@link <a href="http://archives.java.sun.com/cgi-bin/wa?A2=ind0101&L=rmi-users&P=R23746&D=0&I=-3">link</a>}
 * 
 * @throws MarshalException
 *             if a {@link java.io.IOException} occurs while
 *             marshalling the remote call header, arguments or return value
 *             for a remote method call
 * @throws IOException
 *             if the socket is closed
 * @throws ProtocolException
 *             if there is an error in the underlying protocol
 */
@Override
public final void establishConnection() throws MarshalException,
        IOException, ProtocolException {

    if (lastUsageTime == null) {
        // Initially, by default 1 millisecond.
        handshake();
        rttTable.put(this.ep, new Long(1));
        lastUsageTime = System.currentTimeMillis();
    } else if (System.currentTimeMillis() - this.lastUsageTime >= (rttTable
            .get(this.ep) * 2)) {
        // The multiplied constant 2 is suggested in
        // http://archives.java.sun.com/cgi-bin/wa?A2=ind0101&L=rmi-users&P=R23746&D=0&I=-3.
        Long sentTime = System.currentTimeMillis();
        protocolHandler.writePing(); // renewConnection();
        out.flush();
        protocolHandler.readPingAck();
        rttTable.put(ep, System.currentTimeMillis() - sentTime);
    }
}
项目:freeVM    文件:AbstractServerConnection.java   
/**
 * Receives a {@link Message} object containing the method call
 * request, executes the call, and writes the results to the client.
 * 
 * @param msg The {@link Message} object containing the call execution request.
    *  
 * @throws MarshalException if an exception occurs when writing the result
 * of the call.
 */
protected void handleCall(Message msg) throws MarshalException {
    UID dgcAck = null;
    ReturnMessage methodExecuted = executeMethod(msg);

    try {
        dgcAck = methodExecuted.write(out);
        out.flush();
    } catch (IOException e) {
        throw new MarshalException("Error writing method result", e);
    }
    if (dgcAck != null) {
        dgcAckWaitingMap.put(dgcAck, new Pair<Long, Object>(new Long(System
                .currentTimeMillis()
                + dgcAckMapTimeOut), methodExecuted.getResult()));
    }
}
项目:freeVM    文件:StreamClientConnection.java   
/**
 * Establishes a connection.
 * <li>If {@link #lastUsageTime} is <code>null</code> then starts a
 * connection.
 * <li>If the difference between current time and {@link #lastUsageTime} is
 * bigger or equal than double of the value stored in the table then renew
 * the connection. The multiplied constant 2 is suggested in this
 * {@link <a href="http://archives.java.sun.com/cgi-bin/wa?A2=ind0101&L=rmi-users&P=R23746&D=0&I=-3">link</a>}
 * 
 * @throws MarshalException
 *             if a {@link java.io.IOException} occurs while
 *             marshalling the remote call header, arguments or return value
 *             for a remote method call
 * @throws IOException
 *             if the socket is closed
 * @throws ProtocolException
 *             if there is an error in the underlying protocol
 */
@Override
public final void establishConnection() throws MarshalException,
        IOException, ProtocolException {

    if (lastUsageTime == null) {
        // Initially, by default 1 millisecond.
        handshake();
        rttTable.put(this.ep, new Long(1));
        lastUsageTime = System.currentTimeMillis();
    } else if (System.currentTimeMillis() - this.lastUsageTime >= (rttTable
            .get(this.ep) * 2)) {
        // The multiplied constant 2 is suggested in
        // http://archives.java.sun.com/cgi-bin/wa?A2=ind0101&L=rmi-users&P=R23746&D=0&I=-3.
        Long sentTime = System.currentTimeMillis();
        protocolHandler.writePing(); // renewConnection();
        out.flush();
        protocolHandler.readPingAck();
        rttTable.put(ep, System.currentTimeMillis() - sentTime);
    }
}
项目:freeVM    文件:RemoteObject.java   
/**
 * @com.intel.drl.spec_ref
 */
private void writeObject(ObjectOutputStream out)
        throws IOException {
    if (ref == null) {
        // rmi.17=Invalid remote object: RemoteRef = null
        throw new MarshalException(Messages.getString("rmi.17")); //$NON-NLS-1$
    }
    String refType = ref.getRefClass(out);

    if (refType != null && refType.length() != 0) {
        out.writeUTF(refType);
        ref.writeExternal(out);
    } else {
        out.writeUTF(""); //$NON-NLS-1$
        out.writeObject(ref);
    }
}
项目:freeVM    文件:RemoteObject.java   
/**
 * @com.intel.drl.spec_ref
 */
private void writeObject(ObjectOutputStream out)
        throws IOException {
    if (ref == null) {
        // rmi.17=Invalid remote object: RemoteRef = null
        throw new MarshalException(Messages.getString("rmi.17")); //$NON-NLS-1$
    }
    String refType = ref.getRefClass(out);

    if (refType != null && refType.length() != 0) {
        out.writeUTF(refType);
        ref.writeExternal(out);
    } else {
        out.writeUTF(""); //$NON-NLS-1$
        out.writeObject(ref);
    }
}
项目:openjdk-icedtea7    文件:StreamRemoteCall.java   
public StreamRemoteCall(Connection c, ObjID id, int op, long hash)
    throws RemoteException
{
    try {
        conn = c;
        Transport.transportLog.log(Log.VERBOSE,
            "write remote call header...");

        // write out remote call header info...
        // call header, part 1 (read by Transport)
        conn.getOutputStream().write(TransportConstants.Call);
        getOutputStream();           // creates a MarshalOutputStream
        id.write(out);               // object id (target of call)
        // call header, part 2 (read by Dispatcher)
        out.writeInt(op);            // method number (operation index)
        out.writeLong(hash);         // stub/skeleton hash
    } catch (IOException e) {
        throw new MarshalException("Error marshaling call header", e);
    }
}
项目:jdk8u-jdk    文件:PinLastArguments.java   
public static void main(String[] args) throws Exception {
    System.err.println("\nRegression test for bug 6332349\n");

    Ping impl = new PingImpl();
    Reference<?> ref = new WeakReference<Ping>(impl);
    try {
        Ping stub = (Ping) UnicastRemoteObject.exportObject(impl, 0);
        Object notSerializable = new Object();
        stub.ping(impl, null);
        try {
            stub.ping(impl, notSerializable);
        } catch (MarshalException e) {
            if (e.getCause() instanceof NotSerializableException) {
                System.err.println("ping invocation failed as expected");
            } else {
                throw e;
            }
        }
    } finally {
        UnicastRemoteObject.unexportObject(impl, true);
    }
    impl = null;

    // Might require multiple calls to System.gc() for weak-references
    // processing to be complete. If the weak-reference is not cleared as
    // expected we will hang here until timed out by the test harness.
    while (true) {
        System.gc();
        Thread.sleep(20);
        if (ref.get() == null) {
            break;
        }
    }

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

    Ping impl = new PingImpl();
    Reference<?> ref = new WeakReference<Ping>(impl);
    try {
        Ping stub = (Ping) UnicastRemoteObject.exportObject(impl, 0);
        Object notSerializable = new Object();
        stub.ping(impl, null);
        try {
            stub.ping(impl, notSerializable);
        } catch (MarshalException e) {
            if (e.getCause() instanceof NotSerializableException) {
                System.err.println("ping invocation failed as expected");
            } else {
                throw e;
            }
        }
    } finally {
        UnicastRemoteObject.unexportObject(impl, true);
    }
    impl = null;

    // Might require multiple calls to System.gc() for weak-references
    // processing to be complete. If the weak-reference is not cleared as
    // expected we will hang here until timed out by the test harness.
    while (true) {
        System.gc();
        Thread.sleep(20);
        if (ref.get() == null) {
            break;
        }
    }

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

    Ping impl = new PingImpl();
    Reference<?> ref = new WeakReference<Ping>(impl);
    try {
        Ping stub = (Ping) UnicastRemoteObject.exportObject(impl, 0);
        Object notSerializable = new Object();
        stub.ping(impl, null);
        try {
            stub.ping(impl, notSerializable);
        } catch (MarshalException e) {
            if (e.getCause() instanceof NotSerializableException) {
                System.err.println("ping invocation failed as expected");
            } else {
                throw e;
            }
        }
    } finally {
        UnicastRemoteObject.unexportObject(impl, true);
    }
    impl = null;

    // Might require multiple calls to System.gc() for weak-references
    // processing to be complete. If the weak-reference is not cleared as
    // expected we will hang here until timed out by the test harness.
    while (true) {
        System.gc();
        Thread.sleep(20);
        if (ref.get() == null) {
            break;
        }
    }

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

    Ping impl = new PingImpl();
    Reference<?> ref = new WeakReference<Ping>(impl);
    try {
        Ping stub = (Ping) UnicastRemoteObject.exportObject(impl, 0);
        Object notSerializable = new Object();
        stub.ping(impl, null);
        try {
            stub.ping(impl, notSerializable);
        } catch (MarshalException e) {
            if (e.getCause() instanceof NotSerializableException) {
                System.err.println("ping invocation failed as expected");
            } else {
                throw e;
            }
        }
    } finally {
        UnicastRemoteObject.unexportObject(impl, true);
    }
    impl = null;

    // Might require multiple calls to System.gc() for weak-references
    // processing to be complete. If the weak-reference is not cleared as
    // expected we will hang here until timed out by the test harness.
    while (true) {
        System.gc();
        Thread.sleep(20);
        if (ref.get() == null) {
            break;
        }
    }

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

    Ping impl = new PingImpl();
    Reference<?> ref = new WeakReference<Ping>(impl);
    try {
        Ping stub = (Ping) UnicastRemoteObject.exportObject(impl, 0);
        Object notSerializable = new Object();
        stub.ping(impl, null);
        try {
            stub.ping(impl, notSerializable);
        } catch (MarshalException e) {
            if (e.getCause() instanceof NotSerializableException) {
                System.err.println("ping invocation failed as expected");
            } else {
                throw e;
            }
        }
    } finally {
        UnicastRemoteObject.unexportObject(impl, true);
    }
    impl = null;

    // Might require multiple calls to System.gc() for weak-references
    // processing to be complete. If the weak-reference is not cleared as
    // expected we will hang here until timed out by the test harness.
    while (true) {
        System.gc();
        Thread.sleep(20);
        if (ref.get() == null) {
            break;
        }
    }

    System.err.println("TEST PASSED");
}
项目:jetstream    文件:SpringCollectionSerializer.java   
public void serialize(Element containingElement, Object object) throws MarshalException {
  Collection<?> collection = (Collection<?>) object;
  String elementName = collection instanceof Set ? "set" : "list";
  Element listElement = containingElement.getOwnerDocument().createElement(elementName);
  containingElement.appendChild(listElement);
  for (Object item : collection) {
    XMLSerializationManager.getSerializer("spring").serialize(listElement, item);
  }
}
项目:jetstream    文件:SpringXMLSerializer.java   
@Override
public void serialize(Element containingElement, Object object) throws MarshalException {
  Element element = containingElement;
  IXmlSerializer xs = getSerializer(object, Object.class);
  if (xs.getClass() == SpringBeanSerializer.class && !element.getNodeName().equals("bean")) {
    element = containingElement.getOwnerDocument().createElement("bean");
    containingElement.appendChild(element);
  }
  xs.serialize(element, object);
}
项目:jetstream    文件:SpringPropertySerializer.java   
public void serialize(Element containingElement, Object object) throws MarshalException {
  Map<?, ?> map = (Map<?, ?>) object;
  Element mapElement = containingElement.getOwnerDocument().createElement("map");
  containingElement.appendChild(mapElement);

  for (Map.Entry<?, ?> entry : map.entrySet()) {
    String key = entry.getKey().toString();
    Object value = entry.getValue();

    Element entryElement = mapElement.getOwnerDocument().createElement("entry");
    entryElement.setAttribute("key", key);
    mapElement.appendChild(entryElement);
    XMLSerializationManager.getSerializer("spring").serialize(entryElement, value);
  }
}
项目:jetstream    文件:SpringStringSerializer.java   
public void serialize(Element containingElement, Object object) throws MarshalException {
  Document d = containingElement.getOwnerDocument();
  String value = object + "";
  String name = containingElement.getNodeName();
  if (object == null || name.equals("list") || name.equals("set") || name.equals("entry")) {
    Element element = d.createElement(object == null ? "null" : "value");
    containingElement.appendChild(element);
    if (object != null) {
      element.appendChild(d.createTextNode(value));
    }
  }
  else {
    containingElement.setAttribute("value", value);
  }
}
项目:jetstream    文件:SpringBeanSerializer.java   
@Override
protected void serializeProperty(Element beanElement, String propertyName, Object propertyValue)
    throws MarshalException {
  Element propertyElement = beanElement.getOwnerDocument().createElement("property");
  propertyElement.setAttribute("name", propertyName);
  beanElement.appendChild(propertyElement);
  XMLSerializationManager.getSerializer("spring").serialize(propertyElement, propertyValue);
}
项目:jetstream    文件:XMLSerializer.java   
/**
 * Serializes an object to its XML representation, in a DOM.
 * 
 * @param object
 *          the object to serialize.
 * @return the root Element of a DOM containing the serialized object.
 */
public Element getXMLRepresentation(Object object) {
  Element root = getRootElement(object);
  try {
    getSerializer(object, XSerializable.class).serialize(root, object);
  }
  catch (MarshalException e) {
    throw new RuntimeException(e);
  }
  return root;
}