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;
}
 
Example 41
Project: jetstream   File: SimpleMapSerializer.java   Source Code and License 5 votes vote down vote up
public void serialize(Element containingElement, Object object) throws MarshalException {
  Map<?, ?> map = (Map<?, ?>) object;
  for (Map.Entry<?, ?> entry : map.entrySet()) {
    String key = entry.getKey().toString();
    Object value = entry.getValue();
    Element entryElement = containingElement.getOwnerDocument().createElement("entry");
    entryElement.setAttribute("key", key);
    containingElement.appendChild(entryElement);
    if (value != null) {
      entryElement.setAttribute("class", value.getClass().getSimpleName());
    }
    XMLSerializationManager.getSerializer("xml").serialize(entryElement, value);
  }
}
 
Example 42
Project: jetstream   File: SimpleCollectionSerializer.java   Source Code and License 5 votes vote down vote up
public void serialize(Element containingElement, Object object) throws MarshalException {
  Collection<?> collection = (Collection<?>) object;
  for (Object item : collection) {
    Element itemElement = containingElement.getOwnerDocument().createElement("item");
    containingElement.appendChild(itemElement);
    if (item != null) {
      itemElement.setAttribute("class", item.getClass().getSimpleName());
    }
    XMLSerializationManager.getSerializer("xml").serialize(itemElement, item);
  }
}
 
Example 43
Project: jetstream   File: SimpleBeanSerializer.java   Source Code and License 5 votes vote down vote up
@Override
protected void serializeProperty(Element containerElement, String propertyName, Object propertyValue)
    throws MarshalException {
  Element propertyElement = containerElement.getOwnerDocument().createElement(propertyName);
  containerElement.appendChild(propertyElement);
  XMLSerializationManager.getSerializer("xml").serialize(propertyElement, propertyValue);
}
 
Example 44
Project: jetstream   File: AbstractBeanSerializer.java   Source Code and License 5 votes vote down vote up
public void serialize(Element containerElement, Object object) throws MarshalException {
  for (Method method : object.getClass().getMethods()) {
    String name = getPropertyName(method);
    if (name != null) {
      method.setAccessible(true); // For private/package class with public methods
      try {
        serializeProperty(containerElement, name, method.invoke(object));
      }
      catch (Exception e) {
        containerElement.appendChild(containerElement.getOwnerDocument().createComment(
            "get failed for " + name + ": " + e));
      }
    }
  }
}
 
Example 45
Project: infobip-open-jdk-8   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 46
Project: jdk8u-dev-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 47
Project: jdk7-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;

    System.gc();

    if (ref.get() != null) {
        throw new Error("TEST FAILED: impl not garbage collected");
    }

    System.err.println("TEST PASSED");
}
 
Example 48
Project: openjdk-source-code-learn   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;

    System.gc();

    if (ref.get() != null) {
        throw new Error("TEST FAILED: impl not garbage collected");
    }

    System.err.println("TEST PASSED");
}
 
Example 49
Project: OLD-OpenJDK8   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 50
Project: cn1   File: UnicastRef.java   Source Code and License 5 votes vote down vote up
/**
 * @see RemoteRef.newCall(RemoteObject, Operation[], int, long)
 */
public RemoteCall newCall(RemoteObject obj,
                          Operation[] op,
                          int opnum,
                          long hash)
        throws RemoteException {
    if (opnum != -1) {
        if (clientRefLog.isLoggable(RMILog.BRIEF)) {
            // rmi.log.101=New call: method = [{0}], opnum = {1}, hash = {2}
            clientRefLog.log(RMILog.BRIEF, Messages.getString("rmi.log.101", //$NON-NLS-1$
                    new Object[]{op[opnum].toString(), opnum, hash}));
        }
        logClientCall(obj, op[opnum].toString());
    }
    ClientConnection conn = ClientConnectionManager.getConnection(ep);
    RemoteCall call = new ClientRemoteCall(conn);

    if (clientRefLog.isLoggable(RMILog.VERBOSE)) {
        //rmi.log.102=Created new call {0}
        clientRefLog.log(RMILog.VERBOSE, Messages.getString("rmi.log.102", call)); //$NON-NLS-1$
    }

    try {
        // write method signature
        DataOutputStream dout = new DataOutputStream(conn.getOutputStream());
        dout.writeByte(RMIProtocolConstants.CALL_MSG);
        ObjectOutputStream oout =
                (ObjectOutputStream) call.getOutputStream();
        objId.write(oout);
        oout.writeInt(opnum);
        oout.writeLong(hash);
        return call;
    } catch (IOException ioe) {
        done(call);
        // rmi.72=Unable to marshal call header
        throw new MarshalException(Messages.getString("rmi.72"), ioe); //$NON-NLS-1$
    }
}
 
Example 51
Project: cn1   File: MarshalExceptionTest.java   Source Code and License 5 votes vote down vote up
/**
 * {@link java.rmi.MarshalException#MarshalException(java.lang.String, java.lang.Exception)}.
 */
public void testMarshalExceptionStringException() {
    NullPointerException npe = new NullPointerException();
    MarshalException e = new MarshalException("fixture", npe);
    assertTrue(e.getMessage().indexOf("fixture") > -1);
    assertSame(npe, e.getCause());
    assertSame(npe, e.detail);
}
 
Example 52
Project: cn1   File: MarshalExceptionTest.java   Source Code and License 5 votes vote down vote up
/**
 * {@link java.rmi.MarshalException#MarshalException(java.lang.String)}.
 */
public void testMarshalExceptionString() {
    MarshalException e = new MarshalException("fixture");
    assertEquals("fixture", e.getMessage());
    assertNull(e.getCause());
    assertNull(e.detail);
}
 
