/* 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();
  }
 private synchronized void writeObject(ObjectOutputStream out) throws IOException {
   ObjectOutputStream.PutField pfields = out.putFields();
   pfields.put("permissions", permissions);
   pfields.put("all_allowed", all_allowed);
   pfields.put("filterPermissions", filterPermissions);
   out.writeFields();
 }
Exemple #3
0
 /** readObject is called to restore the state of the StringBuffer from a stream. */
 private synchronized void writeObject(java.io.ObjectOutputStream s) throws java.io.IOException {
   java.io.ObjectOutputStream.PutField fields = s.putFields();
   fields.put("value", value);
   fields.put("count", count);
   fields.put("shared", false);
   s.writeFields();
 }
 private void writeObject(ObjectOutputStream out) throws IOException {
   // don't call defaultWriteObject()
   ObjectOutputStream.PutField fields = out.putFields();
   fields.put("theName", name);
   fields.put("theNumber", number);
   fields.put("theSoftware", someSoftware);
   fields.put("thePolymorphic", polymorphic);
   fields.put("theNothing", nothing);
   out.writeFields();
 }
  private void writeObject(ObjectOutputStream stream) throws IOException {
    ObjectOutputStream.PutField fields = stream.putFields();
    if (ipaddress == null) {
      fields.put("address", 0); // $NON-NLS-1$
    } else {
      fields.put("address", bytesToInt(ipaddress, 0)); // $NON-NLS-1$
    }
    fields.put("family", family); // $NON-NLS-1$
    fields.put("hostName", hostName); // $NON-NLS-1$

    stream.writeFields();
  }
Exemple #6
0
 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();
 }
Exemple #7
0
  private synchronized void writeObject(ObjectOutputStream stream) throws IOException {
    // Emulate loadFactor field for other implementations to read
    ObjectOutputStream.PutField fields = stream.putFields();
    fields.put("threshold", (int) (DEFAULT_LOAD_FACTOR * table.length));
    fields.put("loadFactor", DEFAULT_LOAD_FACTOR);
    stream.writeFields();

    stream.writeInt(table.length); // Capacity
    stream.writeInt(size);
    for (Entry<K, V> e : entrySet()) {
      stream.writeObject(e.getKey());
      stream.writeObject(e.getValue());
    }
  }
  /*
   * 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();
  }
  /*
   * Writes the contents of the perms field out as a Hashtable for
   * serialization compatibility with earlier releases. all_allowed
   * and permClass unchanged.
   */
  private void writeObject(ObjectOutputStream out) throws IOException {
    // Don't call out.defaultWriteObject()

    // Copy perms into a Hashtable
    Hashtable permissions = new Hashtable(perms.size() * 2);
    permissions.putAll(perms);

    // Write out serializable fields
    ObjectOutputStream.PutField pfields = out.putFields();
    pfields.put("all_allowed", all_allowed);
    pfields.put("permissions", permissions);
    pfields.put("permClass", permClass);
    out.writeFields();
  }
 /** Serializes an {@link InvalidTargetObjectTypeException} 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("relatedExcept", exception);
     fields.put("msgStr", ((exception != null) ? exception.getMessage() : ""));
     out.writeFields();
   } else {
     // Serializes this instance in the new serial form
     //
     out.defaultWriteObject();
   }
 }
 /** {@collect.stats} 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", (ArrayList) roleValue);
     fields.put("myPbType", problemType);
     out.writeFields();
   } else {
     // Serializes this instance in the new serial form
     //
     out.defaultWriteObject();
   }
 }
Exemple #12
0
  /**
   * For serialization, write this object as a single long value.
   *
   * @param stream the output stream to write this object to
   */
  private void writeObject(ObjectOutputStream stream) throws IOException {
    ObjectOutputStream.PutField fields = stream.putFields();
    long value = 0;

    try {
      value = this.value.getAsNumber();
    } catch (TemplateModelException e) {
      // Shouldn't ever happen since FastScalar doesn't throw this
      // exception
    }

    // Synthesize for compactness
    fields.put("numberValue", value);
    stream.writeFields();
  }
