Java Code Examples for java.io.ObjectOutputStream#writeFields()
The following examples show how to use
java.io.ObjectOutputStream#writeFields() .
These examples are extracted from open source projects.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: jdk8u60 File: Permissions.java License: GNU General Public License v2.0 | 6 votes |
/** * @serialData Default fields. */ /* * Writes the contents of the permsMap field out as a Hashtable for * serialization compatibility with earlier releases. allPermission * unchanged. */ private void writeObject(ObjectOutputStream out) throws IOException { // Don't call out.defaultWriteObject() // Copy perms into a Hashtable Hashtable<Class<?>, PermissionCollection> perms = new Hashtable<>(permsMap.size()*2); // no sync; estimate synchronized (this) { perms.putAll(permsMap); } // Write out serializable fields ObjectOutputStream.PutField pfields = out.putFields(); pfields.put("allPermission", allPermission); // no sync; staleness OK pfields.put("perms", perms); out.writeFields(); }
Example 2
Source Project: jdk8u-jdk File: BigInteger.java License: GNU General Public License v2.0 | 6 votes |
/** * Save the {@code BigInteger} instance to a stream. * The magnitude of a BigInteger is serialized as a byte array for * historical reasons. * * @serialData two necessary fields are written as well as obsolete * fields for compatibility with older versions. */ private void writeObject(ObjectOutputStream s) throws IOException { // set the values of the Serializable fields ObjectOutputStream.PutField fields = s.putFields(); fields.put("signum", signum); fields.put("magnitude", magSerializedForm()); // The values written for cached fields are compatible with older // versions, but are ignored in readObject so don't otherwise matter. fields.put("bitCount", -1); fields.put("bitLength", -1); fields.put("lowestSetBit", -2); fields.put("firstNonzeroByteNum", -2); // save them s.writeFields(); }
Example 3
Source Project: TencentKona-8 File: Permissions.java License: GNU General Public License v2.0 | 6 votes |
/** * @serialData Default fields. */ /* * Writes the contents of the permsMap field out as a Hashtable for * serialization compatibility with earlier releases. allPermission * unchanged. */ private void writeObject(ObjectOutputStream out) throws IOException { // Don't call out.defaultWriteObject() // Copy perms into a Hashtable Hashtable<Class<?>, PermissionCollection> perms = new Hashtable<>(permsMap.size()*2); // no sync; estimate synchronized (this) { perms.putAll(permsMap); } // Write out serializable fields ObjectOutputStream.PutField pfields = out.putFields(); pfields.put("allPermission", allPermission); // no sync; staleness OK pfields.put("perms", perms); out.writeFields(); }
Example 4
Source Project: Java8CN File: RelationNotification.java License: Apache License 2.0 | 6 votes |
/** * Serializes a {@link RelationNotification} to an {@link ObjectOutputStream}. */ private void writeObject(ObjectOutputStream out) throws IOException { if (compat) { // Serializes this instance in the old serial form // ObjectOutputStream.PutField fields = out.putFields(); fields.put("myNewRoleValue", newRoleValue); fields.put("myOldRoleValue", oldRoleValue); fields.put("myRelId", relationId); fields.put("myRelObjName", relationObjName); fields.put("myRelTypeName", relationTypeName); fields.put("myRoleName",roleName); fields.put("myUnregMBeanList", unregisterMBeanList); out.writeFields(); } else { // Serializes this instance in the new serial form // out.defaultWriteObject(); } }
Example 5
Source Project: Bytecoder File: DocumentImpl.java License: Apache License 2.0 | 6 votes |
/** * @serialData Serialized fields. Convert Maps to Hashtables and Lists * to Vectors for backward compatibility. */ private void writeObject(ObjectOutputStream out) throws IOException { // Convert Maps to Hashtables, Lists to Vectors Vector<NodeIterator> it = (iterators == null)? null : new Vector<>(iterators); Vector<Range> r = (ranges == null)? null : new Vector<>(ranges); Hashtable<NodeImpl, Vector<LEntry>> el = null; if (eventListeners != null) { el = new Hashtable<>(); for (Map.Entry<NodeImpl, List<LEntry>> e : eventListeners.entrySet()) { el.put(e.getKey(), new Vector<>(e.getValue())); } } // Write serialized fields ObjectOutputStream.PutField pf = out.putFields(); pf.put("iterators", it); pf.put("ranges", r); pf.put("eventListeners", el); pf.put("mutationEvents", mutationEvents); out.writeFields(); }
Example 6
Source Project: jdk8u-jdk File: RoleUnresolved.java License: GNU General Public License v2.0 | 6 votes |
/** * Serializes a {@link RoleUnresolved} to an {@link ObjectOutputStream}. */ private void writeObject(ObjectOutputStream out) throws IOException { if (compat) { // Serializes this instance in the old serial form // ObjectOutputStream.PutField fields = out.putFields(); fields.put("myRoleName", roleName); fields.put("myRoleValue", roleValue); fields.put("myPbType", problemType); out.writeFields(); } else { // Serializes this instance in the new serial form // out.defaultWriteObject(); } }
Example 7
Source Project: TencentKona-8 File: Role.java License: GNU General Public License v2.0 | 6 votes |
/** * Serializes a {@link Role} to an {@link ObjectOutputStream}. */ private void writeObject(ObjectOutputStream out) throws IOException { if (compat) { // Serializes this instance in the old serial form // ObjectOutputStream.PutField fields = out.putFields(); fields.put("myName", name); fields.put("myObjNameList", objectNameList); out.writeFields(); } else { // Serializes this instance in the new serial form // out.defaultWriteObject(); } }
Example 8
Source Project: openjdk-8-source File: ServicePermission.java License: GNU General Public License v2.0 | 6 votes |
/** * @serialData "permissions" field (a Vector containing the ServicePermissions). */ /* * Writes the contents of the perms field out as a Vector for * serialization compatibility with earlier releases. */ private void writeObject(ObjectOutputStream out) throws IOException { // Don't call out.defaultWriteObject() // Write out Vector Vector<Permission> permissions = new Vector<>(perms.size()); synchronized (this) { permissions.addAll(perms); } ObjectOutputStream.PutField pfields = out.putFields(); pfields.put("permissions", permissions); out.writeFields(); }
Example 9
Source Project: Java8CN File: Notification.java License: Apache License 2.0 | 6 votes |
/** * Serializes a {@link Notification} to an {@link ObjectOutputStream}. */ private void writeObject(ObjectOutputStream out) throws IOException { if (compat) { // Serializes this instance in the old serial form // ObjectOutputStream.PutField fields = out.putFields(); fields.put("type", type); fields.put("sequenceNumber", sequenceNumber); fields.put("timeStamp", timeStamp); fields.put("userData", userData); fields.put("message", message); fields.put("source", source); out.writeFields(); } else { // Serializes this instance in the new serial form // out.defaultWriteObject(); } }
Example 10
Source Project: dragonwell8_jdk File: NumericValueExp.java License: GNU General Public License v2.0 | 6 votes |
/** * Serializes a {@link NumericValueExp} to an {@link ObjectOutputStream}. */ private void writeObject(ObjectOutputStream out) throws IOException { if (compat) { // Serializes this instance in the old serial form // ObjectOutputStream.PutField fields = out.putFields(); fields.put("doubleVal", doubleValue()); fields.put("longVal", longValue()); fields.put("valIsLong", isLong()); out.writeFields(); } else { // Serializes this instance in the new serial form // out.defaultWriteObject(); } }
Example 11
Source Project: JDKSourceCode1.8 File: RelationTypeSupport.java License: MIT License | 6 votes |
/** * Serializes a {@link RelationTypeSupport} to an {@link ObjectOutputStream}. */ private void writeObject(ObjectOutputStream out) throws IOException { if (compat) { // Serializes this instance in the old serial form // ObjectOutputStream.PutField fields = out.putFields(); fields.put("myTypeName", typeName); fields.put("myRoleName2InfoMap", roleName2InfoMap); fields.put("myIsInRelServFlg", isInRelationService); out.writeFields(); } else { // Serializes this instance in the new serial form // out.defaultWriteObject(); } }
Example 12
Source Project: jdk8u_jdk File: VetoableChangeSupport.java License: GNU General Public License v2.0 | 5 votes |
/** * @serialData Null terminated list of <code>VetoableChangeListeners</code>. * <p> * At serialization time we skip non-serializable listeners and * only serialize the serializable listeners. */ private void writeObject(ObjectOutputStream s) throws IOException { Hashtable<String, VetoableChangeSupport> children = null; VetoableChangeListener[] listeners = null; synchronized (this.map) { for (Entry<String, VetoableChangeListener[]> entry : this.map.getEntries()) { String property = entry.getKey(); if (property == null) { listeners = entry.getValue(); } else { if (children == null) { children = new Hashtable<>(); } VetoableChangeSupport vcs = new VetoableChangeSupport(this.source); vcs.map.set(null, entry.getValue()); children.put(property, vcs); } } } ObjectOutputStream.PutField fields = s.putFields(); fields.put("children", children); fields.put("source", this.source); fields.put("vetoableChangeSupportSerializedDataVersion", 2); s.writeFields(); if (listeners != null) { for (VetoableChangeListener l : listeners) { if (l instanceof Serializable) { s.writeObject(l); } } } s.writeObject(null); }
Example 13
Source Project: dragonwell8_jdk File: CryptoPermissions.java License: GNU General Public License v2.0 | 5 votes |
private void writeObject(ObjectOutputStream s) throws IOException { Hashtable<String,PermissionCollection> permTable = new Hashtable<>(perms); ObjectOutputStream.PutField fields = s.putFields(); fields.put("perms", permTable); s.writeFields(); }
Example 14
Source Project: knopflerfish.org File: PackagePermission.java License: BSD 3-Clause "New" or "Revised" License | 5 votes |
private synchronized void writeObject(ObjectOutputStream out) throws IOException { Hashtable<String, PackagePermission> hashtable = new Hashtable<String, PackagePermission>(permissions); ObjectOutputStream.PutField pfields = out.putFields(); pfields.put("permissions", hashtable); pfields.put("all_allowed", all_allowed); pfields.put("filterPermissions", filterPermissions); out.writeFields(); }
Example 15
Source Project: hottub File: CoreDocumentImpl.java License: GNU General Public License v2.0 | 5 votes |
/** * @serialData Serialized fields. Convert Maps to Hashtables for backward * compatibility. */ private void writeObject(ObjectOutputStream out) throws IOException { // Convert Maps to Hashtables Hashtable<Node, Hashtable<String, UserDataRecord>> nud = null; if (nodeUserData != null) { nud = new Hashtable<>(); for (Map.Entry<Node, Map<String, UserDataRecord>> e : nodeUserData.entrySet()) { //e.getValue() will not be null since an entry is always put with a non-null value nud.put(e.getKey(), new Hashtable<>(e.getValue())); } } Hashtable<String, Node> ids = (identifiers == null)? null : new Hashtable<>(identifiers); Hashtable<Node, Integer> nt = (nodeTable == null)? null : new Hashtable<>(nodeTable); // Write serialized fields ObjectOutputStream.PutField pf = out.putFields(); pf.put("docType", docType); pf.put("docElement", docElement); pf.put("fFreeNLCache", fFreeNLCache); pf.put("encoding", encoding); pf.put("actualEncoding", actualEncoding); pf.put("version", version); pf.put("standalone", standalone); pf.put("fDocumentURI", fDocumentURI); //userData is the original name. It has been changed to nodeUserData, refer to the corrsponding @serialField pf.put("userData", nud); pf.put("identifiers", ids); pf.put("changes", changes); pf.put("allowGrammarAccess", allowGrammarAccess); pf.put("errorChecking", errorChecking); pf.put("ancestorChecking", ancestorChecking); pf.put("xmlVersionChanged", xmlVersionChanged); pf.put("documentNumber", documentNumber); pf.put("nodeCounter", nodeCounter); pf.put("nodeTable", nt); pf.put("xml11Version", xml11Version); out.writeFields(); }
Example 16
Source Project: jdk8u-dev-jdk File: DescriptorSupport.java License: GNU General Public License v2.0 | 4 votes |
/** * Serializes a {@link DescriptorSupport} to an {@link ObjectOutputStream}. */ /* If you set jmx.serial.form to "1.2.0" or "1.2.1", then we are bug-compatible with those versions. Specifically, field names are forced to lower-case before being written. This contradicts the spec, which, though it does not mention serialization explicitly, does say that the case of field names is preserved. But in 1.2.0 and 1.2.1, this requirement was not met. Instead, field names in the descriptor map were forced to lower case. Those versions expect this to have happened to a descriptor they deserialize and e.g. getFieldValue will not find a field whose name is spelt with a different case. */ private void writeObject(ObjectOutputStream out) throws IOException { ObjectOutputStream.PutField fields = out.putFields(); boolean compat = "1.0".equals(serialForm); if (compat) fields.put("currClass", currClass); /* Purge the field "targetObject" from the DescriptorSupport before * serializing since the referenced object is typically not * serializable. We do this here rather than purging the "descriptor" * variable below because that HashMap doesn't do case-insensitivity. * See CR 6332962. */ SortedMap<String, Object> startMap = descriptorMap; if (startMap.containsKey("targetObject")) { startMap = new TreeMap<String, Object>(descriptorMap); startMap.remove("targetObject"); } final HashMap<String, Object> descriptor; if (compat || "1.2.0".equals(serialForm) || "1.2.1".equals(serialForm)) { descriptor = new HashMap<String, Object>(); for (Map.Entry<String, Object> entry : startMap.entrySet()) descriptor.put(entry.getKey().toLowerCase(), entry.getValue()); } else descriptor = new HashMap<String, Object>(startMap); fields.put("descriptor", descriptor); out.writeFields(); }
Example 17
Source Project: openjdk-jdk8u-backup File: DescriptorSupport.java License: GNU General Public License v2.0 | 4 votes |
/** * Serializes a {@link DescriptorSupport} to an {@link ObjectOutputStream}. */ /* If you set jmx.serial.form to "1.2.0" or "1.2.1", then we are bug-compatible with those versions. Specifically, field names are forced to lower-case before being written. This contradicts the spec, which, though it does not mention serialization explicitly, does say that the case of field names is preserved. But in 1.2.0 and 1.2.1, this requirement was not met. Instead, field names in the descriptor map were forced to lower case. Those versions expect this to have happened to a descriptor they deserialize and e.g. getFieldValue will not find a field whose name is spelt with a different case. */ private void writeObject(ObjectOutputStream out) throws IOException { ObjectOutputStream.PutField fields = out.putFields(); boolean compat = "1.0".equals(serialForm); if (compat) fields.put("currClass", currClass); /* Purge the field "targetObject" from the DescriptorSupport before * serializing since the referenced object is typically not * serializable. We do this here rather than purging the "descriptor" * variable below because that HashMap doesn't do case-insensitivity. * See CR 6332962. */ SortedMap<String, Object> startMap = descriptorMap; if (startMap.containsKey("targetObject")) { startMap = new TreeMap<String, Object>(descriptorMap); startMap.remove("targetObject"); } final HashMap<String, Object> descriptor; if (compat || "1.2.0".equals(serialForm) || "1.2.1".equals(serialForm)) { descriptor = new HashMap<String, Object>(); for (Map.Entry<String, Object> entry : startMap.entrySet()) descriptor.put(entry.getKey().toLowerCase(), entry.getValue()); } else descriptor = new HashMap<String, Object>(startMap); fields.put("descriptor", descriptor); out.writeFields(); }
Example 18
Source Project: j2objc File: Support_GetPutFieldsDefaulted.java License: Apache License 2.0 | 4 votes |
private void writeObject(ObjectOutputStream oos) throws IOException { putField = oos.putFields(); // Do not put anything into putField so that the get methods // will have to use default values. oos.writeFields(); }
Example 19
Source Project: dragonwell8_jdk File: ObjectName.java License: GNU General Public License v2.0 | 4 votes |
/** * Serializes an {@link ObjectName} to an {@link ObjectOutputStream}. * @serialData <ul> * <li>In the current serial form (value of property * <code>jmx.serial.form</code> differs from * <code>1.0</code>): the string * "<domain>:<properties><wild>", * where: <ul> * <li><domain> represents the domain part * of the {@link ObjectName}</li> * <li><properties> represents the list of * properties, as returned by * {@link #getKeyPropertyListString} * <li><wild> is empty if not * <code>isPropertyPattern</code>, or * is the character "<code>*</code>" if * this <code>isPropertyPattern</code> * and <properties> is empty, or * is "<code>,*</code>" if * <code>isPropertyPattern</code> and * <properties> is not empty. * </li> * </ul> * The intent is that this string could be supplied * to the {@link #ObjectName(String)} constructor to * produce an equivalent {@link ObjectName}. * </li> * <li>In the old serial form (value of property * <code>jmx.serial.form</code> is * <code>1.0</code>): <domain> <propertyList> * <propertyListString> <canonicalName> * <pattern> <propertyPattern>, * where: <ul> * <li><domain> represents the domain part * of the {@link ObjectName}</li> * <li><propertyList> is the * {@link Hashtable} that contains all the * pairs (key,value) for this * {@link ObjectName}</li> * <li><propertyListString> is the * {@link String} representation of the * list of properties in any order (not * mandatorily a canonical representation) * </li> * <li><canonicalName> is the * {@link String} containing this * {@link ObjectName}'s canonical name</li> * <li><pattern> is a boolean which is * <code>true</code> if this * {@link ObjectName} contains a pattern</li> * <li><propertyPattern> is a boolean which * is <code>true</code> if this * {@link ObjectName} contains a pattern in * the list of properties</li> * </ul> * </li> * </ul> */ private void writeObject(ObjectOutputStream out) throws IOException { if (compat) { // Serializes this instance in the old serial form // Read CR 6441274 before making any changes to this code ObjectOutputStream.PutField fields = out.putFields(); fields.put("domain", _canonicalName.substring(0, _domain_length)); fields.put("propertyList", getKeyPropertyList()); fields.put("propertyListString", getKeyPropertyListString()); fields.put("canonicalName", _canonicalName); fields.put("pattern", (_domain_pattern || _property_list_pattern)); fields.put("propertyPattern", _property_list_pattern); out.writeFields(); } else { // Serializes this instance in the new serial form // out.defaultWriteObject(); out.writeObject(getSerializedNameString()); } }
Example 20
Source Project: openjdk-8 File: XPathException.java License: GNU General Public License v2.0 | 3 votes |
/** * Writes "cause" field to the stream. * The cause is got from the parent class. * * @param out stream used for serialization. * @throws IOException thrown by <code>ObjectOutputStream</code> * */ private void writeObject(ObjectOutputStream out) throws IOException { ObjectOutputStream.PutField fields = out.putFields(); fields.put("cause", (Throwable) super.getCause()); out.writeFields(); }