From bba0d25ba5ddb9625525d582a5849b31023d664d Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Tue, 29 Oct 2013 22:28:22 -0500 Subject: [PATCH] ObjectInputStream: handle fields of type String Signed-off-by: Johannes Schindelin --- classpath/java/io/ObjectInputStream.java | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/classpath/java/io/ObjectInputStream.java b/classpath/java/io/ObjectInputStream.java index fe301a6c7f..796d6745d9 100644 --- a/classpath/java/io/ObjectInputStream.java +++ b/classpath/java/io/ObjectInputStream.java @@ -278,7 +278,20 @@ public class ObjectInputStream extends InputStream implements DataInput { } public Object readObject() throws IOException, ClassNotFoundException { - expectToken(TC_OBJECT); + int c = rawByte(); + if (c == TC_NULL) { + return null; + } + if (c == TC_STRING) { + int length = rawShort(); + byte[] bytes = new byte[length]; + readFully(bytes); + return new String(bytes, "UTF-8"); + } + if (c != TC_OBJECT) { + throw new IOException("Unexpected token: 0x" + + Integer.toHexString(c)); + } // class desc expectToken(TC_CLASSDESC);