Exemple #13
0
 /** 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();
   }
 }
  static void writeSlotWithDefaultMethod(
      ClassMetaDataSlot slot,
      ObjectOutput out,
      Object obj,
      ObjectSubstitutionInterface substitution)
      throws IOException {
    ObjectOutputStream oos = new ObjectOutputStreamProxy(out, obj, slot, substitution);
    ObjectOutputStream.PutField putField = oos.putFields();
    ClassMetadataField[] fields = slot.getFields();
    FieldsManager fieldsManager = FieldsManager.getFieldsManager();

    for (int fieldNR = 0; fieldNR < fields.length; fieldNR++) {
      ClassMetadataField classMetadataField = fields[fieldNR];
      Class type = classMetadataField.getField().getType();
      String fieldName = classMetadataField.getFieldName();

      if (type == Boolean.TYPE) {
        putField.put(fieldName, fieldsManager.getBoolean(obj, classMetadataField));
      } else if (type == Byte.TYPE) {
        putField.put(fieldName, fieldsManager.getByte(obj, classMetadataField));
      } else if (type == Character.TYPE) {
        putField.put(fieldName, fieldsManager.getCharacter(obj, classMetadataField));
      } else if (type == Short.TYPE) {
        putField.put(fieldName, fieldsManager.getShort(obj, classMetadataField));
      } else if (type == Integer.TYPE) {
        putField.put(fieldName, fieldsManager.getInt(obj, classMetadataField));
      } else if (type == Long.TYPE) {
        putField.put(fieldName, fieldsManager.getLong(obj, classMetadataField));
      } else if (type == Float.TYPE) {
        putField.put(fieldName, fieldsManager.getFloat(obj, classMetadataField));
      } else if (type == Double.TYPE) {
        putField.put(fieldName, fieldsManager.getDouble(obj, classMetadataField));
      } else {
        Object value = fieldsManager.getObject(obj, classMetadataField);
        putField.put(fieldName, value);
      }
    }

    oos.writeFields();
  }
 private void writeObject(ObjectOutputStream stream) throws IOException {
   ObjectOutputStream.PutField fields = stream.putFields();
   fields.put("groupingUsed", groupingUsed);
   fields.put(
       "maxFractionDigits",
       maximumFractionDigits < Byte.MAX_VALUE ? (byte) maximumFractionDigits : Byte.MAX_VALUE);
   fields.put("maximumFractionDigits", maximumFractionDigits);
   fields.put("maximumIntegerDigits", maximumIntegerDigits);
   fields.put(
       "maxIntegerDigits",
       maximumIntegerDigits < Byte.MAX_VALUE ? (byte) maximumIntegerDigits : Byte.MAX_VALUE);
   fields.put(
       "minFractionDigits",
       minimumFractionDigits < Byte.MAX_VALUE ? (byte) minimumFractionDigits : Byte.MAX_VALUE);
   fields.put("minimumFractionDigits", minimumFractionDigits);
   fields.put("minimumIntegerDigits", minimumIntegerDigits);
   fields.put(
       "minIntegerDigits",
       minimumIntegerDigits < Byte.MAX_VALUE ? (byte) minimumIntegerDigits : Byte.MAX_VALUE);
   fields.put("parseIntegerOnly", parseIntegerOnly);
   fields.put("serialVersionOnStream", 1);
   stream.writeFields();
 }
  /**
   * This is to fix bugzilla bug 22438 If the user defined class implements URIResolver and
   * Serializable then we want it to get serialized
   */
  private void writeObject(ObjectOutputStream os) throws IOException, ClassNotFoundException {
    if (_auxClasses != null) {
      // throw with the same message as when Hashtable was used for compatibility.
      throw new NotSerializableException(
          "com.sun.org.apache.xalan.internal.xsltc.runtime.Hashtable");
    }

    // Write serialized fields
    ObjectOutputStream.PutField pf = os.putFields();
    pf.put("_name", _name);
    pf.put("_bytecodes", _bytecodes);
    pf.put("_class", _class);
    pf.put("_transletIndex", _transletIndex);
    pf.put("_outputProperties", _outputProperties);
    pf.put("_indentNumber", _indentNumber);
    os.writeFields();

    if (_uriResolver instanceof Serializable) {
      os.writeBoolean(true);
      os.writeObject((Serializable) _uriResolver);
    } else {
      os.writeBoolean(false);
    }
  }
Exemple #17
0
 private void writeObject(ObjectOutputStream s) throws IOException {
   java.io.ObjectOutputStream.PutField fields = s.putFields();
   fields.put(SerializationValuesFieldKey, ((_allObjects())));
   s.writeFields();
 }
 private void writeObject(ObjectOutputStream oos) throws IOException {
   // note aField2 is not written
   ObjectOutputStream.PutField fields = oos.putFields();
   fields.put("aField1", aField1);
   oos.writeFields();
 }
 private void writeObject(java.io.ObjectOutputStream out)
     throws java.io.IOException, ClassNotFoundException {
   out.putFields();
   out.writeFields();
 }
 private void writeObject(java.io.ObjectOutputStream out)
     throws java.io.IOException, ClassNotFoundException {
   ObjectOutputStream.PutField fields = out.putFields();
   fields.put(SIMULATED_FIELD_NAME, Integer.toString(anInstanceVar));
   out.writeFields();
 }
 /**
  * Writes the fields according to expected format, adding the boolean field {@code all_allowed}
  * which is {@code true} if this collection is not empty.
  */
 private void writeObject(java.io.ObjectOutputStream out) throws IOException {
   ObjectOutputStream.PutField fields = out.putFields();
   fields.put("all_allowed", all != null); // $NON-NLS-1$
   out.writeFields();
 }
 private void writeObject(ObjectOutputStream out) throws IOException {
   ObjectOutputStream.PutField fields = out.putFields();
   fields.put("name", name.toUpperCase());
   fields.put("number", number * 100);
   out.writeFields();
 }
 @Override
 public void writeFields() throws IOException {
   out.writeFields();
 }