8334165: Remove serialVersionUID compatibility logic from JMX
Reviewed-by: dfuchs
This commit is contained in:
parent
315abdf8c8
commit
3c40afa59c
@ -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 @@ import com.sun.jmx.mbeanserver.GetPropertyAction;
|
||||
*
|
||||
* @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
|
||||
|
@ -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 @@ import java.util.Objects;
|
||||
*
|
||||
* @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];
|
||||
|
@ -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 @@ import com.sun.jmx.mbeanserver.GetPropertyAction;
|
||||
*
|
||||
* @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 @@ public class Notification extends EventObject {
|
||||
*/
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
@ -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 @@ import java.security.AccessController;
|
||||
*
|
||||
* @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
|
||||
*
|
||||
* <p>The <b>serialVersionUID</b> of this class is <code>-4679739485102359104L</code>.
|
||||
*/
|
||||
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 @@ class NumericValueExp extends QueryEval implements ValueExp {
|
||||
*/
|
||||
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 @@ class NumericValueExp extends QueryEval implements ValueExp {
|
||||
*/
|
||||
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
|
||||
|
@ -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 @@ import java.util.Map;
|
||||
* @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<ObjectName>, QueryExp {
|
||||
private static final int DOMAIN_PATTERN = 0x8000_0000;
|
||||
private static final int PROPLIST_PATTERN = 0x4000_0000;
|
||||
@ -294,57 +293,7 @@ public class ObjectName implements Comparable<ObjectName>, QueryExp {
|
||||
// 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 @@ public class ObjectName implements Comparable<ObjectName>, QueryExp {
|
||||
|
||||
/**
|
||||
* Deserializes an {@link ObjectName} from an {@link ObjectInputStream}.
|
||||
* @serialData <ul>
|
||||
* <li>In the current serial form (value of property
|
||||
* <code>jmx.serial.form</code> differs from
|
||||
* <code>1.0</code>): the string
|
||||
* "<domain>:<properties><wild>",
|
||||
* where: <ul>
|
||||
* <li><domain> represents the domain part
|
||||
* of the {@link ObjectName}</li>
|
||||
* <li><properties> represents the list of
|
||||
* properties, as returned by
|
||||
* {@link #getKeyPropertyListString}
|
||||
* <li><wild> is empty if not
|
||||
* <code>isPropertyPattern</code>, or
|
||||
* is the character "<code>*</code>" if
|
||||
* <code>isPropertyPattern</code>
|
||||
* and <properties> is empty, or
|
||||
* is "<code>,*</code>" if
|
||||
* <code>isPropertyPattern</code> and
|
||||
* <properties> is not empty.
|
||||
* </li>
|
||||
* </ul>
|
||||
* The intent is that this string could be supplied
|
||||
* to the {@link #ObjectName(String)} constructor to
|
||||
* produce an equivalent {@link ObjectName}.
|
||||
* </li>
|
||||
* <li>In the old serial form (value of property
|
||||
* <code>jmx.serial.form</code> is
|
||||
* <code>1.0</code>): <domain> <propertyList>
|
||||
* <propertyListString> <canonicalName>
|
||||
* <pattern> <propertyPattern>,
|
||||
* where: <ul>
|
||||
* <li><domain> represents the domain part
|
||||
* of the {@link ObjectName}</li>
|
||||
* <li><propertyList> is the
|
||||
* {@link Hashtable} that contains all the
|
||||
* pairs (key,value) for this
|
||||
* {@link ObjectName}</li>
|
||||
* <li><propertyListString> is the
|
||||
* {@link String} representation of the
|
||||
* list of properties in any order (not
|
||||
* mandatorily a canonical representation)
|
||||
* </li>
|
||||
* <li><canonicalName> is the
|
||||
* {@link String} containing this
|
||||
* {@link ObjectName}'s canonical name</li>
|
||||
* <li><pattern> is a boolean which is
|
||||
* <code>true</code> if this
|
||||
* {@link ObjectName} contains a pattern</li>
|
||||
* <li><propertyPattern> is a boolean which
|
||||
* is <code>true</code> if this
|
||||
* {@link ObjectName} contains a pattern in
|
||||
* the list of properties</li>
|
||||
* </ul>
|
||||
* </li>
|
||||
* @serialData The string "<domain>:<properties><wild>", where:
|
||||
* <ul>
|
||||
* <li><domain> represents the domain part
|
||||
* of the {@link ObjectName}</li>
|
||||
* <li><properties> represents the list of
|
||||
* properties, as returned by
|
||||
* {@link #getKeyPropertyListString}</li>
|
||||
* <li><wild> is empty if not
|
||||
* <code>isPropertyPattern</code>, or
|
||||
* is the character "<code>*</code>" if
|
||||
* <code>isPropertyPattern</code>
|
||||
* and <properties> is empty, or
|
||||
* is "<code>,*</code>" if
|
||||
* <code>isPropertyPattern</code> and
|
||||
* <properties> is not empty.</li>
|
||||
* </ul>
|
||||
* The intent is that this string could be supplied
|
||||
* to the {@link #ObjectName(String)} constructor to
|
||||
* produce an equivalent {@link ObjectName}.
|
||||
*/
|
||||
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 @@ public class ObjectName implements Comparable<ObjectName>, QueryExp {
|
||||
|
||||
/**
|
||||
* Serializes an {@link ObjectName} to an {@link ObjectOutputStream}.
|
||||
* @serialData <ul>
|
||||
* <li>In the current serial form (value of property
|
||||
* <code>jmx.serial.form</code> differs from
|
||||
* <code>1.0</code>): the string
|
||||
* "<domain>:<properties><wild>",
|
||||
* where: <ul>
|
||||
* <li><domain> represents the domain part
|
||||
* of the {@link ObjectName}</li>
|
||||
* <li><properties> represents the list of
|
||||
* properties, as returned by
|
||||
* {@link #getKeyPropertyListString}
|
||||
* <li><wild> is empty if not
|
||||
* <code>isPropertyPattern</code>, or
|
||||
* is the character "<code>*</code>" if
|
||||
* this <code>isPropertyPattern</code>
|
||||
* and <properties> is empty, or
|
||||
* is "<code>,*</code>" if
|
||||
* <code>isPropertyPattern</code> and
|
||||
* <properties> is not empty.
|
||||
* </li>
|
||||
* </ul>
|
||||
* The intent is that this string could be supplied
|
||||
* to the {@link #ObjectName(String)} constructor to
|
||||
* produce an equivalent {@link ObjectName}.
|
||||
* </li>
|
||||
* <li>In the old serial form (value of property
|
||||
* <code>jmx.serial.form</code> is
|
||||
* <code>1.0</code>): <domain> <propertyList>
|
||||
* <propertyListString> <canonicalName>
|
||||
* <pattern> <propertyPattern>,
|
||||
* where: <ul>
|
||||
* <li><domain> represents the domain part
|
||||
* of the {@link ObjectName}</li>
|
||||
* <li><propertyList> is the
|
||||
* {@link Hashtable} that contains all the
|
||||
* pairs (key,value) for this
|
||||
* {@link ObjectName}</li>
|
||||
* <li><propertyListString> is the
|
||||
* {@link String} representation of the
|
||||
* list of properties in any order (not
|
||||
* mandatorily a canonical representation)
|
||||
* </li>
|
||||
* <li><canonicalName> is the
|
||||
* {@link String} containing this
|
||||
* {@link ObjectName}'s canonical name</li>
|
||||
* <li><pattern> is a boolean which is
|
||||
* <code>true</code> if this
|
||||
* {@link ObjectName} contains a pattern</li>
|
||||
* <li><propertyPattern> is a boolean which
|
||||
* is <code>true</code> if this
|
||||
* {@link ObjectName} contains a pattern in
|
||||
* the list of properties</li>
|
||||
* </ul>
|
||||
* </li>
|
||||
* @serialData The string "<domain>:<properties><wild>", where:
|
||||
* <ul>
|
||||
* <li><domain> represents the domain part
|
||||
* of the {@link ObjectName}</li>
|
||||
* <li><properties> represents the list of
|
||||
* properties, as returned by
|
||||
* {@link #getKeyPropertyListString}</li>
|
||||
* <li><wild> is empty if not
|
||||
* <code>isPropertyPattern</code>, or
|
||||
* is the character "<code>*</code>" if
|
||||
* this <code>isPropertyPattern</code>
|
||||
* and <properties> is empty, or
|
||||
* is "<code>,*</code>" if
|
||||
* <code>isPropertyPattern</code> and
|
||||
* <properties> is not empty.</li>
|
||||
* </ul>
|
||||
* The intent is that this string could be supplied
|
||||
* to the {@link #ObjectName(String)} constructor to
|
||||
* produce an equivalent {@link ObjectName}.
|
||||
*/
|
||||
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 <===================================
|
||||
|
@ -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 @@ import sun.reflect.misc.ReflectUtil;
|
||||
*
|
||||
* @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 @@ public class DescriptorSupport
|
||||
/**
|
||||
* 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 @@ public class DescriptorSupport
|
||||
startMap.remove("targetObject");
|
||||
}
|
||||
|
||||
final HashMap<String, Object> descriptor;
|
||||
if (compat || "1.2.0".equals(serialForm) ||
|
||||
"1.2.1".equals(serialForm)) {
|
||||
descriptor = new HashMap<>();
|
||||
for (Map.Entry<String, Object> entry : startMap.entrySet())
|
||||
descriptor.put(entry.getKey().toLowerCase(), entry.getValue());
|
||||
} else
|
||||
descriptor = new HashMap<>(startMap);
|
||||
|
||||
final HashMap<String, Object> descriptor = new HashMap<>(startMap);
|
||||
fields.put("descriptor", descriptor);
|
||||
out.writeFields();
|
||||
}
|
||||
|
@ -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 @@ import java.security.AccessController;
|
||||
*
|
||||
* @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 class InvalidTargetObjectTypeException extends Exception
|
||||
*/
|
||||
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 @@ public class InvalidTargetObjectTypeException extends Exception
|
||||
*/
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
@ -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 @@ import javax.management.RuntimeOperationsException;
|
||||
* @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 @@ public class ModelMBeanAttributeInfo
|
||||
*/
|
||||
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();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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 @@ import javax.management.RuntimeOperationsException;
|
||||
*
|
||||
* @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 @@ public class ModelMBeanConstructorInfo
|
||||
*/
|
||||
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();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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 @@ import javax.management.RuntimeOperationsException;
|
||||
*
|
||||
* @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 @@ public class ModelMBeanInfoSupport extends MBeanInfo implements ModelMBeanInfo {
|
||||
*/
|
||||
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 @@ public class ModelMBeanInfoSupport extends MBeanInfo implements ModelMBeanInfo {
|
||||
*/
|
||||
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();
|
||||
}
|
||||
|
||||
|
||||
|
@ -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 @@ import javax.management.RuntimeOperationsException;
|
||||
*
|
||||
* @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 @@ public class ModelMBeanNotificationInfo
|
||||
**/
|
||||
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();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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 @@ import javax.management.RuntimeOperationsException;
|
||||
*
|
||||
* @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 @@ public class ModelMBeanOperationInfo extends MBeanOperationInfo
|
||||
*/
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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 @@ import java.security.AccessController;
|
||||
*
|
||||
* @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 @@ extends Exception
|
||||
*/
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
@ -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 @@ import java.lang.System.Logger.Level;
|
||||
*
|
||||
* @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
|
||||
* <ul>
|
||||
@ -102,27 +74,11 @@ public class MBeanServerNotificationFilter extends NotificationFilterSupport {
|
||||
* <li>Empty vector means that no {@link ObjectName} is explicitly deselected</li>
|
||||
* </ul>
|
||||
*/
|
||||
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 class MBeanServerNotificationFilter extends NotificationFilterSupport {
|
||||
*/
|
||||
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 @@ public class MBeanServerNotificationFilter extends NotificationFilterSupport {
|
||||
*/
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
@ -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 @@ import static com.sun.jmx.mbeanserver.Util.cast;
|
||||
*
|
||||
* @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 @@ public class RelationNotification extends Notification {
|
||||
|
||||
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 @@ public class RelationNotification extends Notification {
|
||||
*/
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
@ -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 @@ import java.lang.System.Logger.Level;
|
||||
*
|
||||
* @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 @@ public class RelationTypeSupport implements RelationType {
|
||||
*/
|
||||
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 @@ public class RelationTypeSupport implements RelationType {
|
||||
*/
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
@ -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 @@ import javax.management.ObjectName;
|
||||
*
|
||||
* @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 class Role implements Serializable {
|
||||
*/
|
||||
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 @@ public class Role implements Serializable {
|
||||
*/
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
@ -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 @@ import javax.management.NotCompliantMBeanException;
|
||||
*
|
||||
* @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 @@ public class RoleInfo implements Serializable {
|
||||
*/
|
||||
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 @@ public class RoleInfo implements Serializable {
|
||||
*/
|
||||
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();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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 @@ import java.security.AccessController;
|
||||
*
|
||||
* @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 class RoleResult implements Serializable {
|
||||
*/
|
||||
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 @@ public class RoleResult implements Serializable {
|
||||
*/
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
@ -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 @@ import javax.management.ObjectName;
|
||||
*
|
||||
* @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 class RoleUnresolved implements Serializable {
|
||||
*/
|
||||
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 @@ public class RoleUnresolved implements Serializable {
|
||||
*/
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
@ -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()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user