Search in sources :

Example 21 with InvalidObjectException

use of java.io.InvalidObjectException in project jdk8u_jdk by JetBrains.

the class RMIConnector method readObject.

/**
     * Read RMIConnector fields from an {@link java.io.ObjectInputStream
     * ObjectInputStream}.
     * Calls <code>s.defaultReadObject()</code> and then initializes
     * all transient variables that need initializing.
     * @param s The ObjectInputStream to read from.
     * @exception InvalidObjectException if none of <var>rmiServer</var> stub
     *    or <var>jmxServiceURL</var> are set.
     * @see #RMIConnector(JMXServiceURL,Map)
     * @see #RMIConnector(RMIServer,Map)
     **/
private void readObject(java.io.ObjectInputStream s) throws IOException, ClassNotFoundException {
    s.defaultReadObject();
    if (rmiServer == null && jmxServiceURL == null)
        throw new InvalidObjectException("rmiServer and jmxServiceURL both null");
    initTransients();
}
Also used : InvalidObjectException(java.io.InvalidObjectException)

Example 22 with InvalidObjectException

use of java.io.InvalidObjectException in project jdk8u_jdk by JetBrains.

the class InetSocketAddress method readObject.

private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
    // Don't call defaultReadObject()
    ObjectInputStream.GetField oisFields = in.readFields();
    final String oisHostname = (String) oisFields.get("hostname", null);
    final InetAddress oisAddr = (InetAddress) oisFields.get("addr", null);
    final int oisPort = oisFields.get("port", -1);
    // Check that our invariants are satisfied
    checkPort(oisPort);
    if (oisHostname == null && oisAddr == null)
        throw new InvalidObjectException("hostname and addr " + "can't both be null");
    InetSocketAddressHolder h = new InetSocketAddressHolder(oisHostname, oisAddr, oisPort);
    UNSAFE.putObject(this, FIELDS_OFFSET, h);
}
Also used : InvalidObjectException(java.io.InvalidObjectException) ObjectInputStream(java.io.ObjectInputStream)

Example 23 with InvalidObjectException

use of java.io.InvalidObjectException in project jdk8u_jdk by JetBrains.

the class ActivationID method readObject.

/**
     * <code>readObject</code> for custom serialization.
     *
     * <p>This method reads this object's serialized form for this
     * class as follows:
     *
     * <p>The <code>readObject</code> method is invoked on
     * <code>in</code> to read this object's unique identifier
     * (a {@link java.rmi.server.UID UID} instance).
     *
     * <p>Next, the <code>readUTF</code> method is invoked on
     * <code>in</code> to read the external ref type name of the
     * <code>RemoteRef</code> instance for this object's
     * activator.  Next, the <code>RemoteRef</code>
     * instance is created of an implementation-specific class
     * corresponding to the external ref type name (returned by
     * <code>readUTF</code>), and the <code>readExternal</code>
     * method is invoked on that <code>RemoteRef</code> instance
     * to read the external form corresponding to the external
     * ref type name.
     *
     * <p>Note: If the external ref type name is
     * <code>"UnicastRef"</code>, <code>"UnicastServerRef"</code>,
     * <code>"UnicastRef2"</code>, <code>"UnicastServerRef2"</code>,
     * or <code>"ActivatableRef"</code>, a corresponding
     * implementation-specific class must be found, and its
     * <code>readExternal</code> method must read the serial data
     * for that external ref type name as specified to be written
     * in the <b>serialData</b> documentation for this class.
     * If the external ref type name is any other string (of non-zero
     * length), a <code>ClassNotFoundException</code> will be thrown,
     * unless the implementation provides an implementation-specific
     * class corresponding to that external ref type name, in which
     * case the <code>RemoteRef</code> will be an instance of
     * that implementation-specific class.
     */
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
    uid = (UID) in.readObject();
    try {
        Class<? extends RemoteRef> refClass = Class.forName(RemoteRef.packagePrefix + "." + in.readUTF()).asSubclass(RemoteRef.class);
        RemoteRef ref = refClass.newInstance();
        ref.readExternal(in);
        activator = (Activator) Proxy.newProxyInstance(null, new Class<?>[] { Activator.class }, new RemoteObjectInvocationHandler(ref));
    } catch (InstantiationException e) {
        throw (IOException) new InvalidObjectException("Unable to create remote reference").initCause(e);
    } catch (IllegalAccessException e) {
        throw (IOException) new InvalidObjectException("Unable to create remote reference").initCause(e);
    }
}
Also used : RemoteObjectInvocationHandler(java.rmi.server.RemoteObjectInvocationHandler) RemoteRef(java.rmi.server.RemoteRef) InvalidObjectException(java.io.InvalidObjectException)

Example 24 with InvalidObjectException

use of java.io.InvalidObjectException in project jdk8u_jdk by JetBrains.

the class ActivationID method writeObject.

