Skip to content

Commit 54fe643

Browse files
committed
8347433: Deprecate XML interchange in java.management/javax/management/modelmbean/DescriptorSupport for removal
Reviewed-by: sspitsyn, dfuchs
1 parent 155697f commit 54fe643

File tree

3 files changed

+26
-10
lines changed

3 files changed

+26
-10
lines changed

src/java.management/share/classes/javax/management/modelmbean/DescriptorSupport.java

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2000, 2024, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2000, 2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -201,12 +201,16 @@ public DescriptorSupport(DescriptorSupport inDescr) {
201201
* @exception XMLParseException XML parsing problem while parsing
202202
* the input String
203203
* @exception MBeanException Wraps a distributed communication Exception.
204+
* @deprecated This constructor exists for historical reasons. If
205+
* reading from XML is required, it should be implemented externally.
204206
*/
205207
/* At some stage we should rewrite this code to be cleverer. Using
206208
a StringTokenizer as we do means, first, that we accept a lot of
207209
bogus strings without noticing they are bogus, and second, that we
208210
split the string being parsed at characters like > even if they
209211
occur in the middle of a field value. */
212+
@Deprecated(since="25", forRemoval=true)
213+
@SuppressWarnings("removal")
210214
public DescriptorSupport(String inStr)
211215
throws MBeanException, RuntimeOperationsException,
212216
XMLParseException {
@@ -230,6 +234,7 @@ public DescriptorSupport(String inStr)
230234
if (!lowerInStr.startsWith("<descriptor>")
231235
|| !lowerInStr.endsWith("</descriptor>")) {
232236
throw new XMLParseException("No <descriptor>, </descriptor> pair");
237+
// XMLParseException is deprecated for removal.
233238
}
234239

235240
// parse xmlstring into structures
@@ -284,11 +289,13 @@ else if (kwPart.equalsIgnoreCase("VALUE"))
284289
final String msg =
285290
"Expected `name' or `value', got `" + tok + "'";
286291
throw new XMLParseException(msg);
292+
// XMLParseException is deprecated for removal.
287293
}
288294
} else { // xml parse exception
289295
final String msg =
290296
"Expected `keyword=value', got `" + tok + "'";
291297
throw new XMLParseException(msg);
298+
// XMLParseException is deprecated for removal.
292299
}
293300
}
294301
} // while tokens
@@ -967,7 +974,10 @@ private boolean validateField(String fldName, Object fldValue) {
967974
* field Names or field Values. If the XML formatted string
968975
* construction fails for any reason, this exception will be
969976
* thrown.
977+
* @deprecated This method exists for historical reasons. If
978+
* writing to XML is required, it should be implemented externally.
970979
*/
980+
@Deprecated(since="25", forRemoval=true)
971981
public synchronized String toXMLString() {
972982
final StringBuilder buf = new StringBuilder("<Descriptor>");
973983
Set<Map.Entry<String, Object>> returnedSet = descriptorMap.entrySet();
@@ -1057,9 +1067,12 @@ private static String quote(String s) {
10571067
return buf.toString();
10581068
}
10591069

1070+
@SuppressWarnings("removal")
10601071
private static String unquote(String s) throws XMLParseException {
1061-
if (!s.startsWith("\"") || !s.endsWith("\""))
1072+
if (!s.startsWith("\"") || !s.endsWith("\"")) {
10621073
throw new XMLParseException("Value must be quoted: <" + s + ">");
1074+
// XMLParseException is deprecated for removal.
1075+
}
10631076
final StringBuilder buf = new StringBuilder();
10641077
final int len = s.length() - 1;
10651078
for (int i = 1; i < len; i++) {
@@ -1120,6 +1133,7 @@ private static String makeFieldValue(Object value) {
11201133
* - some other string, in which case the result is that string,
11211134
* without the parentheses.
11221135
*/
1136+
@SuppressWarnings("removal")
11231137
private static Object parseQuotedFieldValue(String s)
11241138
throws XMLParseException {
11251139
s = unquote(s);
@@ -1142,8 +1156,8 @@ private static Object parseQuotedFieldValue(String s)
11421156
Class.forName(className, false, contextClassLoader);
11431157
constr = c.getConstructor(new Class<?>[] {String.class});
11441158
} catch (Exception e) {
1145-
throw new XMLParseException(e,
1146-
"Cannot parse value: <" + s + ">");
1159+
throw new XMLParseException(e, "Cannot parse value: <" + s + ">");
1160+
// XMLParseException is deprecated for removal.
11471161
}
11481162
final String arg = s.substring(slash + 1, s.length() - 1);
11491163
try {
@@ -1153,6 +1167,7 @@ private static Object parseQuotedFieldValue(String s)
11531167
"Cannot construct instance of " + className +
11541168
" with arg: <" + s + ">";
11551169
throw new XMLParseException(e, msg);
1170+
// XMLParseException is deprecated for removal.
11561171
}
11571172
}
11581173

src/java.management/share/classes/javax/management/modelmbean/RequiredModelMBean.java

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,7 @@
9191
* from MBeans, connectors/adaptors like other MBeans. Through the
9292
* Descriptors, values and methods in the managed application can be
9393
* defined and mapped to attributes and operations of the ModelMBean.
94-
* This mapping can be defined in an XML formatted file or dynamically and
95-
* programmatically at runtime.
94+
* This mapping can be defined dynamically and programmatically at runtime.
9695
* <P>
9796
* Every RequiredModelMBean which is instantiated in the MBeanServer
9897
* becomes manageable:<br>
@@ -129,7 +128,6 @@ public class RequiredModelMBean
129128
* and operations will be executed */
130129
private Object managedResource = null;
131130

132-
133131
/* records the registering in MBeanServer */
134132
private boolean registered = false;
135133
private transient MBeanServer server = null;
@@ -367,7 +365,7 @@ public void load()
367365
throw new MBeanException(x, x.getMessage());
368366
}
369367

370-
/**
368+
/**
371369
* <p>Captures the current state of this MBean instance and writes
372370
* it out to the persistent store. The state stored could include
373371
* attribute and operation values.</p>
@@ -651,7 +649,6 @@ private String printModelMBeanInfo(ModelMBeanInfo info) {
651649
retStr.append("\nCLASSNAME: \t").append(info.getClassName());
652650
retStr.append("\nDESCRIPTION: \t").append(info.getDescription());
653651

654-
655652
try {
656653
retStr.append("\nMBEAN DESCRIPTOR: \t").append(info.getMBeanDescriptor());
657654
} catch (Exception e) {

src/java.management/share/classes/javax/management/modelmbean/XMLParseException.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2000, 2024, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2000, 2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -44,8 +44,12 @@
4444
*
4545
* <p>The <b>serialVersionUID</b> of this class is <code>3176664577895105181L</code>.
4646
*
47+
* @deprecated This class exists only to support XML parsing implemented privately in this module,
48+
* in DescriptorSupport. That feature is deprecated for removal.
49+
*
4750
* @since 1.5
4851
*/
52+
@Deprecated(since="25", forRemoval=true)
4953
public class XMLParseException
5054
extends Exception
5155
{

0 commit comments

Comments
 (0)