68 * Namespaces in XML Errata</a> |
68 * Namespaces in XML Errata</a> |
69 * @since 1.5 |
69 * @since 1.5 |
70 */ |
70 */ |
71 |
71 |
72 public class QName implements Serializable { |
72 public class QName implements Serializable { |
73 |
73 // tests show that the ID is the same from JDK 1.5 through JDK 9 |
74 /** |
74 private static final long serialVersionUID = -9120448754896609940L; |
75 * <p>Stream Unique Identifier.</p> |
|
76 * |
|
77 * <p>Due to a historical defect, QName was released with multiple |
|
78 * serialVersionUID values even though its serialization was the |
|
79 * same.</p> |
|
80 * |
|
81 * <p>To workaround this issue, serialVersionUID is set with either |
|
82 * a default value or a compatibility value. To use the |
|
83 * compatibility value, set the system property:</p> |
|
84 * |
|
85 * <code>com.sun.xml.namespace.QName.useCompatibleSerialVersionUID=1.0</code> |
|
86 * |
|
87 * <p>This workaround was inspired by classes in the javax.management |
|
88 * package, e.g. ObjectName, etc. |
|
89 * See CR6267224 for original defect report.</p> |
|
90 */ |
|
91 private static final long serialVersionUID; |
|
92 /** |
|
93 * <p>Default <code>serialVersionUID</code> value.</p> |
|
94 */ |
|
95 private static final long defaultSerialVersionUID = -9120448754896609940L; |
|
96 /** |
|
97 * <p>Compatibility <code>serialVersionUID</code> value.</p> |
|
98 */ |
|
99 private static final long compatibleSerialVersionUID = 4418622981026545151L; |
|
100 /** |
|
101 * <p>Flag to use default or campatible serialVersionUID.</p> |
|
102 */ |
|
103 private static boolean useDefaultSerialVersionUID = true; |
|
104 static { |
|
105 try { |
|
106 // use a privileged block as reading a system property |
|
107 String valueUseCompatibleSerialVersionUID = SecuritySupport.getSystemProperty( |
|
108 "com.sun.xml.namespace.QName.useCompatibleSerialVersionUID"); |
|
109 |
|
110 useDefaultSerialVersionUID = (valueUseCompatibleSerialVersionUID != null |
|
111 && valueUseCompatibleSerialVersionUID.equals("1.0")) ? false : true; |
|
112 } catch (Exception exception) { |
|
113 // use default if any Exceptions |
|
114 useDefaultSerialVersionUID = true; |
|
115 } |
|
116 |
|
117 // set serialVersionUID to desired value |
|
118 if (useDefaultSerialVersionUID) { |
|
119 serialVersionUID = defaultSerialVersionUID; |
|
120 } else { |
|
121 serialVersionUID = compatibleSerialVersionUID; |
|
122 } |
|
123 } |
|
124 |
75 |
125 /** |
76 /** |
126 * <p>Namespace URI of this <code>QName</code>.</p> |
77 * <p>Namespace URI of this <code>QName</code>.</p> |
127 */ |
78 */ |
128 private final String namespaceURI; |
79 private final String namespaceURI; |