Example 53
Project: JAVA_UNIT   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;

    System.gc();

    if (ref.get() != null) {
        throw new Error("TEST FAILED: impl not garbage collected");
    }

    System.err.println("TEST PASSED");
}
 
Example 54
Project: openjdk-jdk7u-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 55
Project: SORCER   File: ActivateWrapper.java   Source Code and License 5 votes vote down vote up
/**
 * Analog to
 * {@link java.rmi.activation.Activatable#register(java.rmi.activation.ActivationDesc)
 * Activatable.register()} for activatable objects that want to use this
 * wrapper mechanism.
 * 
 * @return activation ID of the registered service
 * @throws ActivationException if there was a problem registering the
 * activatable class with the activation system
 * @throws RemoteException if there was a problem communicating with the
 * activation system
 */
public static ActivationID register(ActivationGroupID gid,
                                    ActivateDesc desc,
                                    boolean restart,
                                    ActivationSystem sys)
    throws ActivationException, RemoteException {
    logger.debug("Entering register {} {} {} {}", gid, desc, restart, sys);
    MarshalledObject data;
    try {
        data = new MarshalledObject(desc);
    } catch(Exception e) {
        MarshalException me = new MarshalException("marshalling ActivateDesc",
                                                   e);
        logger.warn("register", me);
        throw me;
    }
    ActivationDesc adesc = new ActivationDesc(gid,
                                              ActivateWrapper.class.getName(),
                                              null,
                                              data,
                                              restart);
    logger.trace(
               "Registering descriptor with activation: {0}",
               adesc);
    ActivationID aid = sys.registerObject(adesc);
    logger.debug(ActivateWrapper.class.getName(), "register", aid);
    return aid;
}
 
Example 56
Project: freeVM   File: ClientProtocolHandler.java   Source Code and License 5 votes vote down vote up
/**
 * Writes the protocol header, version and type of connection
 * 
 * @param type
 *            the protocol's type
 * @throws MarshalException
 *             if an I/O exceptions ocurrs
 */
public final void writeHandshake(ProtocolType type) throws MarshalException {

    Header header = new Header(type);
    try {
        header.writeExternal(out);
    } catch (IOException e) {
        throw new MarshalException("Exception marshaling JRMP Header", e);
    }
}
 
Example 57
Project: freeVM   File: ClientProtocolHandler.java   Source Code and License 5 votes vote down vote up
/**
 * Writes the protocol header, version and type of connection
 * 
 * @param type
 *            the protocol's type
 * @throws MarshalException
 *             if an I/O exceptions ocurrs
 */
public final void writeHandshake(ProtocolType type) throws MarshalException {

    Header header = new Header(type);
    try {
        header.writeExternal(out);
    } catch (IOException e) {
        throw new MarshalException("Exception marshaling JRMP Header", e);
    }
}
 
Example 58
Project: freeVM   File: UnicastRef.java   Source Code and License 5 votes vote down vote up
/**
 * @see RemoteRef.newCall(RemoteObject, Operation[], int, long)
 */
public RemoteCall newCall(RemoteObject obj,
                          Operation[] op,
                          int opnum,
                          long hash)
        throws RemoteException {
    if (opnum != -1) {
        if (clientRefLog.isLoggable(RMILog.BRIEF)) {
            // rmi.log.101=New call: method = [{0}], opnum = {1}, hash = {2}
            clientRefLog.log(RMILog.BRIEF, Messages.getString("rmi.log.101", //$NON-NLS-1$
                    new Object[]{op[opnum].toString(), opnum, hash}));
        }
        logClientCall(obj, op[opnum].toString());
    }
    ClientConnection conn = ClientConnectionManager.getConnection(ep);
    RemoteCall call = new ClientRemoteCall(conn);

    if (clientRefLog.isLoggable(RMILog.VERBOSE)) {
        //rmi.log.102=Created new call {0}
        clientRefLog.log(RMILog.VERBOSE, Messages.getString("rmi.log.102", call)); //$NON-NLS-1$
    }

    try {
        // write method signature
        DataOutputStream dout = new DataOutputStream(conn.getOutputStream());
        dout.writeByte(RMIProtocolConstants.CALL_MSG);
        ObjectOutputStream oout =
                (ObjectOutputStream) call.getOutputStream();
        objId.write(oout);
        oout.writeInt(opnum);
        oout.writeLong(hash);
        return call;
    } catch (IOException ioe) {
        done(call);
        // rmi.72=Unable to marshal call header
        throw new MarshalException(Messages.getString("rmi.72"), ioe); //$NON-NLS-1$
    }
}
 
Example 59
Project: freeVM   File: MarshalExceptionTest.java   Source Code and License 5 votes vote down vote up
/**
 * {@link java.rmi.MarshalException#MarshalException(java.lang.String, java.lang.Exception)}.
 */
public void testMarshalExceptionStringException() {
    NullPointerException npe = new NullPointerException();
    MarshalException e = new MarshalException("fixture", npe);
    assertTrue(e.getMessage().indexOf("fixture") > -1);
    assertSame(npe, e.getCause());
    assertSame(npe, e.detail);
}
 
Example 60
Project: freeVM   File: MarshalExceptionTest.java   Source Code and License 5 votes vote down vote up
/**
 * {@link java.rmi.MarshalException#MarshalException(java.lang.String)}.
 */
public void testMarshalExceptionString() {
    MarshalException e = new MarshalException("fixture");
    assertEquals("fixture", e.getMessage());
    assertNull(e.getCause());
    assertNull(e.detail);
}