Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-6387704

Source code of OOS/OIS/OSC is incorrect in specification

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P4 P4
    • None
    • 6
    • core-libs
    • None

      The Java Object Serialization Specification:

      http://java.sun.com/j2se/1.5.0/docs/guide/serialization/spec/serialTOC.html

      contains several errors in its descriptions of the public API of
      java.io.ObjectOutputStream, ObjectOutputStream, ObjectStreamClass,
      and ObjectStreamField classes, making them not correspond to the actual
      API as seen in the Javadoc-generated API doc.

      The incorrect listings are in the following sections of specification:

      2.1 The ObjectOutputStream Class
      3.1 The ObjectInputStream Class
      4.1 The ObjectStreamClass Class
      4.4, for ObjectStreamField


      The pointed places in serialization specification should be fixed in the following manner:

      2.1 The ObjectOutputStream Class
      listing of ObjectOutputStream Class
      lines:

      >> public void defaultWriteObject() throws IOException, NotActiveException;
      should be:
      public void defaultWriteObject() throws IOException;

      >> public writeFields() throws IOException;
      should be:
      public void writeFields() throws IOException;

      >> protected void annotateClass(Class cl) throws IOException;
      should be:
      protected void annotateClass(Class<?> cl) throws IOException;

      >> abstract static public class PutField {
      should be:
      public abstract static class PutField {

      Each method in PutField class like:
      >> public void put(String name, boolean value) throws IOException, IllegalArgumentException;
      should have keyword *abstract* and doesn't throw any exceptions

      >> protected writeObjectOverride() throws NotActiveException, IOException;
      should be:
      protected void writeObjectOverride(Object obj) throws IOException;

      line like: protected ObjectOutputStream() throws IOException;
      should follow after definition of another constructor in the beginning
      of class

      following definition should be added to interface:
      protected void annotateProxyClass(Class<?> class)
           throws IOException;

      3.1 The ObjectInputStream Class
      listing of ObjectInputStream Class
      lines:

      >> public ObjectInputStream(InputStream in) throws StreamCorruptedException, IOException;
      should be:
      public ObjectInputStream(InputStream in) throws IOException;

      >> public final Object readObject() throws OptionalDataException, ClassNotFoundException, IOException;
      should be:
      public final Object readObject() throws ClassNotFoundException, IOException;

      >> public Object readUnshared() throws OptionalDataException, ClassNotFoundException, IOException;
      should be:
      public Object readUnshared() throws ClassNotFoundException, IOException;

      >> public void defaultReadObject() throws IOException, ClassNotFoundException, NotActiveException;
      should be:
      public void defaultReadObject() throws IOException, ClassNotFoundException;

      >> public GetField readFields() throws IOException;
      should be:
      public GetField readFields() throws IOException, ClassNotFoundException;

      line: public synchronized void registerValidation(ObjectInputValidation obj, int prio)
      throws NotActiveException, InvalidObjectException;
      should be without *synchronized* keyword:
      public void registerValidation(ObjectInputValidation obj, int prio) throws NotActiveException, InvalidObjectException;

      >> protected Class resolveClass(ObjectStreamClass v) throws IOException, ClassNotFoundException;
      should be:
      protected Class<?> resolveClass(ObjectStreamClass desc) throws IOException, ClassNotFoundException;

      >> static abstract public class GetField
      should be:
      public abstract static class GetField

      Each method in GetField class like:
      >> public char get(String name, char default) throws IOException, IllegalArgumentException;
      should have keyword *abstract* and doesn't throw IllegalArgumentException exception

      >> protected readObjectOverride() throws OptionalDataException, ClassNotFoundException, IOException;
      should be:
      protected Object readObjectOverride() throws ClassNotFoundException, IOException;

      line like: protected ObjectInputStream() throws StreamCorruptedException, IOException;
      should follow after definition of another constructor in the beginning of class

      following definition should be added to interface:
      protected Class<?> resolveProxyClass(String[] interfaces)
           throws IOException, ClassNotFoundException;

      4.1 The ObjectStreamClass Class
      listing of ObjectStreamClass Class

      >> public class ObjectStreamClass
      replace on:
      public class ObjectStreamClass implements Serializable

      >> public static ObjectStreamClass lookup(Class cl);
      replace on:
      public static ObjectStreamClass lookup(Class<?> cl);

      >> public static ObjectStreamClass lookupAny(Class cl);
      replace on:
      public static ObjectStreamClass lookupAny(Class<?> cl);

      >> public Class forClass();
      replace on:
      public Class<?> forClass();

      >> also we have to add following method to code:
      public ObjectStreamField getField(String name);

      4.4 The ObjectStreamField Class
      listing of ObjectStreamField class

      lines:

      >> public class ObjectStreamField implements Comparable {
      should be;
      public class ObjectStreamField implements Comparable<Object> {

      >> public ObjectStreamField(String fieldName, Class fieldType);
      should be:
      public ObjectStreamField(String fieldName, Class<?> fieldType);

      >> public ObjectStreamField(String fieldName, Class fieldType, boolean unshared);
      should be:
      public ObjectStreamField(String fieldName, Class<?> fieldType, boolean unshared);

      >> public Class getType();
      should be:
      public Class<?> getType();

            rriggs Roger Riggs
            aozerov Andrey Ozerov
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: