0N/A/*
2362N/A * Copyright (c) 2000, 2006, Oracle and/or its affiliates. All rights reserved.
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A *
0N/A * This code is free software; you can redistribute it and/or modify it
0N/A * under the terms of the GNU General Public License version 2 only, as
2362N/A * published by the Free Software Foundation. Oracle designates this
0N/A * particular file as subject to the "Classpath" exception as provided
2362N/A * by Oracle in the LICENSE file that accompanied this code.
0N/A *
0N/A * This code is distributed in the hope that it will be useful, but WITHOUT
0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A * version 2 for more details (a copy is included in the LICENSE file that
0N/A * accompanied this code).
0N/A *
0N/A * You should have received a copy of the GNU General Public License version
0N/A * 2 along with this work; if not, write to the Free Software Foundation,
0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A *
2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2362N/A * or visit www.oracle.com if you need additional information or have any
2362N/A * questions.
0N/A */
0N/A/*
0N/A * @author IBM Corp.
0N/A *
0N/A * Copyright IBM Corp. 1999-2000. All rights reserved.
0N/A */
0N/A
0N/A
0N/Apackage javax.management.modelmbean;
0N/A
0N/Aimport com.sun.jmx.mbeanserver.GetPropertyAction;
0N/A
0N/Aimport java.io.IOException;
0N/Aimport java.io.ObjectInputStream;
0N/Aimport java.io.ObjectOutputStream;
0N/Aimport java.io.ObjectStreamField;
0N/Aimport java.security.AccessController;
0N/A
0N/A/**
0N/A* This exception is thrown when an XML formatted string is being parsed into ModelMBean objects
0N/A* or when XML formatted strings are being created from ModelMBean objects.
0N/A*
0N/A* It is also used to wrapper exceptions from XML parsers that may be used.
0N/A*
0N/A* <p>The <b>serialVersionUID</b> of this class is <code>3176664577895105181L</code>.
0N/A*
0N/A* @since 1.5
0N/A*/
0N/A@SuppressWarnings("serial") // serialVersionUID not constant
0N/Apublic class XMLParseException
0N/Aextends Exception
0N/A{
0N/A // Serialization compatibility stuff:
0N/A // Two serial forms are supported in this class. The selected form depends
0N/A // on system property "jmx.serial.form":
0N/A // - "1.0" for JMX 1.0
0N/A // - any other value for JMX 1.1 and higher
0N/A //
0N/A // Serial version for old serial form
0N/A private static final long oldSerialVersionUID = -7780049316655891976L;
0N/A //
0N/A // Serial version for new serial form
0N/A private static final long newSerialVersionUID = 3176664577895105181L;
0N/A //
0N/A // Serializable fields in old serial form
0N/A private static final ObjectStreamField[] oldSerialPersistentFields =
0N/A {
0N/A new ObjectStreamField("msgStr", String.class)
0N/A };
0N/A //
0N/A // Serializable fields in new serial form
0N/A private static final ObjectStreamField[] newSerialPersistentFields = { };
0N/A //
0N/A // Actual serial version and serial form
0N/A private static final long serialVersionUID;
0N/A private static final ObjectStreamField[] serialPersistentFields;
0N/A private static boolean compat = false;
0N/A static {
0N/A try {
0N/A GetPropertyAction act = new GetPropertyAction("jmx.serial.form");
0N/A String form = AccessController.doPrivileged(act);
0N/A compat = (form != null && form.equals("1.0"));
0N/A } catch (Exception e) {
0N/A // OK: No compat with 1.0
0N/A }
0N/A if (compat) {
0N/A serialPersistentFields = oldSerialPersistentFields;
0N/A serialVersionUID = oldSerialVersionUID;
0N/A } else {
0N/A serialPersistentFields = newSerialPersistentFields;
0N/A serialVersionUID = newSerialVersionUID;
0N/A }
0N/A }
0N/A //
0N/A // END Serialization compatibility stuff
0N/A
0N/A /**
0N/A * Default constructor .
0N/A */
0N/A public XMLParseException ()
0N/A {
0N/A super("XML Parse Exception.");
0N/A }
0N/A
0N/A /**
0N/A * Constructor taking a string.
0N/A *
0N/A * @param s the detail message.
0N/A */
0N/A public XMLParseException (String s)
0N/A {
0N/A super("XML Parse Exception: " + s);
0N/A }
0N/A /**
0N/A * Constructor taking a string and an exception.
0N/A *
0N/A * @param e the nested exception.
0N/A * @param s the detail message.
0N/A */
0N/A public XMLParseException (Exception e, String s)
0N/A {
0N/A super("XML Parse Exception: " + s + ":" + e.toString());
0N/A }
0N/A
0N/A /**
0N/A * Deserializes an {@link XMLParseException} from an {@link ObjectInputStream}.
0N/A */
0N/A private void readObject(ObjectInputStream in)
0N/A throws IOException, ClassNotFoundException {
0N/A // New serial form ignores extra field "msgStr"
0N/A in.defaultReadObject();
0N/A }
0N/A
0N/A
0N/A /**
0N/A * Serializes an {@link XMLParseException} to an {@link ObjectOutputStream}.
0N/A */
0N/A private void writeObject(ObjectOutputStream out)
0N/A throws IOException {
0N/A if (compat)
0N/A {
0N/A // Serializes this instance in the old serial form
0N/A //
0N/A ObjectOutputStream.PutField fields = out.putFields();
0N/A fields.put("msgStr", getMessage());
0N/A out.writeFields();
0N/A }
0N/A else
0N/A {
0N/A // Serializes this instance in the new serial form
0N/A //
0N/A out.defaultWriteObject();
0N/A }
0N/A }
0N/A}