/** * Serializes an {@link MBeanFeatureInfo} to an {@link ObjectOutputStream}. * * @serialData For compatibility reasons, an object of this class is serialized as follows. * <ul> * The method {@link ObjectOutputStream#defaultWriteObject defaultWriteObject()} is called * first to serialize the object except the field {@code descriptor} which is declared as * transient. The field {@code descriptor} is serialized as follows: * <ul> * <li>If {@code descriptor} is an instance of the class {@link ImmutableDescriptor}, the * method {@link ObjectOutputStream#write write(int val)} is called to write a byte * with the value {@code 1}, then the method {@link ObjectOutputStream#writeObject * writeObject(Object obj)} is called twice to serialize the field names and the field * values of the {@code descriptor}, respectively as a {@code String[]} and an {@code * Object[]}; * <li>Otherwise, the method {@link ObjectOutputStream#write write(int val)} is called to * write a byte with the value {@code 0}, then the method {@link * ObjectOutputStream#writeObject writeObject(Object obj)} is called to serialize * directly the field {@code descriptor}. * </ul> * </ul> * * @since 1.6 */ private void writeObject(ObjectOutputStream out) throws IOException { out.defaultWriteObject(); if (descriptor != null && descriptor.getClass() == ImmutableDescriptor.class) { out.write(1); final String[] names = descriptor.getFieldNames(); out.writeObject(names); out.writeObject(descriptor.getFieldValues(names)); } else { out.write(0); out.writeObject(descriptor); } }