History

My first initial commit with all of mine experimental changes.

Dmitry Kabak (userdima committed 13 years ago

Commit d37b88d1 parent 3f5b46618352 files · +2598093 −-8690Browse files

Showing the changes to java/pkg/javax/management/modelmbean/InvalidTargetObjectTypeException.java (1 of 18352 files). Show all

Unified · Split

java/pkg/javax/management/modelmbean/InvalidTargetObjectTypeException.java+199−0
@@ -0,0 +1,199 @@
1+/*
2+ * Copyright (c) 2000, 2006, Oracle and/or its affiliates. All rights reserved.
3+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+ *
5+ * This code is free software; you can redistribute it and/or modify it
6+ * under the terms of the GNU General Public License version 2 only, as
7+ * published by the Free Software Foundation. Oracle designates this
8+ * particular file as subject to the "Classpath" exception as provided
9+ * by Oracle in the LICENSE file that accompanied this code.
10+ *
11+ * This code is distributed in the hope that it will be useful, but WITHOUT
12+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14+ * version 2 for more details (a copy is included in the LICENSE file that
15+ * accompanied this code).
16+ *
17+ * You should have received a copy of the GNU General Public License version
18+ * 2 along with this work; if not, write to the Free Software Foundation,
19+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20+ *
21+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22+ * or visit www.oracle.com if you need additional information or have any
23+ * questions.
24+ */
25+/*
26+ * @author IBM Corp.
27+ *
28+ * Copyright IBM Corp. 1999-2000. All rights reserved.
29+ */
30+
31+package javax.management.modelmbean;
32+
33+import com.sun.jmx.mbeanserver.GetPropertyAction;
34+
35+import java.io.IOException;
36+import java.io.ObjectInputStream;
37+import java.io.ObjectOutputStream;
38+import java.io.ObjectStreamField;
39+import java.security.AccessController;
40+
41+/**
42+ * Exception thrown when an invalid target object type is specified.
43+ *
44+ *
45+ * <p>The <b>serialVersionUID</b> of this class is <code>1190536278266811217L</code>.
46+ *
47+ * @since 1.5
48+ */
49+@SuppressWarnings("serial") // serialVersionUID not constant
50+public class InvalidTargetObjectTypeException extends Exception
51+{
52+
53+ // Serialization compatibility stuff:
54+ // Two serial forms are supported in this class. The selected form depends
55+ // on system property "jmx.serial.form":
56+ // - "1.0" for JMX 1.0
57+ // - any other value for JMX 1.1 and higher
58+ //
59+ // Serial version for old serial form
60+ private static final long oldSerialVersionUID = 3711724570458346634L;
61+ //
62+ // Serial version for new serial form
63+ private static final long newSerialVersionUID = 1190536278266811217L;
64+ //
65+ // Serializable fields in old serial form
66+ private static final ObjectStreamField[] oldSerialPersistentFields =
67+ {
68+ new ObjectStreamField("msgStr", String.class),
69+ new ObjectStreamField("relatedExcept", Exception.class)
70+ };
71+ //
72+ // Serializable fields in new serial form
73+ private static final ObjectStreamField[] newSerialPersistentFields =
74+ {
75+ new ObjectStreamField("exception", Exception.class)
76+ };
77+ //
78+ // Actual serial version and serial form
79+ private static final long serialVersionUID;
80+ /**
81+ * @serialField exception Exception Encapsulated {@link Exception}
82+ */
83+ private static final ObjectStreamField[] serialPersistentFields;
84+ private static boolean compat = false;
85+ static {
86+ try {
87+ GetPropertyAction act = new GetPropertyAction("jmx.serial.form");
88+ String form = AccessController.doPrivileged(act);
89+ compat = (form != null && form.equals("1.0"));
90+ } catch (Exception e) {
91+ // OK: No compat with 1.0
92+ }
93+ if (compat) {
94+ serialPersistentFields = oldSerialPersistentFields;
95+ serialVersionUID = oldSerialVersionUID;
96+ } else {
97+ serialPersistentFields = newSerialPersistentFields;
98+ serialVersionUID = newSerialVersionUID;
99+ }
100+ }
101+ //
102+ // END Serialization compatibility stuff
103+
104+ /**
105+ * @serial Encapsulated {@link Exception}
106+ */
107+ Exception exception;
108+
109+
110+ /**
111+ * Default constructor.
112+ */
113+ public InvalidTargetObjectTypeException ()
114+ {
115+ super("InvalidTargetObjectTypeException: ");
116+ exception = null;
117+ }
118+
119+
120+ /**
121+ * Constructor from a string.
122+ *
123+ * @param s String value that will be incorporated in the message for
124+ * this exception.
125+ */
126+
127+ public InvalidTargetObjectTypeException (String s)
128+ {
129+ super("InvalidTargetObjectTypeException: " + s);
130+ exception = null;
131+ }
132+
133+
134+ /**
135+ * Constructor taking an exception and a string.
136+ *
137+ * @param e Exception that we may have caught to reissue as an
138+ * InvalidTargetObjectTypeException. The message will be used, and we may want to
139+ * consider overriding the printStackTrace() methods to get data
140+ * pointing back to original throw stack.
141+ * @param s String value that will be incorporated in message for
142+ * this exception.
143+ */
144+
145+ public InvalidTargetObjectTypeException (Exception e, String s)
146+ {
147+ super("InvalidTargetObjectTypeException: " +
148+ s +
149+ ((e != null)?("\n\t triggered by:" + e.toString()):""));
150+ exception = e;
151+ }
152+
153+ /**
154+ * Deserializes an {@link InvalidTargetObjectTypeException} from an {@link ObjectInputStream}.
155+ */
156+ private void readObject(ObjectInputStream in)
157+ throws IOException, ClassNotFoundException {
158+ if (compat)
159+ {
160+ // Read an object serialized in the old serial form
161+ //
162+ ObjectInputStream.GetField fields = in.readFields();
163+ exception = (Exception) fields.get("relatedExcept", null);
164+ if (fields.defaulted("relatedExcept"))
165+ {
166+ throw new NullPointerException("relatedExcept");
167+ }
168+ }
169+ else
170+ {
171+ // Read an object serialized in the new serial form
172+ //
173+ in.defaultReadObject();
174+ }
175+ }
176+
177+
178+ /**
179+ * Serializes an {@link InvalidTargetObjectTypeException} to an {@link ObjectOutputStream}.
180+ */
181+ private void writeObject(ObjectOutputStream out)
182+ throws IOException {
183+ if (compat)
184+ {
185+ // Serializes this instance in the old serial form
186+ //
187+ ObjectOutputStream.PutField fields = out.putFields();
188+ fields.put("relatedExcept", exception);
189+ fields.put("msgStr", ((exception != null)?exception.getMessage():""));
190+ out.writeFields();
191+ }
192+ else
193+ {
194+ // Serializes this instance in the new serial form
195+ //
196+ out.defaultWriteObject();
197+ }
198+ }
199+}