I'm committing the attached patch which allows enumerations to be
deserialized.  I've tested this using an enum instance serialized
by Sun's VM (so it works from Sun-->Classpath).  Serialization to follow.
Unfortunately, deserialization needs Enum.valueOf() so it's not available
for anything but the branch.

Changelog:

2006-03-29  Andrew John Hughes  <[EMAIL PROTECTED]>

        * java/io/ObjectInputStream.java:
        (parseContent(byte)): Added enum support.
        * java/io/ObjectStreamConstants.java:
        (TC_ENUM): Added.
        (TC_MAX): Changed to new maximum, TC_ENUM.

-- 
Andrew :-)

Please avoid sending me Microsoft Office (e.g. Word, PowerPoint) attachments.
See http://www.fsf.org/philosophy/no-word-attachments.html

If you use Microsoft Office, support movement towards the end of vendor lock-in:
http://opendocumentfellowship.org/petition/

"Value your freedom, or you will lose it, teaches history. 
`Don't bother us with politics' respond those who don't want to learn." 
-- Richard Stallman

Escape the Java Trap with GNU Classpath!
http://www.gnu.org/philosophy/java-trap.html
public class gcj extends Freedom implements Java { ... }
Index: java/io/ObjectInputStream.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/io/ObjectInputStream.java,v
retrieving revision 1.43.2.22
diff -u -3 -p -u -r1.43.2.22 ObjectInputStream.java
--- java/io/ObjectInputStream.java      2 Mar 2006 09:33:57 -0000       
1.43.2.22
+++ java/io/ObjectInputStream.java      29 Mar 2006 21:29:20 -0000
@@ -432,7 +432,23 @@ public class ObjectInputStream extends I
          clearHandles();
          throw new WriteAbortedException("Exception thrown during writing of 
stream", e);
        }
-       
+
+       case TC_ENUM:
+        {
+          /* TC_ENUM classDesc newHandle enumConstantName */
+          if (dump)
+            dumpElementln("ENUM=");
+          ObjectStreamClass osc = (ObjectStreamClass) readObject();
+          String constantName = (String) readObject();
+          if (dump)
+            dumpElementln("CONSTANT NAME = " + constantName);
+          Class clazz = osc.forClass();
+          Enum instance = Enum.valueOf(clazz, constantName);
+          assignNewHandle(instance);
+          ret_val = instance;
+          break;
+        }
+
        default:
        throw new IOException("Unknown marker on stream: " + marker);
       }
Index: java/io/ObjectStreamConstants.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/io/ObjectStreamConstants.java,v
retrieving revision 1.12.2.2
diff -u -3 -p -u -r1.12.2.2 ObjectStreamConstants.java
--- java/io/ObjectStreamConstants.java  26 Mar 2006 20:08:16 -0000      1.12.2.2
+++ java/io/ObjectStreamConstants.java  29 Mar 2006 21:29:20 -0000
@@ -87,9 +87,10 @@ public interface ObjectStreamConstants
   byte TC_EXCEPTION = (byte)123;       //0x7B
   byte TC_LONGSTRING = (byte)124;      //0x7C
   byte TC_PROXYCLASSDESC = (byte)125;  //0x7D
+  byte TC_ENUM = (byte)126;            //0x7E
 
   byte TC_BASE = TC_NULL;
-  byte TC_MAX = TC_PROXYCLASSDESC;
+  byte TC_MAX = TC_ENUM;
 
   int baseWireHandle = 0x7e0000;
 

Attachment: signature.asc
Description: Digital signature

Reply via email to