Search in sources :

Example 16 with InvalidObjectException

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

the class ObjectName method readObject.

// Category : Internal accessors <==============================
// Category : Serialization ----------------------------------->
/**
     * Deserializes an {@link ObjectName} from an {@link ObjectInputStream}.
     * @serialData <ul>
     *               <li>In the current serial form (value of property
     *                   <code>jmx.serial.form</code> differs from
     *                   <code>1.0</code>): the string
     *                   &quot;&lt;domain&gt;:&lt;properties&gt;&lt;wild&gt;&quot;,
     *                   where: <ul>
     *                            <li>&lt;domain&gt; represents the domain part
     *                                of the {@link ObjectName}</li>
     *                            <li>&lt;properties&gt; represents the list of
     *                                properties, as returned by
     *                                {@link #getKeyPropertyListString}
     *                            <li>&lt;wild&gt; is empty if not
     *                                <code>isPropertyPattern</code>, or
     *                                is the character "<code>*</code>" if
     *                                <code>isPropertyPattern</code>
     *                                and &lt;properties&gt; is empty, or
     *                                is "<code>,*</code>" if
     *                                <code>isPropertyPattern</code> and
     *                                &lt;properties&gt; is not empty.
     *                            </li>
     *                          </ul>
     *                   The intent is that this string could be supplied
     *                   to the {@link #ObjectName(String)} constructor to
     *                   produce an equivalent {@link ObjectName}.
     *               </li>
     *               <li>In the old serial form (value of property
     *                   <code>jmx.serial.form</code> is
     *                   <code>1.0</code>): &lt;domain&gt; &lt;propertyList&gt;
     *                   &lt;propertyListString&gt; &lt;canonicalName&gt;
     *                   &lt;pattern&gt; &lt;propertyPattern&gt;,
     *                   where: <ul>
     *                            <li>&lt;domain&gt; represents the domain part
     *                                of the {@link ObjectName}</li>
     *                            <li>&lt;propertyList&gt; is the
     *                                {@link Hashtable} that contains all the
     *                                pairs (key,value) for this
     *                                {@link ObjectName}</li>
     *                            <li>&lt;propertyListString&gt; is the
     *                                {@link String} representation of the
     *                                list of properties in any order (not
     *                                mandatorily a canonical representation)
     *                                </li>
     *                            <li>&lt;canonicalName&gt; is the
     *                                {@link String} containing this
     *                                {@link ObjectName}'s canonical name</li>
     *                            <li>&lt;pattern&gt; is a boolean which is
     *                                <code>true</code> if this
     *                                {@link ObjectName} contains a pattern</li>
     *                            <li>&lt;propertyPattern&gt; is a boolean which
     *                                is <code>true</code> if this
     *                                {@link ObjectName} contains a pattern in
     *                                the list of properties</li>
     *                          </ul>
     *               </li>
     *             </ul>
     */
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
    String cn;
    if (compat) {
        // Read an object serialized in the old serial form
        //
        //in.defaultReadObject();
        final ObjectInputStream.GetField fields = in.readFields();
        String propListString = (String) fields.get("propertyListString", "");
        // 6616825: take care of property patterns
        final boolean propPattern = fields.get("propertyPattern", false);
        if (propPattern) {
            propListString = (propListString.length() == 0 ? "*" : (propListString + ",*"));
        }
        cn = (String) fields.get("domain", "default") + ":" + propListString;
    } else {
        // Read an object serialized in the new serial form
        //
        in.defaultReadObject();
        cn = (String) in.readObject();
    }
    try {
        construct(cn);
    } catch (NullPointerException e) {
        throw new InvalidObjectException(e.toString());
    } catch (MalformedObjectNameException e) {
        throw new InvalidObjectException(e.toString());
    }
}
Also used : InvalidObjectException(java.io.InvalidObjectException) ObjectInputStream(java.io.ObjectInputStream)

Example 17 with InvalidObjectException

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

the class ImmutableDescriptor method readResolve.

/**
     * This method can replace a deserialized instance of this
     * class with another instance.  For example, it might replace
     * a deserialized empty ImmutableDescriptor with
     * {@link #EMPTY_DESCRIPTOR}.
     *
     * @return the replacement object, which may be {@code this}.
     *
     * @throws InvalidObjectException if the read object has invalid fields.
     */
private Object readResolve() throws InvalidObjectException {
    boolean bad = false;
    if (names == null || values == null || names.length != values.length)
        bad = true;
    if (!bad) {
        if (names.length == 0 && getClass() == ImmutableDescriptor.class)
            return EMPTY_DESCRIPTOR;
        final Comparator<String> compare = String.CASE_INSENSITIVE_ORDER;
        // also catches illegal null name
        String lastName = "";
        for (int i = 0; i < names.length; i++) {
            if (names[i] == null || compare.compare(lastName, names[i]) >= 0) {
                bad = true;
                break;
            }
            lastName = names[i];
        }
    }
    if (bad)
        throw new InvalidObjectException("Bad names or values");
    return this;
}
Also used : InvalidObjectException(java.io.InvalidObjectException)

Example 18 with InvalidObjectException

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

the class RMIConnector method writeObject.

/**
     * Writes the RMIConnector fields to an {@link java.io.ObjectOutputStream
     * ObjectOutputStream}.
     * <p>Connects the underlying RMIServer stub to an ORB, if needed,
     * before serializing it. This is done using the environment
     * map that was provided to the constructor, if any, and as documented
     * in {@link javax.management.remote.rmi}.</p>
     * <p>This method then calls <code>s.defaultWriteObject()</code>.
     * Usually, <var>rmiServer</var> is null if this object
     * was constructed with a JMXServiceURL, and <var>jmxServiceURL</var>
     * is null if this object is constructed with a RMIServer stub.
     * <p>Note that the environment Map is not serialized, since the objects
     * it contains are assumed to be contextual and relevant only
     * with respect to the local environment (class loader, ORB, etc...).</p>
     * <p>After an RMIConnector is deserialized, it is assumed that the
     * user will call {@link #connect(Map)}, providing a new Map that
     * can contain values which are contextually relevant to the new
     * local environment.</p>
     * <p>Since connection to the ORB is needed prior to serializing, and
     * since the ORB to connect to is one of those contextual parameters,
     * it is not recommended to re-serialize a just de-serialized object -
     * as the de-serialized object has no map. Thus, when an RMIConnector
     * object is needed for serialization or transmission to a remote
     * application, it is recommended to obtain a new RMIConnector stub
     * by calling {@link RMIConnectorServer#toJMXConnector(Map)}.</p>
     * @param s The ObjectOutputStream to write to.
     * @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 writeObject(java.io.ObjectOutputStream s) throws IOException {
    if (rmiServer == null && jmxServiceURL == null)
        throw new InvalidObjectException("rmiServer and jmxServiceURL both null.");
    connectStub(this.rmiServer, env);
    s.defaultWriteObject();
}
Also used : InvalidObjectException(java.io.InvalidObjectException)

Example 19 with InvalidObjectException

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

the class JMXPrincipal method readObject.

private void readObject(ObjectInputStream ois) throws IOException, ClassNotFoundException {
    ObjectInputStream.GetField gf = ois.readFields();
    String principalName = (String) gf.get("name", null);
    try {
        validate(principalName);
        this.name = principalName;
    } catch (NullPointerException e) {
        throw new InvalidObjectException(e.getMessage());
    }
}
Also used : InvalidObjectException(java.io.InvalidObjectException) ObjectInputStream(java.io.ObjectInputStream)

Example 20 with InvalidObjectException

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

the class NotificationResult method readObject.

private void readObject(ObjectInputStream ois) throws IOException, ClassNotFoundException {
    ois.defaultReadObject();
    try {
        validate(this.targetedNotifications, this.earliestSequenceNumber, this.nextSequenceNumber);
        this.targetedNotifications = this.targetedNotifications.length == 0 ? this.targetedNotifications : this.targetedNotifications.clone();
    } catch (IllegalArgumentException e) {
        throw new InvalidObjectException(e.getMessage());
    }
}
Also used : InvalidObjectException(java.io.InvalidObjectException)

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