Java Code Examples for java.io.ObjectOutputStream#PutField

The following examples show how to use java.io.ObjectOutputStream#PutField . 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 File: MBeanServerNotificationFilter.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Serializes an {@link MBeanServerNotificationFilter} 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("mySelectObjNameList", selectedNames);
    fields.put("myDeselectObjNameList", deselectedNames);
    out.writeFields();
  }
  else
  {
    // Serializes this instance in the new serial form
    //
    out.defaultWriteObject();
  }
}
 
Example 2
Source File: RelationNotification.java    From jdk1.8-source-analysis with Apache License 2.0 6 votes vote down vote up
/**
 * 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 3
Source File: PropertyPermission.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
/**
 * @serialData Default fields.
 */
/*
 * Writes the contents of the perms field out as a Hashtable for
 * serialization compatibility with earlier releases. all_allowed
 * unchanged.
 */
private void writeObject(ObjectOutputStream out) throws IOException {
    // Don't call out.defaultWriteObject()

    // Copy perms into a Hashtable
    Hashtable<String, Permission> permissions =
        new Hashtable<>(perms.size()*2);
    synchronized (this) {
        permissions.putAll(perms);
    }

    // Write out serializable fields
    ObjectOutputStream.PutField pfields = out.putFields();
    pfields.put("all_allowed", all_allowed);
    pfields.put("permissions", permissions);
    out.writeFields();
}
 
Example 4
Source File: MBeanServerNotificationFilter.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Serializes an {@link MBeanServerNotificationFilter} 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("mySelectObjNameList", selectedNames);
    fields.put("myDeselectObjNameList", deselectedNames);
    out.writeFields();
  }
  else
  {
    // Serializes this instance in the new serial form
    //
    out.defaultWriteObject();
  }
}
 
Example 5
Source File: RoleInfo.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Serializes a {@link RoleInfo} 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("myIsReadableFlg", isReadable);
    fields.put("myIsWritableFlg", isWritable);
    fields.put("myDescription", description);
    fields.put("myMinDegree", minDegree);
    fields.put("myMaxDegree", maxDegree);
    fields.put("myRefMBeanClassName", referencedMBeanClassName);
    out.writeFields();
  }
  else
  {
    // Serializes this instance in the new serial form
    //
    out.defaultWriteObject();
  }
}
 
Example 6
Source File: Permissions.java    From jdk8u-dev-jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * @serialData Default fields.
 */
/*
 * Writes the contents of the permsMap field out as a Hashtable for
 * serialization compatibility with earlier releases.
 */
private void writeObject(ObjectOutputStream out) throws IOException {
    // Don't call out.defaultWriteObject()

    // Copy perms into a Hashtable
    Hashtable<Permission, Permission> perms =
            new Hashtable<>(permsMap.size()*2);
    synchronized (this) {
        perms.putAll(permsMap);
    }

    // Write out serializable fields
    ObjectOutputStream.PutField pfields = out.putFields();
    pfields.put("perms", perms);
    out.writeFields();
}
 
Example 7
Source File: Notification.java    From jdk8u-dev-jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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 8
Source File: ModelMBeanConstructorInfo.java    From jdk8u_jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Serializes a {@link ModelMBeanConstructorInfo} 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("consDescriptor", consDescriptor);
    fields.put("currClass", currClass);
    out.writeFields();
  }
  else
  {
    // Serializes this instance in the new serial form
    //
    out.defaultWriteObject();
  }
}
 
Example 9
Source File: Inet6Address.java    From Java8CN with Apache License 2.0 6 votes vote down vote up
/**
 * default behavior is overridden in order to write the
 * scope_ifname field as a String, rather than a NetworkInterface
 * which is not serializable
 */
private synchronized void writeObject(ObjectOutputStream s)
    throws IOException
{
        String ifname = null;

    if (holder6.scope_ifname != null) {
        ifname = holder6.scope_ifname.getName();
        holder6.scope_ifname_set = true;
    }
    ObjectOutputStream.PutField pfields = s.putFields();
    pfields.put("ipaddress", holder6.ipaddress);
    pfields.put("scope_id", holder6.scope_id);
    pfields.put("scope_id_set", holder6.scope_id_set);
    pfields.put("scope_ifname_set", holder6.scope_ifname_set);
    pfields.put("ifname", ifname);
    s.writeFields();
}
 
