Java Code Examples for java.rmi.MarshalException

The following are top voted examples for showing how to use java.rmi.MarshalException. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: OpenJSharp   File: RMIConnector.java   Source Code and License 7 votes vote down vote up
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.
}
 
Example 2
Project: OpenJSharp   File: StreamRemoteCall.java   Source Code and License 6 votes vote down vote up
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);
    }
}
 
Example 3
Project: jdk8u-jdk   File: StreamRemoteCall.java   Source Code and License 6 votes vote down vote up
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);
    }
}
 
Example 4
Project: jdk8u-jdk   File: RMIConnector.java   Source Code and License 6 votes vote down vote up
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.
}
 
Example 5
Project: openjdk-jdk10   File: StreamRemoteCall.java   Source Code and License 6 votes vote down vote up
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);
    }
}
 
Example 6
Project: openjdk9   File: StreamRemoteCall.java   Source Code and License 6 votes vote down vote up
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);
    }
}
 
Example 7
Project: Java8CN   File: RMIConnector.java   Source Code and License 6 votes vote down vote up
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.
}
 
Example 8
Project: jdk8u_jdk   File: StreamRemoteCall.java   Source Code and License 6 votes vote down vote up
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);
    }
}
 
Example 9
Project: jdk8u_jdk   File: RMIConnector.java   Source Code and License 6 votes vote down vote up
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.
}
 
Example 10
Project: lookaside_java-1.8.0-openjdk   File: StreamRemoteCall.java   Source Code and License 6 votes vote down vote up
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);
    }
}
 
Example 11
Project: lookaside_java-1.8.0-openjdk   File: RMIConnector.java   Source Code and License 6 votes vote down vote up
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.
}
 
Example 12
Project: jetstream   File: SpringBeanSerializer.java   Source Code and License 6 votes vote down vote up
@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);
}
 
Example 13
Project: jetstream   File: SpringMapSerializer.java   Source Code and License 6 votes vote down vote up
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);
    }
  }
}
 
Example 14
Project: infobip-open-jdk-8   File: StreamRemoteCall.java   Source Code and License 6 votes vote down vote up
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);
    }
}
 
Example 15
Project: infobip-open-jdk-8   File: RMIConnector.java   Source Code and License 6 votes vote down vote up
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.
}
 
Example 16
Project: jdk8u-dev-jdk   File: StreamRemoteCall.java   Source Code and License 6 votes vote down vote up
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);
    }
}
 
Example 17
Project: jdk8u-dev-jdk   File: RMIConnector.java   Source Code and License 6 votes vote down vote up
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.
}
 
Example 18
Project: jdk7-jdk   File: StreamRemoteCall.java   Source Code and License 6 votes vote down vote up
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);
    }
}
 
Example 19
Project: openjdk-source-code-learn   File: StreamRemoteCall.java   Source Code and License 6 votes vote down vote up
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);
    }
}
 
Example 20
Project: OLD-OpenJDK8   File: StreamRemoteCall.java   Source Code and License 6 votes vote down vote up
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);
    }
}
 
Example 21
Project: cn1   File: RemoteObject.java   Source Code and License 6 votes vote down vote up
/**
 * @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);
    }
}
 
Example 22
Project: openjdk-jdk7u-jdk   File: StreamRemoteCall.java   Source Code and License 6 votes vote down vote up
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);
    }
}
 
Example 23
Project: freeVM   File: AbstractServerConnection.java   Source Code and License 6 votes vote down vote up
/**
 * 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()));
	}
}
 
Example 24
Project: freeVM   File: StreamClientConnection.java   Source Code and License 6 votes vote down vote up
/**
 * 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);
	}
}
 
Example 25
Project: freeVM   File: AbstractServerConnection.java   Source Code and License 6 votes vote down vote up
/**
 * 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()));
	}
}
 
Example 26
Project: freeVM   File: StreamClientConnection.java   Source Code and License 6 votes vote down vote up
/**
 * 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);
	}
}
 
Example 27
Project: freeVM   File: RemoteObject.java   Source Code and License 6 votes vote down vote up
/**
 * @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);
    }
}
 
Example 28
Project: freeVM   File: RemoteObject.java   Source Code and License 6 votes vote down vote up
/**
 * @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);
    }
}
 
Example 29
Project: openjdk-icedtea7   File: StreamRemoteCall.java   Source Code and License 6 votes vote down vote up
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);
    }
}
 
Example 30
Project: jdk8u-jdk   File: PinLastArguments.java   Source Code and License 5 votes vote down vote up
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");
}
 
Example 31
Project: openjdk-jdk10   File: PinLastArguments.java   Source Code and License 5 votes vote down vote up
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");
}
 
Example 32
Project: openjdk9   File: PinLastArguments.java   Source Code and License 5 votes vote down vote up
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");
}
 
Example 33
Project: jdk8u_jdk   File: PinLastArguments.java   Source Code and License 5 votes vote down vote up
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");
}
 
Example 34
Project: lookaside_java-1.8.0-openjdk   File: PinLastArguments.java   Source Code and License 5 votes vote down vote up
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");
}
 
Example 35
Project: jetstream   File: SpringCollectionSerializer.java   Source Code and License 5 votes vote down vote up
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);
  }
}
 
Example 36
Project: jetstream   File: SpringXMLSerializer.java   Source Code and License 5 votes vote down vote up
@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);
}
 
Example 37
Project: jetstream   File: SpringPropertySerializer.java   Source Code and License 5 votes vote down vote up
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);
  }
}
 
Example 38
Project: jetstream   File: SpringStringSerializer.java   Source Code and License 5 votes vote down vote up
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);
  }
}
 
Example 39
Project: jetstream   File: SpringBeanSerializer.java   Source Code and License 5 votes vote down vote up
@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);
}
 
Example 40
Project: jetstream   File: XMLSerializer.java   Source Code and License 5 votes vote down vote up
/**
 * 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;
}