diff --git a/src/java.management/share/classes/javax/management/modelmbean/DescriptorSupport.java b/src/java.management/share/classes/javax/management/modelmbean/DescriptorSupport.java index d003cd9d9d671..5015567adc920 100644 --- a/src/java.management/share/classes/javax/management/modelmbean/DescriptorSupport.java +++ b/src/java.management/share/classes/javax/management/modelmbean/DescriptorSupport.java @@ -174,137 +174,6 @@ public DescriptorSupport(DescriptorSupport inDescr) { init(inDescr.descriptorMap); } - - /** - *
Descriptor constructor taking an XML String.
- * - *The format of the XML string is not defined, but an - * implementation must ensure that the string returned by - * {@link #toXMLString() toXMLString()} on an existing - * descriptor can be used to instantiate an equivalent - * descriptor using this constructor.
- * - *In this implementation, all field values will be created - * as Strings. If the field values are not Strings, the - * programmer will have to reset or convert these fields - * correctly.
- * - * @param inStr An XML-formatted string used to populate this - * Descriptor. The format is not defined, but any - * implementation must ensure that the string returned by - * method {@link #toXMLString toXMLString} on an existing - * descriptor can be used to instantiate an equivalent - * descriptor when instantiated using this constructor. - * - * @exception RuntimeOperationsException If the String inStr - * passed in parameter is null - * @exception XMLParseException XML parsing problem while parsing - * the input String - * @exception MBeanException Wraps a distributed communication Exception. - * @deprecated This constructor exists for historical reasons. If - * reading from XML is required, it should be implemented externally. - */ - /* At some stage we should rewrite this code to be cleverer. Using - a StringTokenizer as we do means, first, that we accept a lot of - bogus strings without noticing they are bogus, and second, that we - split the string being parsed at characters like > even if they - occur in the middle of a field value. */ - @Deprecated(since="25", forRemoval=true) - @SuppressWarnings("removal") - public DescriptorSupport(String inStr) - throws MBeanException, RuntimeOperationsException, - XMLParseException { - /* parse an XML-formatted string and populate internal - * structure with it */ - if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) { - MODELMBEAN_LOGGER.log(Level.TRACE, - "Descriptor(String = '" + inStr + "') Constructor"); - } - if (inStr == null) { - if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) { - MODELMBEAN_LOGGER.log(Level.TRACE, - "Descriptor(String = null) Illegal arguments"); - } - final String msg = "String in parameter is null"; - final RuntimeException iae = new IllegalArgumentException(msg); - throw new RuntimeOperationsException(iae, msg); - } - - final String lowerInStr = inStr.toLowerCase(Locale.ENGLISH); - if (!lowerInStr.startsWith("Returns an XML String representing the descriptor.
- * - *The format is not defined, but an implementation must - * ensure that the string returned by this method can be - * used to build an equivalent descriptor when instantiated - * using the constructor {@link #DescriptorSupport(String) - * DescriptorSupport(String inStr)}.
- * - *Fields which are not String objects will have toString() - * called on them to create the value. The value will be - * enclosed in parentheses. It is not guaranteed that you can - * reconstruct these objects unless they have been - * specifically set up to support toString() in a meaningful - * format and have a matching constructor that accepts a - * String in the same format.
- * - *If the descriptor is empty the following String is - * returned: <Descriptor></Descriptor>
- * - * @return the XML string. - * - * @exception RuntimeOperationsException for illegal value for - * field Names or field Values. If the XML formatted string - * construction fails for any reason, this exception will be - * thrown. - * @deprecated This method exists for historical reasons. If - * writing to XML is required, it should be implemented externally. - */ - @Deprecated(since="25", forRemoval=true) - public synchronized String toXMLString() { - final StringBuilder buf = new StringBuilder("The serialVersionUID of this class is 3176664577895105181L
.
-*
-* @deprecated This class exists only to support XML parsing implemented privately in this module,
-* in DescriptorSupport. That feature is deprecated for removal.
-*
-* @since 1.5
-*/
-@Deprecated(since="25", forRemoval=true)
-public class XMLParseException
-extends Exception
-{
- private static final long serialVersionUID = 3176664577895105181L;
-
- /**
- * Default constructor .
- */
- public XMLParseException ()
- {
- super("XML Parse Exception.");
- }
-
- /**
- * Constructor taking a string.
- *
- * @param s the detail message.
- */
- public XMLParseException (String s)
- {
- super("XML Parse Exception: " + s);
- }
- /**
- * Constructor taking a string and an exception.
- *
- * @param e the nested exception.
- * @param s the detail message.
- */
- public XMLParseException (Exception e, String s)
- {
- super("XML Parse Exception: " + s + ":" + e.toString());
- }
-
- /**
- * Deserializes an {@link XMLParseException} from an {@link ObjectInputStream}.
- */
- private void readObject(ObjectInputStream in)
- throws IOException, ClassNotFoundException {
- // New serial form ignores extra field "msgStr"
- in.defaultReadObject();
- }
-
-
- /**
- * Serializes an {@link XMLParseException} to an {@link ObjectOutputStream}.
- */
- private void writeObject(ObjectOutputStream out)
- throws IOException {
- out.defaultWriteObject();
- }
-}
diff --git a/test/jdk/javax/management/MBeanServer/ExceptionFactory.java b/test/jdk/javax/management/MBeanServer/ExceptionFactory.java
index a615c5252da7a..dd82cf288f46c 100644
--- a/test/jdk/javax/management/MBeanServer/ExceptionFactory.java
+++ b/test/jdk/javax/management/MBeanServer/ExceptionFactory.java
@@ -46,7 +46,6 @@
import javax.management.ServiceNotFoundException;
import javax.management.StringValueExp;
import javax.management.modelmbean.InvalidTargetObjectTypeException;
-import javax.management.modelmbean.XMLParseException;
import javax.management.monitor.MonitorSettingException;
import javax.management.openmbean.InvalidKeyException;
import javax.management.openmbean.InvalidOpenTypeException;
@@ -100,7 +99,6 @@ public class ExceptionFactory {
exceptions.add(new RuntimeOperationsException(new RuntimeException(mes), mes));
exceptions.add(new ServiceNotFoundException());
exceptions.add(new InvalidTargetObjectTypeException());
- exceptions.add(new XMLParseException());
exceptions.add(new MonitorSettingException());
exceptions.add(new InvalidKeyException());
exceptions.add(new InvalidOpenTypeException());
diff --git a/test/jdk/javax/management/modelmbean/DescriptorSupportTest.java b/test/jdk/javax/management/modelmbean/DescriptorSupportTest.java
index ed33c737175ac..45c397f987e4d 100644
--- a/test/jdk/javax/management/modelmbean/DescriptorSupportTest.java
+++ b/test/jdk/javax/management/modelmbean/DescriptorSupportTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2025, 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
@@ -183,9 +183,6 @@ public static void main(String[] args) throws Exception {
ok &= caseTest(new DescriptorSupport(d1),
"DescriptorSupport(Descriptor)");
d1 = new DescriptorSupport(new String[] {"NAME=blah"});
- ok &= caseTest(new DescriptorSupport(d1.toXMLString()),
- "DescriptorSupport(String)");
- d1 = new DescriptorSupport(new String[] {"NAME=blah"});
ByteArrayOutputStream bos = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(bos);
oos.writeObject(d1);
diff --git a/test/jdk/javax/management/modelmbean/DescriptorSupportXMLTest.java b/test/jdk/javax/management/modelmbean/DescriptorSupportXMLTest.java
deleted file mode 100644
index dc66b2ad79456..0000000000000
--- a/test/jdk/javax/management/modelmbean/DescriptorSupportXMLTest.java
+++ /dev/null
@@ -1,176 +0,0 @@
-/*
- * Copyright (c) 2003, 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 4957393
- * @summary Test that DescriptorSupport.toXMLString() can be used to
- * reconstruct an equivalent DescriptorSupport
- * @author Eamonn McManus
- *
- * @run clean DescriptorSupportXMLTest
- * @run build DescriptorSupportXMLTest
- * @run main DescriptorSupportXMLTest
- */
-
-import java.util.Arrays;
-
-import javax.management.RuntimeOperationsException;
-import javax.management.modelmbean.DescriptorSupport;
-
-public class DescriptorSupportXMLTest {
- public static void main(String[] args) throws Exception {
- System.out.println("Testing that DescriptorSupport.toXMLString() " +
- "can be used to reconstruct an equivalent " +
- "DescriptorSupport");
- int failed = 0;
-
- final Object[] testValues = {
- // Values that should be encodable.
- "",
- "ok",
- "null",
- "(open",
- "close)",
- "(parens)",
- "quote\"quote",
- "a description with several words",
- "magic&\"\\<> \r\t\n\f;&;magic",
- "<descriptor>&&&</descriptor>",
- "<descriptor>&&&</blahblahblah>",
- null,
- new Integer(10),
- Boolean.TRUE,
- new Float(1.0f),
-
- // Values that are not encodable: it is important that we throw
- // an exception during encoding rather than waiting until decode
- // time to discover the problem. These classes are not encodable
- // because they don't have a (String) constructor.
- new Character('!'),
- new java.util.HashMap(),
- };
-
- for (int i = 0; i < testValues.length; i++) {
- final Object v = testValues[i];
- final String what =
- (v == null) ? "null" :
- (v.getClass().getName() + "{" + v + "}");
-
- final DescriptorSupport in =
- new DescriptorSupport(new String[] {"bloo"}, new Object[] {v});
-
- final String xml;
- try {
- xml = in.toXMLString();
- } catch (RuntimeOperationsException e) {
- final Throwable cause = e.getCause();
- if (cause instanceof IllegalArgumentException) {
- System.out.println("OK: " + what + ": got a " +
- "RuntimeOperationsException wrapping " +
- "an IllegalArgumentException: " +
- cause.getMessage());
- } else {
- final String causeString =
- (cause == null) ? "null" : cause.getClass().getName();
- System.out.println("FAILED: " + what + ": got a " +
- "RuntimeOperationException wrapping " +
- causeString);
- failed++;
- }
- continue;
- }
-
- System.out.println("Encoded " + what + " as " + xml);
-
- final DescriptorSupport out;
- try {
- out = new DescriptorSupport(xml);
- } catch (Exception e) {
- System.out.println("FAILED: " + what + ": got an exception:");
- e.printStackTrace(System.out);
- failed++;
- continue;
- }
-
- final String[] names = out.getFieldNames();
- if (names.length != 1 || !"bloo".equals(names[0])) {
- System.out.println("FAILED: decoded names wrong: " +
- Arrays.asList(names));
- failed++;
- continue;
- }
-
- final Object[] values = out.getFieldValues(names);
- if (values.length != 1) {
- System.out.println("FAILED: wrong number of values: " +
- Arrays.asList(values));
- failed++;
- continue;
- }
-
- final Object outValue = values[0];
-
- if (v == null) {
- if (outValue == null)
- System.out.println("OK: decoded null value");
- else {
- System.out.println("FAILED: decoded null value as " +
- outValue.getClass().getName() + "{" +
- outValue + "}");
- failed++;
- }
- continue;
- }
-
- if (outValue == null) {
- System.out.println("FAILED: decoded non-null value as null");
- failed++;
- continue;
- }
-
- if (v.getClass() != outValue.getClass()) {
- System.out.println("FAILED: decoded value has class " +
- outValue.getClass().getName() + "{" +
- outValue + "}");
- failed++;
- continue;
- }
-
- if (v.equals(outValue))
- System.out.println("OK: decoded value is equal to original");
- else {
- System.out.println("FAILED: decoded value is different: {" +
- outValue + "}");
- failed++;
- }
- }
-
- if (failed == 0)
- System.out.println("OK: all tests passed");
- else {
- System.out.println("TEST FAILED: fail count: " + failed);
- System.exit(1);
- }
- }
-}
diff --git a/test/jdk/javax/management/modelmbean/LoggingExceptionTest.java b/test/jdk/javax/management/modelmbean/LoggingExceptionTest.java
index 94dfee092eafd..c47e67b6afb3f 100644
--- a/test/jdk/javax/management/modelmbean/LoggingExceptionTest.java
+++ b/test/jdk/javax/management/modelmbean/LoggingExceptionTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2008, 2025, 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
@@ -47,7 +47,6 @@ public class LoggingExceptionTest {
private static final String tests[] = new String[] {
"DescriptorSupport()",
"DescriptorSupport(int)",
- "DescriptorSupport(String)",
"DescriptorSupport(String...)",
"DescriptorSupport(String[], Object[])",
"DescriptorSupport(DescriptorSupport)",
@@ -72,18 +71,15 @@ public static void main(String[] args) {
ds = new DescriptorSupport(10);
break;
case 2:
- ds = new DescriptorSupport(new DescriptorSupport().toXMLString());
- break;
- case 3:
ds = new DescriptorSupport("name1=value1", "name2=value2");
break;
- case 4:
+ case 3:
ds = new DescriptorSupport(new String[] {"name"}, new Object[] {"value"});
break;
- case 5:
+ case 4:
ds = new DescriptorSupport(new DescriptorSupport());
break;
- case 6:
+ case 5:
RequiredModelMBean mbean = new RequiredModelMBean();
NotificationListener nl = new NotificationListener() {
public void handleNotification(Notification notification,