diff options
Diffstat (limited to 'libjava/classpath/java/io')
-rw-r--r-- | libjava/classpath/java/io/InputStream.java | 4 | ||||
-rw-r--r-- | libjava/classpath/java/io/InputStreamReader.java | 20 | ||||
-rw-r--r-- | libjava/classpath/java/io/ObjectInputStream.java | 19 | ||||
-rw-r--r-- | libjava/classpath/java/io/ObjectOutputStream.java | 4 |
4 files changed, 32 insertions, 15 deletions
diff --git a/libjava/classpath/java/io/InputStream.java b/libjava/classpath/java/io/InputStream.java index 86d1cd7..e56197a 100644 --- a/libjava/classpath/java/io/InputStream.java +++ b/libjava/classpath/java/io/InputStream.java @@ -193,10 +193,8 @@ public abstract class InputStream */ public int read(byte[] b, int off, int len) throws IOException { - if (off < 0 || len < 0 || off + len > b.length) + if (off < 0 || len < 0 || b.length - off < len) throw new IndexOutOfBoundsException(); - if (b.length == 0) - return 0; int i, ch; diff --git a/libjava/classpath/java/io/InputStreamReader.java b/libjava/classpath/java/io/InputStreamReader.java index ef8fd45..936a03c 100644 --- a/libjava/classpath/java/io/InputStreamReader.java +++ b/libjava/classpath/java/io/InputStreamReader.java @@ -1,5 +1,6 @@ /* InputStreamReader.java -- Reader than transforms bytes to chars - Copyright (C) 1998, 1999, 2001, 2003, 2004, 2005 Free Software Foundation, Inc. + Copyright (C) 1998, 1999, 2001, 2003, 2004, 2005, 2006 + Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -38,6 +39,7 @@ exception statement from your version. */ package java.io; +import gnu.classpath.SystemProperties; import gnu.java.nio.charset.EncodingHelper; import java.nio.ByteBuffer; @@ -145,7 +147,7 @@ public class InputStreamReader extends Reader this.in = in; try { - encoding = System.getProperty("file.encoding"); + encoding = SystemProperties.getProperty("file.encoding"); // Don't use NIO if avoidable if(EncodingHelper.isISOLatin1(encoding)) { @@ -231,12 +233,20 @@ public class InputStreamReader extends Reader * charset to decode the bytes in the InputStream into * characters. * - * @since 1.5 + * @since 1.4 */ public InputStreamReader(InputStream in, Charset charset) { + if (in == null) + throw new NullPointerException(); this.in = in; decoder = charset.newDecoder(); + try { + maxBytesPerChar = charset.newEncoder().maxBytesPerChar(); + } catch(UnsupportedOperationException _){ + maxBytesPerChar = 1f; + } + decoder.onMalformedInput(CodingErrorAction.REPLACE); decoder.onUnmappableCharacter(CodingErrorAction.REPLACE); decoder.reset(); @@ -247,9 +257,11 @@ public class InputStreamReader extends Reader * Creates an InputStreamReader that uses the given charset decoder * to decode the bytes in the InputStream into characters. * - * @since 1.5 + * @since 1.4 */ public InputStreamReader(InputStream in, CharsetDecoder decoder) { + if (in == null) + throw new NullPointerException(); this.in = in; this.decoder = decoder; diff --git a/libjava/classpath/java/io/ObjectInputStream.java b/libjava/classpath/java/io/ObjectInputStream.java index 750c698..91832f9 100644 --- a/libjava/classpath/java/io/ObjectInputStream.java +++ b/libjava/classpath/java/io/ObjectInputStream.java @@ -1,5 +1,5 @@ /* ObjectInputStream.java -- Class used to read serialized objects - Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2005 + Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2005, 2006 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -555,8 +555,7 @@ public class ObjectInputStream extends InputStream classLookupTable.put(clazz, osc); setBlockDataMode(oldmode); - // find the first non-serializable, non-abstract - // class in clazz's inheritance hierarchy + // find the first non-serializable class in clazz's inheritance hierarchy Class first_nonserial = clazz.getSuperclass(); // Maybe it is a primitive class, those don't have a super class, // or Object itself. Otherwise we can keep getting the superclass @@ -565,9 +564,8 @@ public class ObjectInputStream extends InputStream if (first_nonserial == null) first_nonserial = clazz; else - while (Serializable.class.isAssignableFrom(first_nonserial) - || Modifier.isAbstract(first_nonserial.getModifiers())) - first_nonserial = first_nonserial.getSuperclass(); + while (Serializable.class.isAssignableFrom(first_nonserial)) + first_nonserial = first_nonserial.getSuperclass(); final Class local_constructor_class = first_nonserial; @@ -1596,7 +1594,14 @@ public class ObjectInputStream extends InputStream private void readNextBlock() throws IOException { - readNextBlock(this.realInputStream.readByte()); + byte marker = this.realInputStream.readByte(); + while (marker == TC_RESET) + { + if(dump) dumpElementln("RESET"); + clearHandles(); + marker = this.realInputStream.readByte(); + } + readNextBlock(marker); } private void readNextBlock(byte marker) throws IOException diff --git a/libjava/classpath/java/io/ObjectOutputStream.java b/libjava/classpath/java/io/ObjectOutputStream.java index 961d5e3..55a12e4 100644 --- a/libjava/classpath/java/io/ObjectOutputStream.java +++ b/libjava/classpath/java/io/ObjectOutputStream.java @@ -1,5 +1,5 @@ /* ObjectOutputStream.java -- Class used to write serialized objects - Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005 + Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -421,6 +421,8 @@ public class ObjectOutputStream extends OutputStream for (int i = 0; i < intfs.length; i++) realOutput.writeUTF(intfs[i].getName()); + assignNewHandle(osc); + boolean oldmode = setBlockDataMode(true); annotateProxyClass(osc.forClass()); setBlockDataMode(oldmode); |