/**
     * <code>writeObject</code> for custom serialization.
     *
     * <p>This method writes this object's serialized form for
     * this class as follows:
     *
     * <p>The <code>writeObject</code> method is invoked on
     * <code>out</code> passing this object's unique identifier
     * (a {@link java.rmi.server.UID UID} instance) as the argument.
     *
     * <p>Next, the {@link
     * java.rmi.server.RemoteRef#getRefClass(java.io.ObjectOutput)
     * getRefClass} method is invoked on the activator's
     * <code>RemoteRef</code> instance to obtain its external ref
     * type name.  Next, the <code>writeUTF</code> method is
     * invoked on <code>out</code> with the value returned by
     * <code>getRefClass</code>, and then the
     * <code>writeExternal</code> method is invoked on the
     * <code>RemoteRef</code> instance passing <code>out</code>
     * as the argument.
     *
     * @serialData The serialized data for this class comprises a
     * <code>java.rmi.server.UID</code> (written with
     * <code>ObjectOutput.writeObject</code>) followed by the
     * external ref type name of the activator's
     * <code>RemoteRef</code> instance (a string written with
     * <code>ObjectOutput.writeUTF</code>), followed by the
     * external form of the <code>RemoteRef</code> instance as
     * written by its <code>writeExternal</code> method.
     *
     * <p>The external ref type name of the
     * <code>RemoteRef</Code> instance is
     * determined using the definitions of external ref type
     * names specified in the {@link java.rmi.server.RemoteObject
     * RemoteObject} <code>writeObject</code> method
     * <b>serialData</b> specification.  Similarly, the data
     * written by the <code>writeExternal</code> method and read
     * by the <code>readExternal</code> method of
     * <code>RemoteRef</code> implementation classes
     * corresponding to each of the defined external ref type
     * names is specified in the {@link
     * java.rmi.server.RemoteObject RemoteObject}
     * <code>writeObject</code> method <b>serialData</b>
     * specification.
     **/
private void writeObject(ObjectOutputStream out) throws IOException, ClassNotFoundException {
    out.writeObject(uid);
    RemoteRef ref;
    if (activator instanceof RemoteObject) {
        ref = ((RemoteObject) activator).getRef();
    } else if (Proxy.isProxyClass(activator.getClass())) {
        InvocationHandler handler = Proxy.getInvocationHandler(activator);
        if (!(handler instanceof RemoteObjectInvocationHandler)) {
            throw new InvalidObjectException("unexpected invocation handler");
        }
        ref = ((RemoteObjectInvocationHandler) handler).getRef();
    } else {
        throw new InvalidObjectException("unexpected activator type");
    }
    out.writeUTF(ref.getRefClass(out));
    ref.writeExternal(out);
}
Also used : RemoteObject(java.rmi.server.RemoteObject) RemoteObjectInvocationHandler(java.rmi.server.RemoteObjectInvocationHandler) RemoteRef(java.rmi.server.RemoteRef) InvalidObjectException(java.io.InvalidObjectException) RemoteObjectInvocationHandler(java.rmi.server.RemoteObjectInvocationHandler) InvocationHandler(java.lang.reflect.InvocationHandler)

Example 25 with InvalidObjectException

use of java.io.InvalidObjectException in project jdk8u_jdk by JetBrains.

the class DirectoryIteratorException method readObject.

/**
     * Called to read the object from a stream.
     *
     * @throws  InvalidObjectException
     *          if the object is invalid or has a cause that is not
     *          an {@code IOException}
     */
private void readObject(ObjectInputStream s) throws IOException, ClassNotFoundException {
    s.defaultReadObject();
    Throwable cause = super.getCause();
    if (!(cause instanceof IOException))
        throw new InvalidObjectException("Cause must be an IOException");
}
Also used : InvalidObjectException(java.io.InvalidObjectException) IOException(java.io.IOException)

Aggregations

InvalidObjectException (java.io.InvalidObjectException)54 ObjectInputStream (java.io.ObjectInputStream)13 IOException (java.io.IOException)7 SmallTest (android.test.suitebuilder.annotation.SmallTest)5 Rational (android.util.Rational)5 GwtIncompatible (com.google.common.annotations.GwtIncompatible)4 ByteArrayInputStream (java.io.ByteArrayInputStream)4 ByteArrayOutputStream (java.io.ByteArrayOutputStream)3 ObjectOutputStream (java.io.ObjectOutputStream)3 GwtIncompatible (com.google_voltpatches.common.annotations.GwtIncompatible)2 Point (java.awt.Point)2 RemoteObjectInvocationHandler (java.rmi.server.RemoteObjectInvocationHandler)2 RemoteRef (java.rmi.server.RemoteRef)2 Comparator (java.util.Comparator)2 SimpleTimeZone (java.util.SimpleTimeZone)2 TimeZone (java.util.TimeZone)2 MBeanException (javax.management.MBeanException)2 OpenDataException (javax.management.openmbean.OpenDataException)2 IgniteLogger (org.apache.ignite.IgniteLogger)2 ANTLRException (antlr.ANTLRException)1