diff options
Diffstat (limited to 'libjava/classpath/java/io/ObjectOutputStream.java')
-rw-r--r-- | libjava/classpath/java/io/ObjectOutputStream.java | 60 |
1 files changed, 22 insertions, 38 deletions
diff --git a/libjava/classpath/java/io/ObjectOutputStream.java b/libjava/classpath/java/io/ObjectOutputStream.java index 55a12e4eae8..61f07bc7cfb 100644 --- a/libjava/classpath/java/io/ObjectOutputStream.java +++ b/libjava/classpath/java/io/ObjectOutputStream.java @@ -549,53 +549,37 @@ public class ObjectOutputStream extends OutputStream * 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 |