summaryrefslogtreecommitdiff
path: root/libjava/java/io/ObjectInputStream.java
diff options
context:
space:
mode:
authorMichael Koch <konqueror@gmx.de>2003-06-25 06:31:59 +0000
committerMichael Koch <mkoch@gcc.gnu.org>2003-06-25 06:31:59 +0000
commit3cc9a95d27f700508a686b8414dcffff9b4d75e9 (patch)
tree0604196de2a75326b3e65189f1592275cda74cb8 /libjava/java/io/ObjectInputStream.java
parent55a5d1f7142fcb3e5cfad518b987c20d441e78cd (diff)
downloadgcc-3cc9a95d27f700508a686b8414dcffff9b4d75e9.tar.gz
2003-06-25 Michael Koch <konqueror@gmx.de>
* java/io/ObjectInputStream.java (readClassDescriptor): New method. (readObject): Moved functionality to readClassDescriptor(). * java/io/ObjectOutputStream.java (writeClassDescriptor): New method. (writeObject): Moved functionality to writeClassDescriptor(). From-SVN: r68465
Diffstat (limited to 'libjava/java/io/ObjectInputStream.java')
-rw-r--r--libjava/java/io/ObjectInputStream.java84
1 files changed, 46 insertions, 38 deletions
diff --git a/libjava/java/io/ObjectInputStream.java b/libjava/java/io/ObjectInputStream.java
index e3e2412967f..ef79727c1e1 100644
--- a/libjava/java/io/ObjectInputStream.java
+++ b/libjava/java/io/ObjectInputStream.java
@@ -219,44 +219,7 @@ public class ObjectInputStream extends InputStream
case TC_CLASSDESC:
{
- dumpElement ("CLASSDESC NAME=");
- String name = this.realInputStream.readUTF ();
- dumpElement (name + "; UID=");
- long uid = this.realInputStream.readLong ();
- dumpElement (Long.toHexString(uid) + "; FLAGS=");
- byte flags = this.realInputStream.readByte ();
- dumpElement (Integer.toHexString(flags) + "; FIELD COUNT=");
- short field_count = this.realInputStream.readShort ();
- dumpElementln (Short.toString(field_count));
- ObjectStreamField[] fields = new ObjectStreamField[field_count];
- ObjectStreamClass osc = new ObjectStreamClass (name, uid,
- flags, fields);
- assignNewHandle (osc);
-
- for (int i=0; i < field_count; i++)
- {
- dumpElement (" TYPE CODE=");
- char type_code = (char)this.realInputStream.readByte ();
- dumpElement (type_code + "; FIELD NAME=");
- String field_name = this.realInputStream.readUTF ();
- dumpElementln (field_name);
- String class_name;
-
- if (type_code == 'L' || type_code == '[')
- class_name = (String)readObject ();
- else
- class_name = String.valueOf (type_code);
-
- // There're many cases you can't get java.lang.Class from
- // typename if your context class loader can't load it,
- // then use typename to construct the field
- fields[i] =
- new ObjectStreamField (field_name, class_name);
- }
-
- boolean oldmode = setBlockDataMode (true);
- osc.setClass (resolveClass (osc));
- setBlockDataMode (oldmode);
+ ObjectStreamClass osc = readClassDescriptor ();
if (!is_consumed)
{
@@ -451,6 +414,51 @@ public class ObjectInputStream extends InputStream
return ret_val;
}
+ protected ObjectStreamClass readClassDescriptor ()
+ throws ClassNotFoundException, IOException
+ {
+ dumpElement ("CLASSDESC NAME=");
+ String name = this.realInputStream.readUTF ();
+ dumpElement (name + "; UID=");
+ long uid = this.realInputStream.readLong ();
+ dumpElement (Long.toHexString(uid) + "; FLAGS=");
+ byte flags = this.realInputStream.readByte ();
+ dumpElement (Integer.toHexString(flags) + "; FIELD COUNT=");
+ short field_count = this.realInputStream.readShort ();
+ dumpElementln (Short.toString(field_count));
+ ObjectStreamField[] fields = new ObjectStreamField[field_count];
+ ObjectStreamClass osc = new ObjectStreamClass (name, uid,
+ flags, fields);
+ assignNewHandle (osc);
+
+ for (int i=0; i < field_count; i++)
+ {
+ dumpElement (" TYPE CODE=");
+ char type_code = (char)this.realInputStream.readByte ();
+ dumpElement (type_code + "; FIELD NAME=");
+ String field_name = this.realInputStream.readUTF ();
+ dumpElementln (field_name);
+ String class_name;
+
+ if (type_code == 'L' || type_code == '[')
+ class_name = (String)readObject ();
+ else
+ class_name = String.valueOf (type_code);
+
+ // There're many cases you can't get java.lang.Class from
+ // typename if your context class loader can't load it,
+ // then use typename to construct the field
+ fields[i] =
+ new ObjectStreamField (field_name, class_name);
+ }
+
+ boolean oldmode = setBlockDataMode (true);
+ osc.setClass (resolveClass (osc));
+ setBlockDataMode (oldmode);
+
+ return osc;
+ }
+
/**
* Reads the current objects non-transient, non-static fields from
* the current class from the underlying output stream.