Example 10
Source File: ServicePermission.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
/**
 * @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 11
Source File: ModelMBeanAttributeInfo.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Serializes a {@link ModelMBeanAttributeInfo} 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("attrDescriptor", attrDescriptor);
    fields.put("currClass", currClass);
    out.writeFields();
  }
  else
  {
    // Serializes this instance in the new serial form
    //
    out.defaultWriteObject();
  }
}
 
Example 12
Source File: RoleInfo.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Serializes a {@link RoleInfo} 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("myIsReadableFlg", isReadable);
    fields.put("myIsWritableFlg", isWritable);
    fields.put("myDescription", description);
    fields.put("myMinDegree", minDegree);
    fields.put("myMaxDegree", maxDegree);
    fields.put("myRefMBeanClassName", referencedMBeanClassName);
    out.writeFields();
  }
  else
  {
    // Serializes this instance in the new serial form
    //
    out.defaultWriteObject();
  }
}
 
Example 13
Source File: OutputStreamHook.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
public ObjectOutputStream.PutField putFields()
    throws IOException {
    if (putFields == null) {
        putFields = new HookPutFields();
    }
    return putFields;
}
 
Example 14
Source File: OutputStreamHook.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
public ObjectOutputStream.PutField putFields()
    throws IOException {
    if (putFields == null) {
        putFields = new HookPutFields();
    }
    return putFields;
}
 
Example 15
Source File: BundlePermission.java    From knopflerfish.org with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private synchronized void writeObject(ObjectOutputStream out) throws IOException {
	Hashtable<String, BundlePermission> hashtable = new Hashtable<String, BundlePermission>(permissions);
	ObjectOutputStream.PutField pfields = out.putFields();
	pfields.put("permissions", hashtable);
	pfields.put("all_allowed", all_allowed);
	out.writeFields();
}
 
Example 16
Source File: PutFieldTest.java    From ehcache3 with Apache License 2.0 5 votes vote down vote up
private void writeObject(ObjectOutputStream out) throws IOException {
  ObjectOutputStream.PutField fields = out.putFields();
  fields.put("z", true);
  fields.put("b", (byte) 5);
  fields.put("c", '5');
  fields.put("s", (short) 5);
  fields.put("i", 5);
  fields.put("j", 5l);
  fields.put("f", 5.0f);
  fields.put("d", 5.0);
  fields.put("str", "5");
  out.writeFields();
}
 
Example 17
Source File: InetSocketAddress.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
private void writeObject(ObjectOutputStream out)
    throws IOException
{
    // Don't call defaultWriteObject()
     ObjectOutputStream.PutField pfields = out.putFields();
     pfields.put("hostname", holder.hostname);
     pfields.put("addr", holder.addr);
     pfields.put("port", holder.port);
     out.writeFields();
 }
 
Example 18
Source File: Token.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
     * @serialData Serialized fields. Convert the List to Vector for backward compatibility.
     */
    private void writeObject(ObjectOutputStream out) throws IOException {
        // Convert List to Vector
        Vector<Token> vChildren = (children == null)? null : new Vector<>(children);

        // Write serialized fields
        ObjectOutputStream.PutField pf = out.putFields();
        pf.put("children", vChildren);
        out.writeFields();
}
 
Example 19
Source File: ExceptionInInitializerError.java    From Bytecoder with Apache License 2.0 4 votes vote down vote up
@java.io.Serial
private void writeObject(ObjectOutputStream out) throws IOException {
    ObjectOutputStream.PutField fields = out.putFields();
    fields.put("exception", super.getCause());
    out.writeFields();
}
 
Example 20
Source File: AbstractObjectOutputStream.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
/*************************************************************/
/* Use the methods of PutField to map between Serializable fields
 * and actual fields of a Serializable class.
 */

abstract public ObjectOutputStream.PutField putFields() throws IOException;