From 60b7365f52d635016272d4622b0c8a3df30205c8 Mon Sep 17 00:00:00 2001 From: Bryce McKinlay Date: Sat, 27 Jan 2001 06:04:29 +0000 Subject: ObjectInputStream.java (read): AND byte with 0xff to make result unsigned. * java/io/ObjectInputStream.java (read): AND byte with 0xff to make result unsigned. (read (byte[], int, int)): Only call readNextBlock() if the block buffer would actually be overrun. Increment blockDataPosition. (callReadMethod): Propagate exceptions from invocation target. * java/io/ObjectOutputStream.java (callWriteMethod): Propagate exceptions from invocation target. From-SVN: r39293 --- libjava/java/io/ObjectInputStream.java | 29 ++++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-) (limited to 'libjava/java/io/ObjectInputStream.java') diff --git a/libjava/java/io/ObjectInputStream.java b/libjava/java/io/ObjectInputStream.java index 595e9de..9c10d58 100644 --- a/libjava/java/io/ObjectInputStream.java +++ b/libjava/java/io/ObjectInputStream.java @@ -577,21 +577,23 @@ public class ObjectInputStream extends InputStream { if (this.blockDataPosition >= this.blockDataBytes) readNextBlock (); - return this.blockData[this.blockDataPosition++]; + return (this.blockData[this.blockDataPosition++] & 0xff); } else return this.realInputStream.read (); } - public int read (byte data[], int offset, int length) throws IOException + public int read (byte[] data, int offset, int length) throws IOException { if (this.readDataFromBlock) { - if (this.blockDataPosition + length >= this.blockDataBytes) + if (this.blockDataPosition + length > this.blockDataBytes) readNextBlock (); System.arraycopy (this.blockData, this.blockDataPosition, data, offset, length); + blockDataPosition += length; + return length; } else @@ -1359,16 +1361,29 @@ public class ObjectInputStream extends InputStream { try { - Class classArgs[] = {Class.forName ("java.io.ObjectInputStream")}; + Class classArgs[] = {ObjectInputStream.class}; Method m = getMethod (klass, "readObject", classArgs); if (m == null) return; Object args[] = {this}; - m.invoke (obj, args); + m.invoke (obj, args); } - catch (Exception _) + catch (InvocationTargetException x) + { + /* Rethrow if possible. */ + Throwable exception = x.getTargetException(); + if (exception instanceof RuntimeException) + throw (RuntimeException) exception; + if (exception instanceof IOException) + throw (IOException) exception; + + throw new IOException ("Exception thrown from readObject() on " + + klass + ": " + exception.getClass().getName()); + } + catch (Exception x) { - throw new IOException (); + throw new IOException ("Failure invoking readObject() on " + + klass + ": " + x.getClass().getName()); } } -- cgit v1.1