1 7 25 26 27 28 package javax.management.modelmbean; 29 30 import java.io.IOException ; 31 import java.io.ObjectInputStream ; 32 import java.io.ObjectOutputStream ; 33 import java.io.ObjectStreamField ; 34 import java.security.AccessController ; 35 import java.security.PrivilegedAction ; 36 37 import com.sun.jmx.mbeanserver.GetPropertyAction; 38 39 47 public class XMLParseException 48 extends Exception 49 { 50 private static final long oldSerialVersionUID = -7780049316655891976L; 58 private static final long newSerialVersionUID = 3176664577895105181L; 61 private static final ObjectStreamField [] oldSerialPersistentFields = 64 { 65 new ObjectStreamField ("msgStr", String .class) 66 }; 67 private static final ObjectStreamField [] newSerialPersistentFields = { }; 70 private static final long serialVersionUID; 73 private static final ObjectStreamField [] serialPersistentFields; 74 private static boolean compat = false; 75 static { 76 try { 77 PrivilegedAction act = new GetPropertyAction("jmx.serial.form"); 78 String form = (String ) AccessController.doPrivileged(act); 79 compat = (form != null && form.equals("1.0")); 80 } catch (Exception e) { 81 } 83 if (compat) { 84 serialPersistentFields = oldSerialPersistentFields; 85 serialVersionUID = oldSerialVersionUID; 86 } else { 87 serialPersistentFields = newSerialPersistentFields; 88 serialVersionUID = newSerialVersionUID; 89 } 90 } 91 94 97 public XMLParseException () 98 { 99 super("XML Parse Exception."); 100 } 101 102 107 public XMLParseException (String s) 108 { 109 super("XML Parse Exception: " + s); 110 } 111 117 public XMLParseException (Exception e, String s) 118 { 119 super("XML Parse Exception: " + s + ":" + e.toString()); 120 } 121 122 125 private void readObject(ObjectInputStream in) 126 throws IOException , ClassNotFoundException { 127 in.defaultReadObject(); 129 } 130 131 132 135 private void writeObject(ObjectOutputStream out) 136 throws IOException { 137 if (compat) 138 { 139 ObjectOutputStream.PutField fields = out.putFields(); 142 fields.put("msgStr", getMessage()); 143 out.writeFields(); 144 } 145 else 146 { 147 out.defaultWriteObject(); 150 } 151 } 152 } 153 154 155 156 157 | Popular Tags |