diff --git a/src/java.management/share/classes/javax/management/ClassAttributeValueExp.java b/src/java.management/share/classes/javax/management/ClassAttributeValueExp.java
index 06c488f90fac7..f7c40691e39b5 100644
--- a/src/java.management/share/classes/javax/management/ClassAttributeValueExp.java
+++ b/src/java.management/share/classes/javax/management/ClassAttributeValueExp.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1999, 2021, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2024, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -39,37 +39,9 @@
*
* @since 1.5
*/
-@SuppressWarnings("serial") // serialVersionUID is not constant
class ClassAttributeValueExp extends AttributeValueExp {
- // Serialization compatibility stuff:
- // Two serial forms are supported in this class. The selected form depends
- // on system property "jmx.serial.form":
- // - "1.0" for JMX 1.0
- // - any other value for JMX 1.1 and higher
- //
- // Serial version for old serial form
- private static final long oldSerialVersionUID = -2212731951078526753L;
- //
- // Serial version for new serial form
- private static final long newSerialVersionUID = -1081892073854801359L;
-
- private static final long serialVersionUID;
- static {
- boolean compat = false;
- try {
- GetPropertyAction act = new GetPropertyAction("jmx.serial.form");
- @SuppressWarnings("removal")
- String form = AccessController.doPrivileged(act);
- compat = (form != null && form.equals("1.0"));
- } catch (Exception e) {
- // OK: exception means no compat with 1.0, too bad
- }
- if (compat)
- serialVersionUID = oldSerialVersionUID;
- else
- serialVersionUID = newSerialVersionUID;
- }
+ private static final long serialVersionUID = -1081892073854801359L;
/**
* @serial The name of the attribute
diff --git a/src/java.management/share/classes/javax/management/MBeanAttributeInfo.java b/src/java.management/share/classes/javax/management/MBeanAttributeInfo.java
index 6d31becbb7317..6551e9ba81bfa 100644
--- a/src/java.management/share/classes/javax/management/MBeanAttributeInfo.java
+++ b/src/java.management/share/classes/javax/management/MBeanAttributeInfo.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1999, 2021, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2024, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -40,33 +40,9 @@
*
* @since 1.5
*/
-@SuppressWarnings("serial") // serialVersionUID not constant
public class MBeanAttributeInfo extends MBeanFeatureInfo implements Cloneable {
- /* Serial version */
- private static final long serialVersionUID;
- static {
- /* For complicated reasons, the serialVersionUID changed
- between JMX 1.0 and JMX 1.1, even though JMX 1.1 did not
- have compatibility code for this class. So the
- serialization produced by this class with JMX 1.2 and
- jmx.serial.form=1.0 is not the same as that produced by
- this class with JMX 1.1 and jmx.serial.form=1.0. However,
- the serialization without that property is the same, and
- that is the only form required by JMX 1.2.
- */
- long uid = 8644704819898565848L;
- try {
- GetPropertyAction act = new GetPropertyAction("jmx.serial.form");
- @SuppressWarnings("removal")
- String form = AccessController.doPrivileged(act);
- if ("1.0".equals(form))
- uid = 7043855487133450673L;
- } catch (Exception e) {
- // OK: exception means no compat with 1.0, too bad
- }
- serialVersionUID = uid;
- }
+ private static final long serialVersionUID = 8644704819898565848L;
static final MBeanAttributeInfo[] NO_ATTRIBUTES =
new MBeanAttributeInfo[0];
diff --git a/src/java.management/share/classes/javax/management/Notification.java b/src/java.management/share/classes/javax/management/Notification.java
index 9455264fa04eb..80cf4b464d268 100644
--- a/src/java.management/share/classes/javax/management/Notification.java
+++ b/src/java.management/share/classes/javax/management/Notification.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1999, 2021, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2024, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -53,46 +53,9 @@
*
* @since 1.5
*/
-@SuppressWarnings("serial") // serialVersionUID is not constant
public class Notification extends EventObject {
- // Serialization compatibility stuff:
- // Two serial forms are supported in this class. The selected form depends
- // on system property "jmx.serial.form":
- // - "1.0" for JMX 1.0
- // - any other value for JMX 1.1 and higher
- //
- // Serial version for old serial form
- private static final long oldSerialVersionUID = 1716977971058914352L;
- //
- // Serial version for new serial form
- private static final long newSerialVersionUID = -7516092053498031989L;
- //
- // Serializable fields in old serial form
- private static final ObjectStreamField[] oldSerialPersistentFields =
- {
- new ObjectStreamField("message", String.class),
- new ObjectStreamField("sequenceNumber", Long.TYPE),
- new ObjectStreamField("source", Object.class),
- new ObjectStreamField("sourceObjectName", ObjectName.class),
- new ObjectStreamField("timeStamp", Long.TYPE),
- new ObjectStreamField("type", String.class),
- new ObjectStreamField("userData", Object.class)
- };
- //
- // Serializable fields in new serial form
- private static final ObjectStreamField[] newSerialPersistentFields =
- {
- new ObjectStreamField("message", String.class),
- new ObjectStreamField("sequenceNumber", Long.TYPE),
- new ObjectStreamField("source", Object.class),
- new ObjectStreamField("timeStamp", Long.TYPE),
- new ObjectStreamField("type", String.class),
- new ObjectStreamField("userData", Object.class)
- };
- //
- // Actual serial version and serial form
- private static final long serialVersionUID;
+ private static final long serialVersionUID = -7516092053498031989L;
/**
* @serialField type String The notification type.
* A string expressed in a dot notation similar to Java properties.
@@ -108,28 +71,15 @@ public class Notification extends EventObject {
* @serialField message String The notification message.
* @serialField source Object The object on which the notification initially occurred.
*/
- private static final ObjectStreamField[] serialPersistentFields;
- private static boolean compat = false;
- static {
- try {
- GetPropertyAction act = new GetPropertyAction("jmx.serial.form");
- @SuppressWarnings("removal")
- String form = AccessController.doPrivileged(act);
- compat = (form != null && form.equals("1.0"));
- } catch (Exception e) {
- // OK: exception means no compat with 1.0, too bad
- }
- if (compat) {
- serialPersistentFields = oldSerialPersistentFields;
- serialVersionUID = oldSerialVersionUID;
- } else {
- serialPersistentFields = newSerialPersistentFields;
- serialVersionUID = newSerialVersionUID;
- }
- }
- //
- // END Serialization compatibility stuff
-
+ private static final ObjectStreamField[] serialPersistentFields =
+ {
+ new ObjectStreamField("message", String.class),
+ new ObjectStreamField("sequenceNumber", Long.TYPE),
+ new ObjectStreamField("source", Object.class),
+ new ObjectStreamField("timeStamp", Long.TYPE),
+ new ObjectStreamField("type", String.class),
+ new ObjectStreamField("userData", Object.class)
+ };
/**
* @serial The notification type.
* A string expressed in a dot notation similar to Java properties.
@@ -378,21 +328,6 @@ private void readObject(ObjectInputStream in)
*/
private void writeObject(ObjectOutputStream out)
throws IOException {
- if (compat) {
- // Serializes this instance in the old serial form
- //
- ObjectOutputStream.PutField fields = out.putFields();
- fields.put("type", type);
- fields.put("sequenceNumber", sequenceNumber);
- fields.put("timeStamp", timeStamp);
- fields.put("userData", userData);
- fields.put("message", message);
- fields.put("source", source);
- out.writeFields();
- } else {
- // Serializes this instance in the new serial form
- //
- out.defaultWriteObject();
- }
+ out.defaultWriteObject();
}
}
diff --git a/src/java.management/share/classes/javax/management/NumericValueExp.java b/src/java.management/share/classes/javax/management/NumericValueExp.java
index 959375a2f500d..bae84019d2e31 100644
--- a/src/java.management/share/classes/javax/management/NumericValueExp.java
+++ b/src/java.management/share/classes/javax/management/NumericValueExp.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1999, 2021, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2024, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -45,68 +45,19 @@
*
* @since 1.5
*/
-@SuppressWarnings("serial") // serialVersionUID not constant
class NumericValueExp extends QueryEval implements ValueExp {
- // Serialization compatibility stuff:
- // Two serial forms are supported in this class. The selected form depends
- // on system property "jmx.serial.form":
- // - "1.0" for JMX 1.0
- // - any other value for JMX 1.1 and higher
- //
- // Serial version for old serial form
- private static final long oldSerialVersionUID = -6227876276058904000L;
- //
- // Serial version for new serial form
- private static final long newSerialVersionUID = -4679739485102359104L;
- //
- // Serializable fields in old serial form
- private static final ObjectStreamField[] oldSerialPersistentFields =
- {
- new ObjectStreamField("longVal", Long.TYPE),
- new ObjectStreamField("doubleVal", Double.TYPE),
- new ObjectStreamField("valIsLong", Boolean.TYPE)
- };
- //
- // Serializable fields in new serial form
- private static final ObjectStreamField[] newSerialPersistentFields =
- {
- new ObjectStreamField("val", Number.class)
- };
- //
- // Actual serial version and serial form
- private static final long serialVersionUID;
-
+ private static final long serialVersionUID = -4679739485102359104L;
/**
* @serialField val Number The numeric value
*
*
The serialVersionUID of this class is -4679739485102359104L
.
*/
- private static final ObjectStreamField[] serialPersistentFields;
+ private static final ObjectStreamField[] serialPersistentFields = {
+ new ObjectStreamField("val", Number.class)
+ };
private Number val = 0.0;
- private static boolean compat = false;
- static {
- try {
- GetPropertyAction act = new GetPropertyAction("jmx.serial.form");
- @SuppressWarnings("removal")
- String form = AccessController.doPrivileged(act);
- compat = (form != null && form.equals("1.0"));
- } catch (Exception e) {
- // OK: exception means no compat with 1.0, too bad
- }
- if (compat) {
- serialPersistentFields = oldSerialPersistentFields;
- serialVersionUID = oldSerialVersionUID;
- } else {
- serialPersistentFields = newSerialPersistentFields;
- serialVersionUID = newSerialVersionUID;
- }
- }
- //
- // END Serialization compatibility stuff
-
-
/**
* Basic constructor.
*/
@@ -189,44 +140,7 @@ public ValueExp apply(ObjectName name)
*/
private void readObject(ObjectInputStream in)
throws IOException, ClassNotFoundException {
- if (compat)
- {
- // Read an object serialized in the old serial form
- //
- double doubleVal;
- long longVal;
- boolean isLong;
- ObjectInputStream.GetField fields = in.readFields();
- doubleVal = fields.get("doubleVal", (double)0);
- if (fields.defaulted("doubleVal"))
- {
- throw new NullPointerException("doubleVal");
- }
- longVal = fields.get("longVal", (long)0);
- if (fields.defaulted("longVal"))
- {
- throw new NullPointerException("longVal");
- }
- isLong = fields.get("valIsLong", false);
- if (fields.defaulted("valIsLong"))
- {
- throw new NullPointerException("valIsLong");
- }
- if (isLong)
- {
- this.val = longVal;
- }
- else
- {
- this.val = doubleVal;
- }
- }
- else
- {
- // Read an object serialized in the new serial form
- //
- in.defaultReadObject();
- }
+ in.defaultReadObject();
}
@@ -235,22 +149,7 @@ private void readObject(ObjectInputStream in)
*/
private void writeObject(ObjectOutputStream out)
throws IOException {
- if (compat)
- {
- // Serializes this instance in the old serial form
- //
- ObjectOutputStream.PutField fields = out.putFields();
- fields.put("doubleVal", doubleValue());
- fields.put("longVal", longValue());
- fields.put("valIsLong", isLong());
- out.writeFields();
- }
- else
- {
- // Serializes this instance in the new serial form
- //
- out.defaultWriteObject();
- }
+ out.defaultWriteObject();
}
@Deprecated
diff --git a/src/java.management/share/classes/javax/management/ObjectName.java b/src/java.management/share/classes/javax/management/ObjectName.java
index 00d5cc6930d60..f20750c9d8a84 100644
--- a/src/java.management/share/classes/javax/management/ObjectName.java
+++ b/src/java.management/share/classes/javax/management/ObjectName.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1999, 2022, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2024, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -222,7 +222,6 @@
* @implNote The maximum allowed length of the domain name in this implementation
* is {@code Integer.MAX_VALUE/4}
*/
-@SuppressWarnings("serial") // don't complain serialVersionUID not constant
public class ObjectName implements Comparable, QueryExp {
private static final int DOMAIN_PATTERN = 0x8000_0000;
private static final int PROPLIST_PATTERN = 0x4000_0000;
@@ -294,57 +293,7 @@ private static class PatternProperty extends Property {
// Private fields ---------------------------------------->
- // Serialization compatibility stuff -------------------->
-
- // Two serial forms are supported in this class. The selected form depends
- // on system property "jmx.serial.form":
- // - "1.0" for JMX 1.0
- // - any other value for JMX 1.1 and higher
- //
- // Serial version for old serial form
- private static final long oldSerialVersionUID = -5467795090068647408L;
- //
- // Serial version for new serial form
- private static final long newSerialVersionUID = 1081892073854801359L;
- //
- // Serializable fields in old serial form
- private static final ObjectStreamField[] oldSerialPersistentFields =
- {
- new ObjectStreamField("domain", String.class),
- new ObjectStreamField("propertyList", Hashtable.class),
- new ObjectStreamField("propertyListString", String.class),
- new ObjectStreamField("canonicalName", String.class),
- new ObjectStreamField("pattern", Boolean.TYPE),
- new ObjectStreamField("propertyPattern", Boolean.TYPE)
- };
- //
- // Serializable fields in new serial form
- private static final ObjectStreamField[] newSerialPersistentFields = { };
- //
- // Actual serial version and serial form
- private static final long serialVersionUID;
- private static final ObjectStreamField[] serialPersistentFields;
- private static boolean compat = false;
- static {
- try {
- GetPropertyAction act = new GetPropertyAction("jmx.serial.form");
- @SuppressWarnings("removal")
- String form = AccessController.doPrivileged(act);
- compat = (form != null && form.equals("1.0"));
- } catch (Exception e) {
- // OK: exception means no compat with 1.0, too bad
- }
- if (compat) {
- serialPersistentFields = oldSerialPersistentFields;
- serialVersionUID = oldSerialVersionUID;
- } else {
- serialPersistentFields = newSerialPersistentFields;
- serialVersionUID = newSerialVersionUID;
- }
- }
-
- //
- // Serialization compatibility stuff <==============================
+ private static final long serialVersionUID = 1081892073854801359L;
// Class private fields ----------------------------------->
@@ -1088,90 +1037,32 @@ private void setDomainLength(int length) throws MalformedObjectNameException {
/**
* Deserializes an {@link ObjectName} from an {@link ObjectInputStream}.
- * @serialData
- * - In the current serial form (value of property
- *
jmx.serial.form
differs from
- * 1.0
): the string
- * "<domain>:<properties><wild>",
- * where:
- * - <domain> represents the domain part
- * of the {@link ObjectName}
- * - <properties> represents the list of
- * properties, as returned by
- * {@link #getKeyPropertyListString}
- *
- <wild> is empty if not
- *
isPropertyPattern
, or
- * is the character "*
" if
- * isPropertyPattern
- * and <properties> is empty, or
- * is ",*
" if
- * isPropertyPattern
and
- * <properties> is not empty.
- *
- *
- * The intent is that this string could be supplied
- * to the {@link #ObjectName(String)} constructor to
- * produce an equivalent {@link ObjectName}.
- *
- * - In the old serial form (value of property
- *
jmx.serial.form
is
- * 1.0
): <domain> <propertyList>
- * <propertyListString> <canonicalName>
- * <pattern> <propertyPattern>,
- * where:
- * - <domain> represents the domain part
- * of the {@link ObjectName}
- * - <propertyList> is the
- * {@link Hashtable} that contains all the
- * pairs (key,value) for this
- * {@link ObjectName}
- * - <propertyListString> is the
- * {@link String} representation of the
- * list of properties in any order (not
- * mandatorily a canonical representation)
- *
- * - <canonicalName> is the
- * {@link String} containing this
- * {@link ObjectName}'s canonical name
- * - <pattern> is a boolean which is
- *
true
if this
- * {@link ObjectName} contains a pattern
- * - <propertyPattern> is a boolean which
- * is
true
if this
- * {@link ObjectName} contains a pattern in
- * the list of properties
- *
- *
+ * @serialData The string "<domain>:<properties><wild>", where:
+ *
+ * - <domain> represents the domain part
+ * of the {@link ObjectName}
+ * - <properties> represents the list of
+ * properties, as returned by
+ * {@link #getKeyPropertyListString}
+ * - <wild> is empty if not
+ *
isPropertyPattern
, or
+ * is the character "*
" if
+ * isPropertyPattern
+ * and <properties> is empty, or
+ * is ",*
" if
+ * isPropertyPattern
and
+ * <properties> is not empty.
*
+ * The intent is that this string could be supplied
+ * to the {@link #ObjectName(String)} constructor to
+ * produce an equivalent {@link ObjectName}.
*/
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();
- }
+ in.defaultReadObject();
+ cn = (String)in.readObject();
try {
construct(cn);
@@ -1183,85 +1074,31 @@ private void readObject(ObjectInputStream in)
/**
* Serializes an {@link ObjectName} to an {@link ObjectOutputStream}.
- * @serialData
- * - In the current serial form (value of property
- *
jmx.serial.form
differs from
- * 1.0
): the string
- * "<domain>:<properties><wild>",
- * where:
- * - <domain> represents the domain part
- * of the {@link ObjectName}
- * - <properties> represents the list of
- * properties, as returned by
- * {@link #getKeyPropertyListString}
- *
- <wild> is empty if not
- *
isPropertyPattern
, or
- * is the character "*
" if
- * this isPropertyPattern
- * and <properties> is empty, or
- * is ",*
" if
- * isPropertyPattern
and
- * <properties> is not empty.
- *
- *
- * The intent is that this string could be supplied
- * to the {@link #ObjectName(String)} constructor to
- * produce an equivalent {@link ObjectName}.
- *
- * - In the old serial form (value of property
- *
jmx.serial.form
is
- * 1.0
): <domain> <propertyList>
- * <propertyListString> <canonicalName>
- * <pattern> <propertyPattern>,
- * where:
- * - <domain> represents the domain part
- * of the {@link ObjectName}
- * - <propertyList> is the
- * {@link Hashtable} that contains all the
- * pairs (key,value) for this
- * {@link ObjectName}
- * - <propertyListString> is the
- * {@link String} representation of the
- * list of properties in any order (not
- * mandatorily a canonical representation)
- *
- * - <canonicalName> is the
- * {@link String} containing this
- * {@link ObjectName}'s canonical name
- * - <pattern> is a boolean which is
- *
true
if this
- * {@link ObjectName} contains a pattern
- * - <propertyPattern> is a boolean which
- * is
true
if this
- * {@link ObjectName} contains a pattern in
- * the list of properties
- *
- *
+ * @serialData The string "<domain>:<properties><wild>", where:
+ *
+ * - <domain> represents the domain part
+ * of the {@link ObjectName}
+ * - <properties> represents the list of
+ * properties, as returned by
+ * {@link #getKeyPropertyListString}
+ * - <wild> is empty if not
+ *
isPropertyPattern
, or
+ * is the character "*
" if
+ * this isPropertyPattern
+ * and <properties> is empty, or
+ * is ",*
" if
+ * isPropertyPattern
and
+ * <properties> is not empty.
*
+ * The intent is that this string could be supplied
+ * to the {@link #ObjectName(String)} constructor to
+ * produce an equivalent {@link ObjectName}.
*/
private void writeObject(ObjectOutputStream out)
throws IOException {
- if (compat)
- {
- // Serializes this instance in the old serial form
- // Read CR 6441274 before making any changes to this code
- ObjectOutputStream.PutField fields = out.putFields();
- fields.put("domain", _canonicalName.substring(0, getDomainLength()));
- fields.put("propertyList", getKeyPropertyList());
- fields.put("propertyListString", getKeyPropertyListString());
- fields.put("canonicalName", _canonicalName);
- fields.put("pattern", (_compressed_storage & (DOMAIN_PATTERN | PROPLIST_PATTERN)) != 0);
- fields.put("propertyPattern", isPropertyListPattern());
- out.writeFields();
- }
- else
- {
- // Serializes this instance in the new serial form
- //
- out.defaultWriteObject();
- out.writeObject(getSerializedNameString());
- }
+ out.defaultWriteObject();
+ out.writeObject(getSerializedNameString());
}
// Category : Serialization <===================================
diff --git a/src/java.management/share/classes/javax/management/modelmbean/DescriptorSupport.java b/src/java.management/share/classes/javax/management/modelmbean/DescriptorSupport.java
index 00aa6ab7eb7c3..bea7ad92d0ce7 100644
--- a/src/java.management/share/classes/javax/management/modelmbean/DescriptorSupport.java
+++ b/src/java.management/share/classes/javax/management/modelmbean/DescriptorSupport.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2000, 2022, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2024, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -81,69 +81,18 @@
*
* @since 1.5
*/
-@SuppressWarnings("serial") // serialVersionUID not constant
public class DescriptorSupport
implements javax.management.Descriptor
{
- // Serialization compatibility stuff:
- // Two serial forms are supported in this class. The selected form depends
- // on system property "jmx.serial.form":
- // - "1.0" for JMX 1.0
- // - any other value for JMX 1.1 and higher
- //
- // Serial version for old serial form
- private static final long oldSerialVersionUID = 8071560848919417985L;
- //
- // Serial version for new serial form
- private static final long newSerialVersionUID = -6292969195866300415L;
- //
- // Serializable fields in old serial form
- private static final ObjectStreamField[] oldSerialPersistentFields =
- {
- new ObjectStreamField("descriptor", HashMap.class),
- new ObjectStreamField("currClass", String.class)
- };
- //
- // Serializable fields in new serial form
- private static final ObjectStreamField[] newSerialPersistentFields =
- {
- new ObjectStreamField("descriptor", HashMap.class)
- };
- //
- // Actual serial version and serial form
- private static final long serialVersionUID;
+ private static final long serialVersionUID = -6292969195866300415L;
/**
* @serialField descriptor HashMap The collection of fields representing this descriptor
*/
- private static final ObjectStreamField[] serialPersistentFields;
- private static final String serialForm;
- static {
- serialForm = getForm();
- boolean compat = "1.0".equals(serialForm); // serialForm may be null
- if (compat) {
- serialPersistentFields = oldSerialPersistentFields;
- serialVersionUID = oldSerialVersionUID;
- } else {
- serialPersistentFields = newSerialPersistentFields;
- serialVersionUID = newSerialVersionUID;
- }
- }
-
- @SuppressWarnings("removal")
- private static String getForm() {
- String form = null;
- try {
- GetPropertyAction act = new GetPropertyAction("jmx.serial.form");
- return AccessController.doPrivileged(act);
- } catch (Exception e) {
- // OK: No compat with 1.0
- return null;
- }
- }
-
- //
- // END Serialization compatibility stuff
+ private static final ObjectStreamField[] serialPersistentFields =
+ {
+ new ObjectStreamField("descriptor", HashMap.class)
+ };
/* Spec says that field names are case-insensitive, but that case
is preserved. This means that we need to be able to map from a
@@ -1286,22 +1235,8 @@ private void readObject(ObjectInputStream in)
/**
* Serializes a {@link DescriptorSupport} to an {@link ObjectOutputStream}.
*/
- /* If you set jmx.serial.form to "1.2.0" or "1.2.1", then we are
- bug-compatible with those versions. Specifically, field names
- are forced to lower-case before being written. This
- contradicts the spec, which, though it does not mention
- serialization explicitly, does say that the case of field names
- is preserved. But in 1.2.0 and 1.2.1, this requirement was not
- met. Instead, field names in the descriptor map were forced to
- lower case. Those versions expect this to have happened to a
- descriptor they deserialize and e.g. getFieldValue will not
- find a field whose name is spelt with a different case.
- */
private void writeObject(ObjectOutputStream out) throws IOException {
ObjectOutputStream.PutField fields = out.putFields();
- boolean compat = "1.0".equals(serialForm);
- if (compat)
- fields.put("currClass", currClass);
/* Purge the field "targetObject" from the DescriptorSupport before
* serializing since the referenced object is typically not
@@ -1315,15 +1250,7 @@ private void writeObject(ObjectOutputStream out) throws IOException {
startMap.remove("targetObject");
}
- final HashMap descriptor;
- if (compat || "1.2.0".equals(serialForm) ||
- "1.2.1".equals(serialForm)) {
- descriptor = new HashMap<>();
- for (Map.Entry entry : startMap.entrySet())
- descriptor.put(entry.getKey().toLowerCase(), entry.getValue());
- } else
- descriptor = new HashMap<>(startMap);
-
+ final HashMap descriptor = new HashMap<>(startMap);
fields.put("descriptor", descriptor);
out.writeFields();
}
diff --git a/src/java.management/share/classes/javax/management/modelmbean/InvalidTargetObjectTypeException.java b/src/java.management/share/classes/javax/management/modelmbean/InvalidTargetObjectTypeException.java
index 2c90dcaa20932..d7d3bed055c6f 100644
--- a/src/java.management/share/classes/javax/management/modelmbean/InvalidTargetObjectTypeException.java
+++ b/src/java.management/share/classes/javax/management/modelmbean/InvalidTargetObjectTypeException.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2000, 2021, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2024, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -46,61 +46,16 @@
*
* @since 1.5
*/
-@SuppressWarnings("serial") // serialVersionUID not constant
public class InvalidTargetObjectTypeException extends Exception
{
-
- // Serialization compatibility stuff:
- // Two serial forms are supported in this class. The selected form depends
- // on system property "jmx.serial.form":
- // - "1.0" for JMX 1.0
- // - any other value for JMX 1.1 and higher
- //
- // Serial version for old serial form
- private static final long oldSerialVersionUID = 3711724570458346634L;
- //
- // Serial version for new serial form
- private static final long newSerialVersionUID = 1190536278266811217L;
- //
- // Serializable fields in old serial form
- private static final ObjectStreamField[] oldSerialPersistentFields =
- {
- new ObjectStreamField("msgStr", String.class),
- new ObjectStreamField("relatedExcept", Exception.class)
- };
- //
- // Serializable fields in new serial form
- private static final ObjectStreamField[] newSerialPersistentFields =
- {
- new ObjectStreamField("exception", Exception.class)
- };
- //
- // Actual serial version and serial form
- private static final long serialVersionUID;
+ private static final long serialVersionUID = 1190536278266811217L;
/**
* @serialField exception Exception Encapsulated {@link Exception}
*/
- private static final ObjectStreamField[] serialPersistentFields;
- private static boolean compat = false;
- static {
- try {
- GetPropertyAction act = new GetPropertyAction("jmx.serial.form");
- @SuppressWarnings("removal")
- String form = AccessController.doPrivileged(act);
- compat = (form != null && form.equals("1.0"));
- } catch (Exception e) {
- // OK: No compat with 1.0
- }
- if (compat) {
- serialPersistentFields = oldSerialPersistentFields;
- serialVersionUID = oldSerialVersionUID;
- } else {
- serialPersistentFields = newSerialPersistentFields;
- serialVersionUID = newSerialVersionUID;
- }
- }
- //
- // END Serialization compatibility stuff
+ private static final ObjectStreamField[] serialPersistentFields =
+ {
+ new ObjectStreamField("exception", Exception.class)
+ };
/**
* @serial Encapsulated {@link Exception}
@@ -156,23 +111,7 @@ public InvalidTargetObjectTypeException (Exception e, String s)
*/
private void readObject(ObjectInputStream in)
throws IOException, ClassNotFoundException {
- if (compat)
- {
- // Read an object serialized in the old serial form
- //
- ObjectInputStream.GetField fields = in.readFields();
- exception = (Exception) fields.get("relatedExcept", null);
- if (fields.defaulted("relatedExcept"))
- {
- throw new NullPointerException("relatedExcept");
- }
- }
- else
- {
- // Read an object serialized in the new serial form
- //
- in.defaultReadObject();
- }
+ in.defaultReadObject();
}
@@ -181,20 +120,6 @@ private void readObject(ObjectInputStream in)
*/
private void writeObject(ObjectOutputStream out)
throws IOException {
- if (compat)
- {
- // Serializes this instance in the old serial form
- //
- ObjectOutputStream.PutField fields = out.putFields();
- fields.put("relatedExcept", exception);
- fields.put("msgStr", ((exception != null)?exception.getMessage():""));
- out.writeFields();
- }
- else
- {
- // Serializes this instance in the new serial form
- //
- out.defaultWriteObject();
- }
+ out.defaultWriteObject();
}
}
diff --git a/src/java.management/share/classes/javax/management/modelmbean/ModelMBeanAttributeInfo.java b/src/java.management/share/classes/javax/management/modelmbean/ModelMBeanAttributeInfo.java
index b4e7ecfd1e731..d30bd368a63bf 100644
--- a/src/java.management/share/classes/javax/management/modelmbean/ModelMBeanAttributeInfo.java
+++ b/src/java.management/share/classes/javax/management/modelmbean/ModelMBeanAttributeInfo.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2000, 2021, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2024, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -116,63 +116,19 @@
* @since 1.5
*/
-@SuppressWarnings("serial") // serialVersionUID is not constant
public class ModelMBeanAttributeInfo
extends MBeanAttributeInfo
implements DescriptorAccess {
- // Serialization compatibility stuff:
- // Two serial forms are supported in this class. The selected form depends
- // on system property "jmx.serial.form":
- // - "1.0" for JMX 1.0
- // - any other value for JMX 1.1 and higher
- //
- // Serial version for old serial form
- private static final long oldSerialVersionUID = 7098036920755973145L;
- //
- // Serial version for new serial form
- private static final long newSerialVersionUID = 6181543027787327345L;
- //
- // Serializable fields in old serial form
- private static final ObjectStreamField[] oldSerialPersistentFields =
- {
- new ObjectStreamField("attrDescriptor", Descriptor.class),
- new ObjectStreamField("currClass", String.class)
- };
- //
- // Serializable fields in new serial form
- private static final ObjectStreamField[] newSerialPersistentFields =
- {
- new ObjectStreamField("attrDescriptor", Descriptor.class)
- };
- //
- // Actual serial version and serial form
- private static final long serialVersionUID;
- /**
- * @serialField attrDescriptor Descriptor The {@link Descriptor}
- * containing the metadata corresponding to this attribute
- */
- private static final ObjectStreamField[] serialPersistentFields;
- private static boolean compat = false;
- static {
- try {
- GetPropertyAction act = new GetPropertyAction("jmx.serial.form");
- @SuppressWarnings("removal")
- String form = AccessController.doPrivileged(act);
- compat = (form != null && form.equals("1.0"));
- } catch (Exception e) {
- // OK: No compat with 1.0
- }
- if (compat) {
- serialPersistentFields = oldSerialPersistentFields;
- serialVersionUID = oldSerialVersionUID;
- } else {
- serialPersistentFields = newSerialPersistentFields;
- serialVersionUID = newSerialVersionUID;
- }
- }
- //
- // END Serialization compatibility stuff
+ private static final long serialVersionUID = 6181543027787327345L;
+ /**
+ * @serialField attrDescriptor Descriptor The {@link Descriptor}
+ * containing the metadata corresponding to this attribute
+ */
+ private static final ObjectStreamField[] serialPersistentFields =
+ {
+ new ObjectStreamField("attrDescriptor", Descriptor.class)
+ };
/**
* @serial The {@link Descriptor} containing the metadata corresponding to
@@ -508,21 +464,7 @@ private void readObject(ObjectInputStream in)
*/
private void writeObject(ObjectOutputStream out)
throws IOException {
- if (compat)
- {
- // Serializes this instance in the old serial form
- //
- ObjectOutputStream.PutField fields = out.putFields();
- fields.put("attrDescriptor", attrDescriptor);
- fields.put("currClass", currClass);
- out.writeFields();
- }
- else
- {
- // Serializes this instance in the new serial form
- //
- out.defaultWriteObject();
- }
+ out.defaultWriteObject();
}
}
diff --git a/src/java.management/share/classes/javax/management/modelmbean/ModelMBeanConstructorInfo.java b/src/java.management/share/classes/javax/management/modelmbean/ModelMBeanConstructorInfo.java
index 3b5863007a683..0b8413083ac01 100644
--- a/src/java.management/share/classes/javax/management/modelmbean/ModelMBeanConstructorInfo.java
+++ b/src/java.management/share/classes/javax/management/modelmbean/ModelMBeanConstructorInfo.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2000, 2021, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2024, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -89,63 +89,18 @@
*
* @since 1.5
*/
-
-@SuppressWarnings("serial") // serialVersionUID is not constant
public class ModelMBeanConstructorInfo
extends MBeanConstructorInfo
implements DescriptorAccess {
- // Serialization compatibility stuff:
- // Two serial forms are supported in this class. The selected form depends
- // on system property "jmx.serial.form":
- // - "1.0" for JMX 1.0
- // - any other value for JMX 1.1 and higher
- //
- // Serial version for old serial form
- private static final long oldSerialVersionUID = -4440125391095574518L;
- //
- // Serial version for new serial form
- private static final long newSerialVersionUID = 3862947819818064362L;
- //
- // Serializable fields in old serial form
- private static final ObjectStreamField[] oldSerialPersistentFields =
- {
- new ObjectStreamField("consDescriptor", Descriptor.class),
- new ObjectStreamField("currClass", String.class)
- };
- //
- // Serializable fields in new serial form
- private static final ObjectStreamField[] newSerialPersistentFields =
- {
- new ObjectStreamField("consDescriptor", Descriptor.class)
- };
- //
- // Actual serial version and serial form
- private static final long serialVersionUID;
- /**
- * @serialField consDescriptor Descriptor The {@link Descriptor} containing the metadata for this instance
- */
- private static final ObjectStreamField[] serialPersistentFields;
- private static boolean compat = false;
- static {
- try {
- GetPropertyAction act = new GetPropertyAction("jmx.serial.form");
- @SuppressWarnings("removal")
- String form = AccessController.doPrivileged(act);
- compat = (form != null && form.equals("1.0"));
- } catch (Exception e) {
- // OK: No compat with 1.0
- }
- if (compat) {
- serialPersistentFields = oldSerialPersistentFields;
- serialVersionUID = oldSerialVersionUID;
- } else {
- serialPersistentFields = newSerialPersistentFields;
- serialVersionUID = newSerialVersionUID;
- }
- }
- //
- // END Serialization compatibility stuff
+ private static final long serialVersionUID = 3862947819818064362L;
+ /**
+ * @serialField consDescriptor Descriptor The {@link Descriptor} containing the metadata for this instance
+ */
+ private static final ObjectStreamField[] serialPersistentFields =
+ {
+ new ObjectStreamField("consDescriptor", Descriptor.class)
+ };
/**
* @serial The {@link Descriptor} containing the metadata for this instance
@@ -464,21 +419,7 @@ private void readObject(ObjectInputStream in)
*/
private void writeObject(ObjectOutputStream out)
throws IOException {
- if (compat)
- {
- // Serializes this instance in the old serial form
- //
- ObjectOutputStream.PutField fields = out.putFields();
- fields.put("consDescriptor", consDescriptor);
- fields.put("currClass", currClass);
- out.writeFields();
- }
- else
- {
- // Serializes this instance in the new serial form
- //
- out.defaultWriteObject();
- }
+ out.defaultWriteObject();
}
}
diff --git a/src/java.management/share/classes/javax/management/modelmbean/ModelMBeanInfoSupport.java b/src/java.management/share/classes/javax/management/modelmbean/ModelMBeanInfoSupport.java
index bf164b678cc85..a209c2c7f420b 100644
--- a/src/java.management/share/classes/javax/management/modelmbean/ModelMBeanInfoSupport.java
+++ b/src/java.management/share/classes/javax/management/modelmbean/ModelMBeanInfoSupport.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2000, 2021, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2024, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -81,44 +81,9 @@
*
* @since 1.5
*/
-@SuppressWarnings("serial")
public class ModelMBeanInfoSupport extends MBeanInfo implements ModelMBeanInfo {
- // Serialization compatibility stuff:
- // Two serial forms are supported in this class. The selected form depends
- // on system property "jmx.serial.form":
- // - "1.0" for JMX 1.0
- // - any other value for JMX 1.1 and higher
- //
- // Serial version for old serial form
- private static final long oldSerialVersionUID = -3944083498453227709L;
- //
- // Serial version for new serial form
- private static final long newSerialVersionUID = -1935722590756516193L;
- //
- // Serializable fields in old serial form
- private static final ObjectStreamField[] oldSerialPersistentFields =
- {
- new ObjectStreamField("modelMBeanDescriptor", Descriptor.class),
- new ObjectStreamField("mmbAttributes", MBeanAttributeInfo[].class),
- new ObjectStreamField("mmbConstructors", MBeanConstructorInfo[].class),
- new ObjectStreamField("mmbNotifications", MBeanNotificationInfo[].class),
- new ObjectStreamField("mmbOperations", MBeanOperationInfo[].class),
- new ObjectStreamField("currClass", String.class)
- };
- //
- // Serializable fields in new serial form
- private static final ObjectStreamField[] newSerialPersistentFields =
- {
- new ObjectStreamField("modelMBeanDescriptor", Descriptor.class),
- new ObjectStreamField("modelMBeanAttributes", MBeanAttributeInfo[].class),
- new ObjectStreamField("modelMBeanConstructors", MBeanConstructorInfo[].class),
- new ObjectStreamField("modelMBeanNotifications", MBeanNotificationInfo[].class),
- new ObjectStreamField("modelMBeanOperations", MBeanOperationInfo[].class)
- };
- //
- // Actual serial version and serial form
- private static final long serialVersionUID;
+ private static final long serialVersionUID = -1935722590756516193L;
/**
* @serialField modelMBeanDescriptor Descriptor The descriptor containing
* MBean wide policy
@@ -135,27 +100,14 @@ public class ModelMBeanInfoSupport extends MBeanInfo implements ModelMBeanInfo {
* {@link ModelMBeanOperationInfo} objects which
* have descriptors
*/
- private static final ObjectStreamField[] serialPersistentFields;
- private static boolean compat = false;
- static {
- try {
- GetPropertyAction act = new GetPropertyAction("jmx.serial.form");
- @SuppressWarnings("removal")
- String form = AccessController.doPrivileged(act);
- compat = (form != null && form.equals("1.0"));
- } catch (Exception e) {
- // OK: No compat with 1.0
- }
- if (compat) {
- serialPersistentFields = oldSerialPersistentFields;
- serialVersionUID = oldSerialVersionUID;
- } else {
- serialPersistentFields = newSerialPersistentFields;
- serialVersionUID = newSerialVersionUID;
- }
- }
- //
- // END Serialization compatibility stuff
+ private static final ObjectStreamField[] serialPersistentFields =
+ {
+ new ObjectStreamField("modelMBeanDescriptor", Descriptor.class),
+ new ObjectStreamField("modelMBeanAttributes", MBeanAttributeInfo[].class),
+ new ObjectStreamField("modelMBeanConstructors", MBeanConstructorInfo[].class),
+ new ObjectStreamField("modelMBeanNotifications", MBeanNotificationInfo[].class),
+ new ObjectStreamField("modelMBeanOperations", MBeanOperationInfo[].class)
+ };
/**
* @serial The descriptor containing MBean wide policy
@@ -957,40 +909,8 @@ private Descriptor validDescriptor(final Descriptor in) throws RuntimeOperations
*/
private void readObject(ObjectInputStream in)
throws IOException, ClassNotFoundException {
- if (compat) {
- // Read an object serialized in the old serial form
- //
- ObjectInputStream.GetField fields = in.readFields();
- modelMBeanDescriptor =
- (Descriptor) fields.get("modelMBeanDescriptor", null);
- if (fields.defaulted("modelMBeanDescriptor")) {
- throw new NullPointerException("modelMBeanDescriptor");
- }
- modelMBeanAttributes =
- (MBeanAttributeInfo[]) fields.get("mmbAttributes", null);
- if (fields.defaulted("mmbAttributes")) {
- throw new NullPointerException("mmbAttributes");
- }
- modelMBeanConstructors =
- (MBeanConstructorInfo[]) fields.get("mmbConstructors", null);
- if (fields.defaulted("mmbConstructors")) {
- throw new NullPointerException("mmbConstructors");
- }
- modelMBeanNotifications =
- (MBeanNotificationInfo[]) fields.get("mmbNotifications", null);
- if (fields.defaulted("mmbNotifications")) {
- throw new NullPointerException("mmbNotifications");
- }
- modelMBeanOperations =
- (MBeanOperationInfo[]) fields.get("mmbOperations", null);
- if (fields.defaulted("mmbOperations")) {
- throw new NullPointerException("mmbOperations");
- }
- } else {
- // Read an object serialized in the new serial form
- //
- in.defaultReadObject();
- }
+
+ in.defaultReadObject();
}
@@ -999,22 +919,7 @@ private void readObject(ObjectInputStream in)
*/
private void writeObject(ObjectOutputStream out)
throws IOException {
- if (compat) {
- // Serializes this instance in the old serial form
- //
- ObjectOutputStream.PutField fields = out.putFields();
- fields.put("modelMBeanDescriptor", modelMBeanDescriptor);
- fields.put("mmbAttributes", modelMBeanAttributes);
- fields.put("mmbConstructors", modelMBeanConstructors);
- fields.put("mmbNotifications", modelMBeanNotifications);
- fields.put("mmbOperations", modelMBeanOperations);
- fields.put("currClass", currClass);
- out.writeFields();
- } else {
- // Serializes this instance in the new serial form
- //
- out.defaultWriteObject();
- }
+ out.defaultWriteObject();
}
diff --git a/src/java.management/share/classes/javax/management/modelmbean/ModelMBeanNotificationInfo.java b/src/java.management/share/classes/javax/management/modelmbean/ModelMBeanNotificationInfo.java
index 1f6cf566ba396..c0bce84a5d925 100644
--- a/src/java.management/share/classes/javax/management/modelmbean/ModelMBeanNotificationInfo.java
+++ b/src/java.management/share/classes/javax/management/modelmbean/ModelMBeanNotificationInfo.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2000, 2021, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2024, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -96,64 +96,19 @@
*
* @since 1.5
*/
-
-@SuppressWarnings("serial") // serialVersionUID is not constant
public class ModelMBeanNotificationInfo
extends MBeanNotificationInfo
implements DescriptorAccess {
- // Serialization compatibility stuff:
- // Two serial forms are supported in this class. The selected form
- // depends on system property "jmx.serial.form":
- // - "1.0" for JMX 1.0
- // - any other value for JMX 1.1 and higher
- //
- // Serial version for old serial form
- private static final long oldSerialVersionUID = -5211564525059047097L;
- //
- // Serial version for new serial form
- private static final long newSerialVersionUID = -7445681389570207141L;
- //
- // Serializable fields in old serial form
- private static final ObjectStreamField[] oldSerialPersistentFields =
- {
- new ObjectStreamField("notificationDescriptor", Descriptor.class),
- new ObjectStreamField("currClass", String.class)
- };
- //
- // Serializable fields in new serial form
- private static final ObjectStreamField[] newSerialPersistentFields =
- {
- new ObjectStreamField("notificationDescriptor", Descriptor.class)
- };
- //
- // Actual serial version and serial form
- private static final long serialVersionUID;
+ private static final long serialVersionUID = -7445681389570207141L;
/**
* @serialField notificationDescriptor Descriptor The descriptor
* containing the appropriate metadata for this instance
*/
- private static final ObjectStreamField[] serialPersistentFields;
- private static boolean compat = false;
- static {
- try {
- GetPropertyAction act = new GetPropertyAction("jmx.serial.form");
- @SuppressWarnings("removal")
- String form = AccessController.doPrivileged(act);
- compat = (form != null && form.equals("1.0"));
- } catch (Exception e) {
- // OK: No compat with 1.0
- }
- if (compat) {
- serialPersistentFields = oldSerialPersistentFields;
- serialVersionUID = oldSerialVersionUID;
- } else {
- serialPersistentFields = newSerialPersistentFields;
- serialVersionUID = newSerialVersionUID;
- }
- }
- //
- // END Serialization compatibility stuff
+ private static final ObjectStreamField[] serialPersistentFields =
+ {
+ new ObjectStreamField("notificationDescriptor", Descriptor.class)
+ };
/**
* @serial The descriptor containing the appropriate metadata for
@@ -398,18 +353,7 @@ private void readObject(ObjectInputStream in)
**/
private void writeObject(ObjectOutputStream out)
throws IOException {
- if (compat) {
- // Serializes this instance in the old serial form
- //
- ObjectOutputStream.PutField fields = out.putFields();
- fields.put("notificationDescriptor", notificationDescriptor);
- fields.put("currClass", currClass);
- out.writeFields();
- } else {
- // Serializes this instance in the new serial form
- //
- out.defaultWriteObject();
- }
+ out.defaultWriteObject();
}
}
diff --git a/src/java.management/share/classes/javax/management/modelmbean/ModelMBeanOperationInfo.java b/src/java.management/share/classes/javax/management/modelmbean/ModelMBeanOperationInfo.java
index 5550be20d6f3c..1d22b41b1e8ee 100644
--- a/src/java.management/share/classes/javax/management/modelmbean/ModelMBeanOperationInfo.java
+++ b/src/java.management/share/classes/javax/management/modelmbean/ModelMBeanOperationInfo.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2000, 2021, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2024, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -108,64 +108,19 @@
*
* @since 1.5
*/
-
-@SuppressWarnings("serial") // serialVersionUID is not constant
public class ModelMBeanOperationInfo extends MBeanOperationInfo
implements DescriptorAccess
{
- // Serialization compatibility stuff:
- // Two serial forms are supported in this class. The selected form depends
- // on system property "jmx.serial.form":
- // - "1.0" for JMX 1.0
- // - any other value for JMX 1.1 and higher
- //
- // Serial version for old serial form
- private static final long oldSerialVersionUID = 9087646304346171239L;
- //
- // Serial version for new serial form
- private static final long newSerialVersionUID = 6532732096650090465L;
- //
- // Serializable fields in old serial form
- private static final ObjectStreamField[] oldSerialPersistentFields =
- {
- new ObjectStreamField("operationDescriptor", Descriptor.class),
- new ObjectStreamField("currClass", String.class)
- };
- //
- // Serializable fields in new serial form
- private static final ObjectStreamField[] newSerialPersistentFields =
- {
- new ObjectStreamField("operationDescriptor", Descriptor.class)
- };
- //
- // Actual serial version and serial form
- private static final long serialVersionUID;
- /**
- * @serialField operationDescriptor Descriptor The descriptor
- * containing the appropriate metadata for this instance
- */
- private static final ObjectStreamField[] serialPersistentFields;
- private static boolean compat = false;
- static {
- try {
- GetPropertyAction act = new GetPropertyAction("jmx.serial.form");
- @SuppressWarnings("removal")
- String form = AccessController.doPrivileged(act);
- compat = (form != null && form.equals("1.0"));
- } catch (Exception e) {
- // OK: No compat with 1.0
- }
- if (compat) {
- serialPersistentFields = oldSerialPersistentFields;
- serialVersionUID = oldSerialVersionUID;
- } else {
- serialPersistentFields = newSerialPersistentFields;
- serialVersionUID = newSerialVersionUID;
- }
- }
- //
- // END Serialization compatibility stuff
+ private static final long serialVersionUID = 6532732096650090465L;
+ /**
+ * @serialField operationDescriptor Descriptor The descriptor
+ * containing the appropriate metadata for this instance
+ */
+ private static final ObjectStreamField[] serialPersistentFields =
+ {
+ new ObjectStreamField("operationDescriptor", Descriptor.class)
+ };
/**
* @serial The descriptor containing the appropriate metadata for this instance
@@ -515,21 +470,7 @@ private void readObject(ObjectInputStream in)
*/
private void writeObject(ObjectOutputStream out)
throws IOException {
- if (compat)
- {
- // Serializes this instance in the old serial form
- //
- ObjectOutputStream.PutField fields = out.putFields();
- fields.put("operationDescriptor", operationDescriptor);
- fields.put("currClass", currClass);
- out.writeFields();
- }
- else
- {
- // Serializes this instance in the new serial form
- //
out.defaultWriteObject();
- }
}
}
diff --git a/src/java.management/share/classes/javax/management/modelmbean/XMLParseException.java b/src/java.management/share/classes/javax/management/modelmbean/XMLParseException.java
index 2be6f37bf3bcf..daa1abf039efc 100644
--- a/src/java.management/share/classes/javax/management/modelmbean/XMLParseException.java
+++ b/src/java.management/share/classes/javax/management/modelmbean/XMLParseException.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2000, 2021, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2024, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -49,54 +49,10 @@
*
* @since 1.5
*/
-@SuppressWarnings("serial") // serialVersionUID not constant
public class XMLParseException
extends Exception
{
- // Serialization compatibility stuff:
- // Two serial forms are supported in this class. The selected form depends
- // on system property "jmx.serial.form":
- // - "1.0" for JMX 1.0
- // - any other value for JMX 1.1 and higher
- //
- // Serial version for old serial form
- private static final long oldSerialVersionUID = -7780049316655891976L;
- //
- // Serial version for new serial form
- private static final long newSerialVersionUID = 3176664577895105181L;
- //
- // Serializable fields in old serial form
- private static final ObjectStreamField[] oldSerialPersistentFields =
- {
- new ObjectStreamField("msgStr", String.class)
- };
- //
- // Serializable fields in new serial form
- private static final ObjectStreamField[] newSerialPersistentFields = { };
- //
- // Actual serial version and serial form
- private static final long serialVersionUID;
- private static final ObjectStreamField[] serialPersistentFields;
- private static boolean compat = false;
- static {
- try {
- GetPropertyAction act = new GetPropertyAction("jmx.serial.form");
- @SuppressWarnings("removal")
- String form = AccessController.doPrivileged(act);
- compat = (form != null && form.equals("1.0"));
- } catch (Exception e) {
- // OK: No compat with 1.0
- }
- if (compat) {
- serialPersistentFields = oldSerialPersistentFields;
- serialVersionUID = oldSerialVersionUID;
- } else {
- serialPersistentFields = newSerialPersistentFields;
- serialVersionUID = newSerialVersionUID;
- }
- }
- //
- // END Serialization compatibility stuff
+ private static final long serialVersionUID = 3176664577895105181L;
/**
* Default constructor .
@@ -141,19 +97,6 @@ private void readObject(ObjectInputStream in)
*/
private void writeObject(ObjectOutputStream out)
throws IOException {
- if (compat)
- {
- // Serializes this instance in the old serial form
- //
- ObjectOutputStream.PutField fields = out.putFields();
- fields.put("msgStr", getMessage());
- out.writeFields();
- }
- else
- {
- // Serializes this instance in the new serial form
- //
- out.defaultWriteObject();
- }
+ out.defaultWriteObject();
}
}
diff --git a/src/java.management/share/classes/javax/management/relation/MBeanServerNotificationFilter.java b/src/java.management/share/classes/javax/management/relation/MBeanServerNotificationFilter.java
index d02d15cb1e5f5..7579e416e36d0 100644
--- a/src/java.management/share/classes/javax/management/relation/MBeanServerNotificationFilter.java
+++ b/src/java.management/share/classes/javax/management/relation/MBeanServerNotificationFilter.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2000, 2022, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2024, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -57,37 +57,9 @@
*
* @since 1.5
*/
-@SuppressWarnings("serial") // serialVersionUID must be constant
public class MBeanServerNotificationFilter extends NotificationFilterSupport {
- // Serialization compatibility stuff:
- // Two serial forms are supported in this class. The selected form depends
- // on system property "jmx.serial.form":
- // - "1.0" for JMX 1.0
- // - any other value for JMX 1.1 and higher
- //
- // Serial version for old serial form
- private static final long oldSerialVersionUID = 6001782699077323605L;
- //
- // Serial version for new serial form
- private static final long newSerialVersionUID = 2605900539589789736L;
- //
- // Serializable fields in old serial form
- private static final ObjectStreamField[] oldSerialPersistentFields =
- {
- new ObjectStreamField("mySelectObjNameList", Vector.class),
- new ObjectStreamField("myDeselectObjNameList", Vector.class)
- };
- //
- // Serializable fields in new serial form
- private static final ObjectStreamField[] newSerialPersistentFields =
- {
- new ObjectStreamField("selectedNames", List.class),
- new ObjectStreamField("deselectedNames", List.class)
- };
- //
- // Actual serial version and serial form
- private static final long serialVersionUID;
+ private static final long serialVersionUID = 2605900539589789736L;
/**
* @serialField selectedNames List List of {@link ObjectName}s of interest
*
@@ -102,27 +74,11 @@ public class MBeanServerNotificationFilter extends NotificationFilterSupport {
* - Empty vector means that no {@link ObjectName} is explicitly deselected
*
*/
- private static final ObjectStreamField[] serialPersistentFields;
- private static boolean compat = false;
- static {
- try {
- GetPropertyAction act = new GetPropertyAction("jmx.serial.form");
- @SuppressWarnings("removal")
- String form = AccessController.doPrivileged(act);
- compat = (form != null && form.equals("1.0"));
- } catch (Exception e) {
- // OK : Too bad, no compat with 1.0
- }
- if (compat) {
- serialPersistentFields = oldSerialPersistentFields;
- serialVersionUID = oldSerialVersionUID;
- } else {
- serialPersistentFields = newSerialPersistentFields;
- serialVersionUID = newSerialVersionUID;
- }
- }
- //
- // END Serialization compatibility stuff
+ private static final ObjectStreamField[] serialPersistentFields =
+ {
+ new ObjectStreamField("selectedNames", List.class),
+ new ObjectStreamField("deselectedNames", List.class)
+ };
//
// Private members
@@ -405,28 +361,7 @@ public synchronized boolean isNotificationEnabled(Notification notif)
*/
private void readObject(ObjectInputStream in)
throws IOException, ClassNotFoundException {
- if (compat)
- {
- // Read an object serialized in the old serial form
- //
- ObjectInputStream.GetField fields = in.readFields();
- selectedNames = cast(fields.get("mySelectObjNameList", null));
- if (fields.defaulted("mySelectObjNameList"))
- {
- throw new NullPointerException("mySelectObjNameList");
- }
- deselectedNames = cast(fields.get("myDeselectObjNameList", null));
- if (fields.defaulted("myDeselectObjNameList"))
- {
- throw new NullPointerException("myDeselectObjNameList");
- }
- }
- else
- {
- // Read an object serialized in the new serial form
- //
- in.defaultReadObject();
- }
+ in.defaultReadObject();
}
@@ -435,20 +370,6 @@ private void readObject(ObjectInputStream in)
*/
private void writeObject(ObjectOutputStream out)
throws IOException {
- if (compat)
- {
- // Serializes this instance in the old serial form
- //
- ObjectOutputStream.PutField fields = out.putFields();
- fields.put("mySelectObjNameList", selectedNames);
- fields.put("myDeselectObjNameList", deselectedNames);
- out.writeFields();
- }
- else
- {
- // Serializes this instance in the new serial form
- //
- out.defaultWriteObject();
- }
+ out.defaultWriteObject();
}
}
diff --git a/src/java.management/share/classes/javax/management/relation/RelationNotification.java b/src/java.management/share/classes/javax/management/relation/RelationNotification.java
index 11c2fab163e06..16d660bc07fb8 100644
--- a/src/java.management/share/classes/javax/management/relation/RelationNotification.java
+++ b/src/java.management/share/classes/javax/management/relation/RelationNotification.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2000, 2022, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2024, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -57,47 +57,9 @@
*
* @since 1.5
*/
-@SuppressWarnings("serial") // serialVersionUID not constant
public class RelationNotification extends Notification {
- // Serialization compatibility stuff:
- // Two serial forms are supported in this class. The selected form depends
- // on system property "jmx.serial.form":
- // - "1.0" for JMX 1.0
- // - any other value for JMX 1.1 and higher
- //
- // Serial version for old serial form
- private static final long oldSerialVersionUID = -2126464566505527147L;
- //
- // Serial version for new serial form
- private static final long newSerialVersionUID = -6871117877523310399L;
- //
- // Serializable fields in old serial form
- private static final ObjectStreamField[] oldSerialPersistentFields =
- {
- new ObjectStreamField("myNewRoleValue", ArrayList.class),
- new ObjectStreamField("myOldRoleValue", ArrayList.class),
- new ObjectStreamField("myRelId", String.class),
- new ObjectStreamField("myRelObjName", ObjectName.class),
- new ObjectStreamField("myRelTypeName", String.class),
- new ObjectStreamField("myRoleName", String.class),
- new ObjectStreamField("myUnregMBeanList", ArrayList.class)
- };
- //
- // Serializable fields in new serial form
- private static final ObjectStreamField[] newSerialPersistentFields =
- {
- new ObjectStreamField("newRoleValue", List.class),
- new ObjectStreamField("oldRoleValue", List.class),
- new ObjectStreamField("relationId", String.class),
- new ObjectStreamField("relationObjName", ObjectName.class),
- new ObjectStreamField("relationTypeName", String.class),
- new ObjectStreamField("roleName", String.class),
- new ObjectStreamField("unregisterMBeanList", List.class)
- };
- //
- // Actual serial version and serial form
- private static final long serialVersionUID;
+ private static final long serialVersionUID = -6871117877523310399L;
/**
* @serialField relationId String Relation identifier of
* created/removed/updated relation
@@ -115,27 +77,16 @@ public class RelationNotification extends Notification {
* @serialField newRoleValue List New role value ({@link
* ArrayList} of {@link ObjectName}s) (only for role update)
*/
- private static final ObjectStreamField[] serialPersistentFields;
- private static boolean compat = false;
- static {
- try {
- GetPropertyAction act = new GetPropertyAction("jmx.serial.form");
- @SuppressWarnings("removal")
- String form = AccessController.doPrivileged(act);
- compat = (form != null && form.equals("1.0"));
- } catch (Exception e) {
- // OK : Too bad, no compat with 1.0
- }
- if (compat) {
- serialPersistentFields = oldSerialPersistentFields;
- serialVersionUID = oldSerialVersionUID;
- } else {
- serialPersistentFields = newSerialPersistentFields;
- serialVersionUID = newSerialVersionUID;
- }
- }
- //
- // END Serialization compatibility stuff
+ private static final ObjectStreamField[] serialPersistentFields =
+ {
+ new ObjectStreamField("newRoleValue", List.class),
+ new ObjectStreamField("oldRoleValue", List.class),
+ new ObjectStreamField("relationId", String.class),
+ new ObjectStreamField("relationObjName", ObjectName.class),
+ new ObjectStreamField("relationTypeName", String.class),
+ new ObjectStreamField("roleName", String.class),
+ new ObjectStreamField("unregisterMBeanList", List.class)
+ };
//
// Notification types
@@ -541,26 +492,14 @@ private void readObject(ObjectInputStream in)
ObjectInputStream.GetField fields = in.readFields();
- if (compat) {
- tmpRelationId = (String)fields.get("myRelId", null);
- tmpRelationTypeName = (String)fields.get("myRelTypeName", null);
- tmpRoleName = (String)fields.get("myRoleName", null);
+ tmpRelationId = (String)fields.get("relationId", null);
+ tmpRelationTypeName = (String)fields.get("relationTypeName", null);
+ tmpRoleName = (String)fields.get("roleName", null);
- tmpRelationObjName = (ObjectName)fields.get("myRelObjName", null);
- tmpNewRoleValue = cast(fields.get("myNewRoleValue", null));
- tmpOldRoleValue = cast(fields.get("myOldRoleValue", null));
- tmpUnregMBeanList = cast(fields.get("myUnregMBeanList", null));
- }
- else {
- tmpRelationId = (String)fields.get("relationId", null);
- tmpRelationTypeName = (String)fields.get("relationTypeName", null);
- tmpRoleName = (String)fields.get("roleName", null);
-
- tmpRelationObjName = (ObjectName)fields.get("relationObjName", null);
- tmpNewRoleValue = cast(fields.get("newRoleValue", null));
- tmpOldRoleValue = cast(fields.get("oldRoleValue", null));
- tmpUnregMBeanList = cast(fields.get("unregisterMBeanList", null));
- }
+ tmpRelationObjName = (ObjectName)fields.get("relationObjName", null);
+ tmpNewRoleValue = cast(fields.get("newRoleValue", null));
+ tmpOldRoleValue = cast(fields.get("oldRoleValue", null));
+ tmpUnregMBeanList = cast(fields.get("unregisterMBeanList", null));
// Validate fields we just read, throw InvalidObjectException
// if something goes wrong
@@ -591,25 +530,6 @@ private void readObject(ObjectInputStream in)
*/
private void writeObject(ObjectOutputStream out)
throws IOException {
- if (compat)
- {
- // Serializes this instance in the old serial form
- //
- ObjectOutputStream.PutField fields = out.putFields();
- fields.put("myNewRoleValue", newRoleValue);
- fields.put("myOldRoleValue", oldRoleValue);
- fields.put("myRelId", relationId);
- fields.put("myRelObjName", relationObjName);
- fields.put("myRelTypeName", relationTypeName);
- fields.put("myRoleName",roleName);
- fields.put("myUnregMBeanList", unregisterMBeanList);
- out.writeFields();
- }
- else
- {
- // Serializes this instance in the new serial form
- //
- out.defaultWriteObject();
- }
+ out.defaultWriteObject();
}
}
diff --git a/src/java.management/share/classes/javax/management/relation/RelationTypeSupport.java b/src/java.management/share/classes/javax/management/relation/RelationTypeSupport.java
index 5038fed2cfe59..766c42ca78079 100644
--- a/src/java.management/share/classes/javax/management/relation/RelationTypeSupport.java
+++ b/src/java.management/share/classes/javax/management/relation/RelationTypeSupport.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2000, 2022, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2024, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -63,39 +63,9 @@
*
* @since 1.5
*/
-@SuppressWarnings("serial") // serialVersionUID not constant
public class RelationTypeSupport implements RelationType {
- // Serialization compatibility stuff:
- // Two serial forms are supported in this class. The selected form depends
- // on system property "jmx.serial.form":
- // - "1.0" for JMX 1.0
- // - any other value for JMX 1.1 and higher
- //
- // Serial version for old serial form
- private static final long oldSerialVersionUID = -8179019472410837190L;
- //
- // Serial version for new serial form
- private static final long newSerialVersionUID = 4611072955724144607L;
- //
- // Serializable fields in old serial form
- private static final ObjectStreamField[] oldSerialPersistentFields =
- {
- new ObjectStreamField("myTypeName", String.class),
- new ObjectStreamField("myRoleName2InfoMap", HashMap.class),
- new ObjectStreamField("myIsInRelServFlg", boolean.class)
- };
- //
- // Serializable fields in new serial form
- private static final ObjectStreamField[] newSerialPersistentFields =
- {
- new ObjectStreamField("typeName", String.class),
- new ObjectStreamField("roleName2InfoMap", Map.class),
- new ObjectStreamField("isInRelationService", boolean.class)
- };
- //
- // Actual serial version and serial form
- private static final long serialVersionUID;
+ private static final long serialVersionUID = 4611072955724144607L;
/**
* @serialField typeName String Relation type name
* @serialField roleName2InfoMap Map {@link Map} holding the mapping:
@@ -103,27 +73,12 @@ public class RelationTypeSupport implements RelationType {
* @serialField isInRelationService boolean Flag specifying whether the relation type has been declared in the
* Relation Service (so can no longer be updated)
*/
- private static final ObjectStreamField[] serialPersistentFields;
- private static boolean compat = false;
- static {
- try {
- GetPropertyAction act = new GetPropertyAction("jmx.serial.form");
- @SuppressWarnings("removal")
- String form = AccessController.doPrivileged(act);
- compat = (form != null && form.equals("1.0"));
- } catch (Exception e) {
- // OK : Too bad, no compat with 1.0
- }
- if (compat) {
- serialPersistentFields = oldSerialPersistentFields;
- serialVersionUID = oldSerialVersionUID;
- } else {
- serialPersistentFields = newSerialPersistentFields;
- serialVersionUID = newSerialVersionUID;
- }
- }
- //
- // END Serialization compatibility stuff
+ private static final ObjectStreamField[] serialPersistentFields =
+ {
+ new ObjectStreamField("typeName", String.class),
+ new ObjectStreamField("roleName2InfoMap", Map.class),
+ new ObjectStreamField("isInRelationService", boolean.class)
+ };
//
// Private members
@@ -421,33 +376,7 @@ static void checkRoleInfos(RoleInfo[] roleInfoArray)
*/
private void readObject(ObjectInputStream in)
throws IOException, ClassNotFoundException {
- if (compat)
- {
- // Read an object serialized in the old serial form
- //
- ObjectInputStream.GetField fields = in.readFields();
- typeName = (String) fields.get("myTypeName", null);
- if (fields.defaulted("myTypeName"))
- {
- throw new NullPointerException("myTypeName");
- }
- roleName2InfoMap = cast(fields.get("myRoleName2InfoMap", null));
- if (fields.defaulted("myRoleName2InfoMap"))
- {
- throw new NullPointerException("myRoleName2InfoMap");
- }
- isInRelationService = fields.get("myIsInRelServFlg", false);
- if (fields.defaulted("myIsInRelServFlg"))
- {
- throw new NullPointerException("myIsInRelServFlg");
- }
- }
- else
- {
- // Read an object serialized in the new serial form
- //
- in.defaultReadObject();
- }
+ in.defaultReadObject();
}
@@ -456,21 +385,6 @@ private void readObject(ObjectInputStream in)
*/
private void writeObject(ObjectOutputStream out)
throws IOException {
- if (compat)
- {
- // Serializes this instance in the old serial form
- //
- ObjectOutputStream.PutField fields = out.putFields();
- fields.put("myTypeName", typeName);
- fields.put("myRoleName2InfoMap", roleName2InfoMap);
- fields.put("myIsInRelServFlg", isInRelationService);
- out.writeFields();
- }
- else
- {
- // Serializes this instance in the new serial form
- //
- out.defaultWriteObject();
- }
+ out.defaultWriteObject();
}
}
diff --git a/src/java.management/share/classes/javax/management/relation/Role.java b/src/java.management/share/classes/javax/management/relation/Role.java
index 60accb2e00720..431092a3b4876 100644
--- a/src/java.management/share/classes/javax/management/relation/Role.java
+++ b/src/java.management/share/classes/javax/management/relation/Role.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2000, 2022, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2024, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -51,62 +51,18 @@
*
* @since 1.5
*/
-@SuppressWarnings("serial") // serialVersionUID not constant
public class Role implements Serializable {
- // Serialization compatibility stuff:
- // Two serial forms are supported in this class. The selected form depends
- // on system property "jmx.serial.form":
- // - "1.0" for JMX 1.0
- // - any other value for JMX 1.1 and higher
- //
- // Serial version for old serial form
- private static final long oldSerialVersionUID = -1959486389343113026L;
- //
- // Serial version for new serial form
- private static final long newSerialVersionUID = -279985518429862552L;
- //
- // Serializable fields in old serial form
- private static final ObjectStreamField[] oldSerialPersistentFields =
- {
- new ObjectStreamField("myName", String.class),
- new ObjectStreamField("myObjNameList", ArrayList.class)
- };
- //
- // Serializable fields in new serial form
- private static final ObjectStreamField[] newSerialPersistentFields =
- {
- new ObjectStreamField("name", String.class),
- new ObjectStreamField("objectNameList", List.class)
- };
- //
- // Actual serial version and serial form
- private static final long serialVersionUID;
+ private static final long serialVersionUID = -279985518429862552L;
/**
* @serialField name String Role name
* @serialField objectNameList List {@link List} of {@link ObjectName}s of referenced MBeans
*/
- private static final ObjectStreamField[] serialPersistentFields;
- private static boolean compat = false;
- static {
- try {
- GetPropertyAction act = new GetPropertyAction("jmx.serial.form");
- @SuppressWarnings("removal")
- String form = AccessController.doPrivileged(act);
- compat = (form != null && form.equals("1.0"));
- } catch (Exception e) {
- // OK : Too bad, no compat with 1.0
- }
- if (compat) {
- serialPersistentFields = oldSerialPersistentFields;
- serialVersionUID = oldSerialVersionUID;
- } else {
- serialPersistentFields = newSerialPersistentFields;
- serialVersionUID = newSerialVersionUID;
- }
- }
- //
- // END Serialization compatibility stuff
+ private static final ObjectStreamField[] serialPersistentFields =
+ {
+ new ObjectStreamField("name", String.class),
+ new ObjectStreamField("objectNameList", List.class)
+ };
//
// Private members
@@ -290,28 +246,7 @@ public static String roleValueToString(List roleValue)
*/
private void readObject(ObjectInputStream in)
throws IOException, ClassNotFoundException {
- if (compat)
- {
- // Read an object serialized in the old serial form
- //
- ObjectInputStream.GetField fields = in.readFields();
- name = (String) fields.get("myName", null);
- if (fields.defaulted("myName"))
- {
- throw new NullPointerException("myName");
- }
- objectNameList = cast(fields.get("myObjNameList", null));
- if (fields.defaulted("myObjNameList"))
- {
- throw new NullPointerException("myObjNameList");
- }
- }
- else
- {
- // Read an object serialized in the new serial form
- //
- in.defaultReadObject();
- }
+ in.defaultReadObject();
}
@@ -320,20 +255,6 @@ private void readObject(ObjectInputStream in)
*/
private void writeObject(ObjectOutputStream out)
throws IOException {
- if (compat)
- {
- // Serializes this instance in the old serial form
- //
- ObjectOutputStream.PutField fields = out.putFields();
- fields.put("myName", name);
- fields.put("myObjNameList", objectNameList);
- out.writeFields();
- }
- else
- {
- // Serializes this instance in the new serial form
- //
- out.defaultWriteObject();
- }
+ out.defaultWriteObject();
}
}
diff --git a/src/java.management/share/classes/javax/management/relation/RoleInfo.java b/src/java.management/share/classes/javax/management/relation/RoleInfo.java
index 23258ce8c72d0..6f2926005e965 100644
--- a/src/java.management/share/classes/javax/management/relation/RoleInfo.java
+++ b/src/java.management/share/classes/javax/management/relation/RoleInfo.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2000, 2021, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2024, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -46,47 +46,9 @@
*
* @since 1.5
*/
-@SuppressWarnings("serial") // serialVersionUID not constant
public class RoleInfo implements Serializable {
- // Serialization compatibility stuff:
- // Two serial forms are supported in this class. The selected form depends
- // on system property "jmx.serial.form":
- // - "1.0" for JMX 1.0
- // - any other value for JMX 1.1 and higher
- //
- // Serial version for old serial form
- private static final long oldSerialVersionUID = 7227256952085334351L;
- //
- // Serial version for new serial form
- private static final long newSerialVersionUID = 2504952983494636987L;
- //
- // Serializable fields in old serial form
- private static final ObjectStreamField[] oldSerialPersistentFields =
- {
- new ObjectStreamField("myName", String.class),
- new ObjectStreamField("myIsReadableFlg", boolean.class),
- new ObjectStreamField("myIsWritableFlg", boolean.class),
- new ObjectStreamField("myDescription", String.class),
- new ObjectStreamField("myMinDegree", int.class),
- new ObjectStreamField("myMaxDegree", int.class),
- new ObjectStreamField("myRefMBeanClassName", String.class)
- };
- //
- // Serializable fields in new serial form
- private static final ObjectStreamField[] newSerialPersistentFields =
- {
- new ObjectStreamField("name", String.class),
- new ObjectStreamField("isReadable", boolean.class),
- new ObjectStreamField("isWritable", boolean.class),
- new ObjectStreamField("description", String.class),
- new ObjectStreamField("minDegree", int.class),
- new ObjectStreamField("maxDegree", int.class),
- new ObjectStreamField("referencedMBeanClassName", String.class)
- };
- //
- // Actual serial version and serial form
- private static final long serialVersionUID;
+ private static final long serialVersionUID = 2504952983494636987L;
/**
* @serialField name String Role name
* @serialField isReadable boolean Read access mode: {@code true} if role is readable
@@ -96,27 +58,16 @@ public class RoleInfo implements Serializable {
* @serialField maxDegree int Maximum degree (i.e. maximum number of referenced MBeans in corresponding role)
* @serialField referencedMBeanClassName String Name of class of MBean(s) expected to be referenced in corresponding role
*/
- private static final ObjectStreamField[] serialPersistentFields;
- private static boolean compat = false;
- static {
- try {
- GetPropertyAction act = new GetPropertyAction("jmx.serial.form");
- @SuppressWarnings("removal")
- String form = AccessController.doPrivileged(act);
- compat = (form != null && form.equals("1.0"));
- } catch (Exception e) {
- // OK : Too bad, no compat with 1.0
- }
- if (compat) {
- serialPersistentFields = oldSerialPersistentFields;
- serialVersionUID = oldSerialVersionUID;
- } else {
- serialPersistentFields = newSerialPersistentFields;
- serialVersionUID = newSerialVersionUID;
- }
- }
- //
- // END Serialization compatibility stuff
+ private static final ObjectStreamField[] serialPersistentFields =
+ {
+ new ObjectStreamField("name", String.class),
+ new ObjectStreamField("isReadable", boolean.class),
+ new ObjectStreamField("isWritable", boolean.class),
+ new ObjectStreamField("description", String.class),
+ new ObjectStreamField("minDegree", int.class),
+ new ObjectStreamField("maxDegree", int.class),
+ new ObjectStreamField("referencedMBeanClassName", String.class)
+ };
//
// Public constants
@@ -530,53 +481,7 @@ private void init(String roleName,
*/
private void readObject(ObjectInputStream in)
throws IOException, ClassNotFoundException {
- if (compat)
- {
- // Read an object serialized in the old serial form
- //
- ObjectInputStream.GetField fields = in.readFields();
- name = (String) fields.get("myName", null);
- if (fields.defaulted("myName"))
- {
- throw new NullPointerException("myName");
- }
- isReadable = fields.get("myIsReadableFlg", false);
- if (fields.defaulted("myIsReadableFlg"))
- {
- throw new NullPointerException("myIsReadableFlg");
- }
- isWritable = fields.get("myIsWritableFlg", false);
- if (fields.defaulted("myIsWritableFlg"))
- {
- throw new NullPointerException("myIsWritableFlg");
- }
- description = (String) fields.get("myDescription", null);
- if (fields.defaulted("myDescription"))
- {
- throw new NullPointerException("myDescription");
- }
- minDegree = fields.get("myMinDegree", 0);
- if (fields.defaulted("myMinDegree"))
- {
- throw new NullPointerException("myMinDegree");
- }
- maxDegree = fields.get("myMaxDegree", 0);
- if (fields.defaulted("myMaxDegree"))
- {
- throw new NullPointerException("myMaxDegree");
- }
- referencedMBeanClassName = (String) fields.get("myRefMBeanClassName", null);
- if (fields.defaulted("myRefMBeanClassName"))
- {
- throw new NullPointerException("myRefMBeanClassName");
- }
- }
- else
- {
- // Read an object serialized in the new serial form
- //
- in.defaultReadObject();
- }
+ in.defaultReadObject();
}
@@ -585,26 +490,7 @@ private void readObject(ObjectInputStream in)
*/
private void writeObject(ObjectOutputStream out)
throws IOException {
- if (compat)
- {
- // Serializes this instance in the old serial form
- //
- ObjectOutputStream.PutField fields = out.putFields();
- fields.put("myName", name);
- fields.put("myIsReadableFlg", isReadable);
- fields.put("myIsWritableFlg", isWritable);
- fields.put("myDescription", description);
- fields.put("myMinDegree", minDegree);
- fields.put("myMaxDegree", maxDegree);
- fields.put("myRefMBeanClassName", referencedMBeanClassName);
- out.writeFields();
- }
- else
- {
- // Serializes this instance in the new serial form
- //
- out.defaultWriteObject();
- }
+ out.defaultWriteObject();
}
}
diff --git a/src/java.management/share/classes/javax/management/relation/RoleResult.java b/src/java.management/share/classes/javax/management/relation/RoleResult.java
index 60836c897e595..7f98a7f7a243b 100644
--- a/src/java.management/share/classes/javax/management/relation/RoleResult.java
+++ b/src/java.management/share/classes/javax/management/relation/RoleResult.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2000, 2021, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2024, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -44,62 +44,18 @@
*
* @since 1.5
*/
-@SuppressWarnings("serial")
public class RoleResult implements Serializable {
- // Serialization compatibility stuff:
- // Two serial forms are supported in this class. The selected form depends
- // on system property "jmx.serial.form":
- // - "1.0" for JMX 1.0
- // - any other value for JMX 1.1 and higher
- //
- // Serial version for old serial form
- private static final long oldSerialVersionUID = 3786616013762091099L;
- //
- // Serial version for new serial form
- private static final long newSerialVersionUID = -6304063118040985512L;
- //
- // Serializable fields in old serial form
- private static final ObjectStreamField[] oldSerialPersistentFields =
- {
- new ObjectStreamField("myRoleList", RoleList.class),
- new ObjectStreamField("myRoleUnresList", RoleUnresolvedList.class)
- };
- //
- // Serializable fields in new serial form
- private static final ObjectStreamField[] newSerialPersistentFields =
- {
- new ObjectStreamField("roleList", RoleList.class),
- new ObjectStreamField("unresolvedRoleList", RoleUnresolvedList.class)
- };
- //
- // Actual serial version and serial form
- private static final long serialVersionUID;
+ private static final long serialVersionUID = -6304063118040985512L;
/**
* @serialField roleList RoleList List of roles successfully accessed
* @serialField unresolvedRoleList RoleUnresolvedList List of roles unsuccessfully accessed
*/
- private static final ObjectStreamField[] serialPersistentFields;
- private static boolean compat = false;
- static {
- try {
- GetPropertyAction act = new GetPropertyAction("jmx.serial.form");
- @SuppressWarnings("removal")
- String form = AccessController.doPrivileged(act);
- compat = (form != null && form.equals("1.0"));
- } catch (Exception e) {
- // OK : Too bad, no compat with 1.0
- }
- if (compat) {
- serialPersistentFields = oldSerialPersistentFields;
- serialVersionUID = oldSerialVersionUID;
- } else {
- serialPersistentFields = newSerialPersistentFields;
- serialVersionUID = newSerialVersionUID;
- }
- }
- //
- // END Serialization compatibility stuff
+ private static final ObjectStreamField[] serialPersistentFields =
+ {
+ new ObjectStreamField("roleList", RoleList.class),
+ new ObjectStreamField("unresolvedRoleList", RoleUnresolvedList.class)
+ };
//
// Private members
@@ -206,28 +162,7 @@ public void setRolesUnresolved(RoleUnresolvedList unresolvedList) {
*/
private void readObject(ObjectInputStream in)
throws IOException, ClassNotFoundException {
- if (compat)
- {
- // Read an object serialized in the old serial form
- //
- ObjectInputStream.GetField fields = in.readFields();
- roleList = (RoleList) fields.get("myRoleList", null);
- if (fields.defaulted("myRoleList"))
- {
- throw new NullPointerException("myRoleList");
- }
- unresolvedRoleList = (RoleUnresolvedList) fields.get("myRoleUnresList", null);
- if (fields.defaulted("myRoleUnresList"))
- {
- throw new NullPointerException("myRoleUnresList");
- }
- }
- else
- {
- // Read an object serialized in the new serial form
- //
- in.defaultReadObject();
- }
+ in.defaultReadObject();
}
@@ -236,20 +171,6 @@ private void readObject(ObjectInputStream in)
*/
private void writeObject(ObjectOutputStream out)
throws IOException {
- if (compat)
- {
- // Serializes this instance in the old serial form
- //
- ObjectOutputStream.PutField fields = out.putFields();
- fields.put("myRoleList", roleList);
- fields.put("myRoleUnresList", unresolvedRoleList);
- out.writeFields();
- }
- else
- {
- // Serializes this instance in the new serial form
- //
- out.defaultWriteObject();
- }
+ out.defaultWriteObject();
}
}
diff --git a/src/java.management/share/classes/javax/management/relation/RoleUnresolved.java b/src/java.management/share/classes/javax/management/relation/RoleUnresolved.java
index 169b1263fdb53..36b6dff9d71c6 100644
--- a/src/java.management/share/classes/javax/management/relation/RoleUnresolved.java
+++ b/src/java.management/share/classes/javax/management/relation/RoleUnresolved.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2000, 2022, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2024, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -52,64 +52,19 @@
*
* @since 1.5
*/
-@SuppressWarnings("serial") // serialVersionUID not constant
public class RoleUnresolved implements Serializable {
- // Serialization compatibility stuff:
- // Two serial forms are supported in this class. The selected form depends
- // on system property "jmx.serial.form":
- // - "1.0" for JMX 1.0
- // - any other value for JMX 1.1 and higher
- //
- // Serial version for old serial form
- private static final long oldSerialVersionUID = -9026457686611660144L;
- //
- // Serial version for new serial form
- private static final long newSerialVersionUID = -48350262537070138L;
- //
- // Serializable fields in old serial form
- private static final ObjectStreamField[] oldSerialPersistentFields =
- {
- new ObjectStreamField("myRoleName", String.class),
- new ObjectStreamField("myRoleValue", ArrayList.class),
- new ObjectStreamField("myPbType", int.class)
- };
- //
- // Serializable fields in new serial form
- private static final ObjectStreamField[] newSerialPersistentFields =
+ private static final long serialVersionUID = -48350262537070138L;
+ /** @serialField roleName String Role name
+ * @serialField roleValue List Role value ({@link List} of {@link ObjectName} objects)
+ * @serialField problemType int Problem type
+ */
+ private static final ObjectStreamField[] serialPersistentFields =
{
new ObjectStreamField("roleName", String.class),
new ObjectStreamField("roleValue", List.class),
new ObjectStreamField("problemType", int.class)
};
- //
- // Actual serial version and serial form
- private static final long serialVersionUID;
- /** @serialField roleName String Role name
- * @serialField roleValue List Role value ({@link List} of {@link ObjectName} objects)
- * @serialField problemType int Problem type
- */
- private static final ObjectStreamField[] serialPersistentFields;
- private static boolean compat = false;
- static {
- try {
- GetPropertyAction act = new GetPropertyAction("jmx.serial.form");
- @SuppressWarnings("removal")
- String form = AccessController.doPrivileged(act);
- compat = (form != null && form.equals("1.0"));
- } catch (Exception e) {
- // OK : Too bad, no compat with 1.0
- }
- if (compat) {
- serialPersistentFields = oldSerialPersistentFields;
- serialVersionUID = oldSerialVersionUID;
- } else {
- serialPersistentFields = newSerialPersistentFields;
- serialVersionUID = newSerialVersionUID;
- }
- }
- //
- // END Serialization compatibility stuff
//
// Private members
@@ -304,33 +259,7 @@ public String toString() {
*/
private void readObject(ObjectInputStream in)
throws IOException, ClassNotFoundException {
- if (compat)
- {
- // Read an object serialized in the old serial form
- //
- ObjectInputStream.GetField fields = in.readFields();
- roleName = (String) fields.get("myRoleName", null);
- if (fields.defaulted("myRoleName"))
- {
- throw new NullPointerException("myRoleName");
- }
- roleValue = cast(fields.get("myRoleValue", null));
- if (fields.defaulted("myRoleValue"))
- {
- throw new NullPointerException("myRoleValue");
- }
- problemType = fields.get("myPbType", 0);
- if (fields.defaulted("myPbType"))
- {
- throw new NullPointerException("myPbType");
- }
- }
- else
- {
- // Read an object serialized in the new serial form
- //
- in.defaultReadObject();
- }
+ in.defaultReadObject();
}
@@ -339,21 +268,6 @@ private void readObject(ObjectInputStream in)
*/
private void writeObject(ObjectOutputStream out)
throws IOException {
- if (compat)
- {
- // Serializes this instance in the old serial form
- //
- ObjectOutputStream.PutField fields = out.putFields();
- fields.put("myRoleName", roleName);
- fields.put("myRoleValue", roleValue);
- fields.put("myPbType", problemType);
- out.writeFields();
- }
- else
- {
- // Serializes this instance in the new serial form
- //
- out.defaultWriteObject();
- }
+ out.defaultWriteObject();
}
}
diff --git a/test/jdk/javax/management/ObjectName/SerialCompatRemovedTest.java b/test/jdk/javax/management/ObjectName/SerialCompatRemovedTest.java
new file mode 100644
index 0000000000000..3a63e5934722e
--- /dev/null
+++ b/test/jdk/javax/management/ObjectName/SerialCompatRemovedTest.java
@@ -0,0 +1,49 @@
+/*
+ * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8334165
+ * @summary Test that jmx.serial.form is not recognised.
+ *
+ * @run main/othervm -Djmx.serial.form=1.0 SerialCompatRemovedTest
+ * @run main/othervm SerialCompatRemovedTest
+ */
+
+import java.io.*;
+import java.util.*;
+import javax.management.ObjectName;
+
+public class SerialCompatRemovedTest {
+
+ public static void main(String[] args) throws Exception {
+ ObjectStreamClass osc = ObjectStreamClass.lookup(ObjectName.class);
+ // Serial form has no fields, uses writeObject, so we should never see
+ // non-zero field count here:
+ if (osc.getFields().length != 0) {
+ throw new Exception("ObjectName using old serial form?: fields: " +
+ Arrays.asList(osc.getFields()));
+ }
+ }
+}
+
diff --git a/test/jdk/javax/management/ObjectName/SerialCompatTest.java b/test/jdk/javax/management/ObjectName/SerialCompatTest.java
deleted file mode 100644
index 14b8720987bbd..0000000000000
--- a/test/jdk/javax/management/ObjectName/SerialCompatTest.java
+++ /dev/null
@@ -1,263 +0,0 @@
-/*
- * Copyright (c) 2004, 2015, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-/*
- * @test
- * @bug 6211220 6616825
- * @summary Test that jmx.serial.form=1.0 works for ObjectName
- * @author Eamonn McManus, Daniel Fuchs
- *
- * @run clean SerialCompatTest
- * @run build SerialCompatTest
- * @run main/othervm -Djdk.jmx.mbeans.allowNonPublic=true -Djmx.serial.form=1.0 SerialCompatTest
- */
-
-import java.io.*;
-import java.util.*;
-import javax.management.ObjectName;
-
-public class SerialCompatTest {
-
- public static void check6211220() throws Exception {
-
- ObjectName on = new ObjectName("a:b=c");
- ByteArrayOutputStream bos = new ByteArrayOutputStream();
- ObjectOutputStream oos = new ObjectOutputStream(bos);
- oos.writeObject(on);
- oos.close();
- byte[] bytes = bos.toByteArray();
- ByteArrayInputStream bis = new ByteArrayInputStream(bytes);
- ObjectInputStream ois = new ObjectInputStream(bis);
- ObjectName on1 = (ObjectName) ois.readObject();
-
- // if the bug is present, these will get NullPointerException
- for (int i = 0; i <= 11; i++) {
- String msg = "6211220 case(" + i + ")";
- try {
- switch (i) {
- case 0:
- check(msg, on1.getDomain().equals("a"));
- break;
- case 1:
- check(msg, on1.getCanonicalName().equals("a:b=c"));
- break;
- case 2:
- check(msg, on1.getKeyPropertyListString()
- .equals("b=c"));
- break;
- case 3:
- check(msg, on1.getCanonicalKeyPropertyListString()
- .equals("b=c"));
- break;
- case 4:
- check(msg, on1.getKeyProperty("b").equals("c"));
- break;
- case 5:
- check(msg, on1.getKeyPropertyList()
- .equals(Collections.singletonMap("b", "c")));
- break;
- case 6:
- check(msg, !on1.isDomainPattern());
- break;
- case 7:
- check(msg, !on1.isPattern());
- break;
- case 8:
- check(msg, !on1.isPropertyPattern());
- break;
- case 9:
- check(msg, on1.equals(on));
- break;
- case 10:
- check(msg, on.equals(on1));
- break;
- case 11:
- check(msg, on1.apply(on));
- break;
- default:
- throw new Exception(msg + ": Test incorrect");
- }
- } catch (Exception e) {
- System.out.println(msg + ": Test failed with exception:");
- e.printStackTrace(System.out);
- failed = true;
- }
- }
-
- if (failed) {
- throw new Exception("Some tests for 6211220 failed");
- } else {
- System.out.println("All tests for 6211220 passed");
- }
- }
-
- static void checkName(String testname, ObjectName on)
- throws Exception {
- ByteArrayOutputStream bos = new ByteArrayOutputStream();
- ObjectOutputStream oos = new ObjectOutputStream(bos);
- oos.writeObject(on);
- oos.close();
- byte[] bytes = bos.toByteArray();
- ByteArrayInputStream bis = new ByteArrayInputStream(bytes);
- ObjectInputStream ois = new ObjectInputStream(bis);
- ObjectName on1 = (ObjectName) ois.readObject();
- // if the bug is present, these will get NullPointerException
- for (int i = 0; i <= 11; i++) {
- String msg = testname + " case(" + i + ")";
- try {
- switch (i) {
- case 0:
- check(msg, on1.getDomain().equals(on.getDomain()));
- break;
- case 1:
- check(msg, on1.getCanonicalName().
- equals(on.getCanonicalName()));
- break;
- case 2:
- check(msg, on1.getKeyPropertyListString().
- equals(on.getKeyPropertyListString()));
- break;
- case 3:
- check(msg, on1.getCanonicalKeyPropertyListString().
- equals(on.getCanonicalKeyPropertyListString()));
- break;
- case 4:
- for (Object ko : on1.getKeyPropertyList().keySet()) {
- final String key = (String) ko;
- check(msg, on1.getKeyProperty(key).
- equals(on.getKeyProperty(key)));
- }
- for (Object ko : on.getKeyPropertyList().keySet()) {
- final String key = (String) ko;
- check(msg, on1.getKeyProperty(key).
- equals(on.getKeyProperty(key)));
- }
- case 5:
- check(msg, on1.getKeyPropertyList()
- .equals(on.getKeyPropertyList()));
- break;
- case 6:
- check(msg, on1.isDomainPattern()==on.isDomainPattern());
- break;
- case 7:
- check(msg, on1.isPattern() == on.isPattern());
- break;
- case 8:
- check(msg,
- on1.isPropertyPattern()==on.isPropertyPattern());
- break;
- case 9:
- check(msg, on1.equals(on));
- break;
- case 10:
- check(msg, on.equals(on1));
- break;
- case 11:
- if (!on.isPattern()) {
- check(msg, on1.apply(on));
- }
- break;
- default:
- throw new Exception("Test incorrect: case: " + i);
- }
- } catch (Exception e) {
- System.out.println("Test (" + i + ") failed with exception:");
- e.printStackTrace(System.out);
- failed = true;
- }
- }
-
- }
- private static String[] names6616825 = {
- "a:b=c", "a:b=c,*", "*:*", ":*", ":b=c", ":b=c,*",
- "a:*,b=c", ":*", ":*,b=c", "*x?:k=\"x\\*z\"", "*x?:k=\"x\\*z\",*",
- "*x?:*,k=\"x\\*z\"", "*x?:k=\"x\\*z\",*,b=c"
- };
-
- static void check6616825() throws Exception {
- System.out.println("Testing 616825");
- for (String n : names6616825) {
- final ObjectName on;
- try {
- on = new ObjectName(n);
- } catch (Exception x) {
- failed = true;
- System.out.println("Unexpected failure for 6616825 [" + n +
- "]: " + x);
- x.printStackTrace(System.out);
- continue;
- }
- try {
- checkName("616825 " + n, on);
- } catch (Exception x) {
- failed = true;
- System.out.println("6616825 failed for [" + n + "]: " + x);
- x.printStackTrace(System.out);
- }
- }
-
- if (failed) {
- throw new Exception("Some tests for 6616825 failed");
- } else {
- System.out.println("All tests for 6616825 passed");
- }
- }
-
- public static void main(String[] args) throws Exception {
- /* Check that we really are in jmx.serial.form=1.0 mode.
- The property is frozen the first time the ObjectName class
- is referenced so checking that it is set to the correct
- value now is not enough. */
- ObjectStreamClass osc = ObjectStreamClass.lookup(ObjectName.class);
- if (osc.getFields().length != 6) {
- throw new Exception("Not using old serial form: fields: " +
- Arrays.asList(osc.getFields()));
- // new serial form has no fields, uses writeObject
- }
-
- try {
- check6211220();
- } catch (Exception x) {
- System.err.println(x.getMessage());
- }
- try {
- check6616825();
- } catch (Exception x) {
- System.err.println(x.getMessage());
- }
-
- if (failed) {
- throw new Exception("Some tests failed");
- } else {
- System.out.println("All tests passed");
- }
- }
-
- private static void check(String msg, boolean condition) {
- if (!condition) {
- new Throwable("Test failed " + msg).printStackTrace(System.out);
- failed = true;
- }
- }
- private static boolean failed;
-}