Hi all, looking at the reverse japi results I noticed that we provide a static setDefaultProtocolVersion() method which is not part of the API. I think we don't want such api additions, right ?
This patch removes this method, documents the non-static useProtocolVersion() public API method a bit more and fixes its parameter testing (mauve test will be committed with the patch). This patch is send as RFC as I don't know if there was maybe a reason behind this GNU classpath specific API method. 2006-03-21 Wolfgang Baer <[EMAIL PROTECTED]> * java/io/ObjectStreamConstants.java: Added since tag. (PROTOCOL_VERSION_1): Added javadoc. (PROTOCOL_VERSION_2): Likewise. * java/io/ObjectOutputStream.java: (setDefaultProtocolVersion): Removed. (useProtocolVersion): Fixed parameter tests. Updated javadoc. Wolfgang
Index: java/io/ObjectOutputStream.java =================================================================== RCS file: /cvsroot/classpath/classpath/java/io/ObjectOutputStream.java,v retrieving revision 1.66 diff -u -r1.66 ObjectOutputStream.java --- java/io/ObjectOutputStream.java 15 Feb 2006 18:43:04 -0000 1.66 +++ java/io/ObjectOutputStream.java 21 Mar 2006 20:23:03 -0000 @@ -549,53 +549,37 @@ * different protocols, specified by <code>PROTOCOL_VERSION_1</code> * and <code>PROTOCOL_VERSION_2</code>. This implementation writes * data using <code>PROTOCOL_VERSION_2</code> by default, as is done - * by the JDK 1.2. - * - * A non-portable method, <code>setDefaultProtocolVersion (int - * version)</code> is provided to change the default protocol - * version. - * + * since the JDK 1.2. + * <p> * For an explanation of the differences between the two protocols - * see XXX: the Java ObjectSerialization Specification. - * - * @exception IOException if <code>version</code> is not a valid - * protocol - * - * @see #setDefaultProtocolVersion(int) + * see the Java Object Serialization Specification. + * </p> + * + * @param version the version to use. + * + * @throws IllegalArgumentException if <code>version</code> is not a valid + * protocol. + * @throws IllegalStateException if called after the first the first object + * was serialized. + * @throws IOException if an I/O error occurs. + * + * @see ObjectStreamConstants#PROTOCOL_VERSION_1 + * @see ObjectStreamConstants#PROTOCOL_VERSION_2 + * + * @since 1.2 */ public void useProtocolVersion(int version) throws IOException { if (version != PROTOCOL_VERSION_1 && version != PROTOCOL_VERSION_2) - throw new IOException("Invalid protocol version requested."); + throw new IllegalArgumentException("Invalid protocol version requested."); + + if (nextOID != baseWireHandle) + throw new IllegalStateException("Protocol version cannot be changed " + + "after serialization started."); protocolVersion = version; } - - /** - * <em>GNU $classpath specific</em> - * - * Changes the default stream protocol used by all - * <code>ObjectOutputStream</code>s. There are currently two - * different protocols, specified by <code>PROTOCOL_VERSION_1</code> - * and <code>PROTOCOL_VERSION_2</code>. The default default is - * <code>PROTOCOL_VERSION_1</code>. - * - * @exception IOException if <code>version</code> is not a valid - * protocol - * - * @see #useProtocolVersion(int) - */ - public static void setDefaultProtocolVersion(int version) - throws IOException - { - if (version != PROTOCOL_VERSION_1 && version != PROTOCOL_VERSION_2) - throw new IOException("Invalid protocol version requested."); - - defaultProtocolVersion = version; - } - - /** * An empty hook that allows subclasses to write extra information * about classes to the stream. This method is called the first Index: java/io/ObjectStreamConstants.java =================================================================== RCS file: /cvsroot/classpath/classpath/java/io/ObjectStreamConstants.java,v retrieving revision 1.13 diff -u -r1.13 ObjectStreamConstants.java --- java/io/ObjectStreamConstants.java 2 Jul 2005 20:32:38 -0000 1.13 +++ java/io/ObjectStreamConstants.java 21 Mar 2006 20:23:03 -0000 @@ -1,6 +1,6 @@ /* ObjectStreamConstants.java -- Interface containing constant values used in reading and writing serialized objects - Copyright (C) 1998, 1999, 2003 Free Software Foundation, Inc. + Copyright (C) 1998, 1999, 2003, 2006 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -45,11 +45,29 @@ * <code>ObjectInputStream</code>, and <code>ObjectStreamClass</code>. * The values for these constants are specified by the Java library * specification. + * + * @since 1.1 */ public interface ObjectStreamConstants { // FIXME: Javadoc comment these values. + + /** + * The serialization stream protocol version 1. This version was + * the default serialization protocol before JDK 1.2. + * + * @see ObjectOutputStream#useProtocolVersion(int) + * @since 1.2 + */ int PROTOCOL_VERSION_1 = 1; + + /** + * The serialization stream protocol version 2. This version is + * used as the default serialization protocol since JDK 1.2. + * + * @see ObjectOutputStream#useProtocolVersion(int) + * @since 1.2 + */ int PROTOCOL_VERSION_2 = 2; short STREAM_MAGIC = (short)0xaced;