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
* "<domain>:<properties><wild>",
* where: <ul>
* <li><domain> represents the domain part
* of the {@link ObjectName}</li>
* <li><properties> represents the list of
* properties, as returned by
* {@link #getKeyPropertyListString}
* <li><wild> is empty if not
* <code>isPropertyPattern</code>, or
* is the character "<code>*</code>" if
* <code>isPropertyPattern</code>
* and <properties> is empty, or
* is "<code>,*</code>" if
* <code>isPropertyPattern</code> and
* <properties> 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>): <domain> <propertyList>
* <propertyListString> <canonicalName>
* <pattern> <propertyPattern>,
* where: <ul>
* <li><domain> represents the domain part
* of the {@link ObjectName}</li>
* <li><propertyList> is the
* {@link Hashtable} that contains all the
* pairs (key,value) for this
* {@link ObjectName}</li>
* <li><propertyListString> is the
* {@link String} representation of the
* list of properties in any order (not
* mandatorily a canonical representation)
* </li>
* <li><canonicalName> is the
* {@link String} containing this
* {@link ObjectName}'s canonical name</li>
* <li><pattern> is a boolean which is
* <code>true</code> if this
* {@link ObjectName} contains a pattern</li>
* <li><propertyPattern> 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());
}
}
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;
}
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();
}
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());
}
}
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());
}
}
Aggregations