classpath
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] Serialization #3


From: Guilhem Lavaux
Subject: [PATCH] Serialization #3
Date: Wed, 26 Nov 2003 22:07:27 +0100
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.4) Gecko/20030630

This the patch number 3. It adds a few methods to java.io.ObjectStreamField: they will become necessary for the next patches that will follow tomorrow. BTW, it fixes the behaviour of a constructor which should throw a NullPointerException according to JDK's behaviour but was not in classpath's.

I will add the documentation on time. But you may understand that it's a nightmare to separate all portions of code as they've been written in one pass. BTW, I will also build some additionnal Mauve tests to import kaffe's tests.

Cheers,
Guilhem.

ChangeLog:

2003-26-11  Guilhem Lavaux <address@hidden>

        * java/io/ObjectStreamField.java: A few methods were added in prevision 
of the
upcoming upgrade of the serialization code. (ObjectStreamField): We should throw a NullPointerException when 'name' is null.
Index: ObjectStreamField.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/io/ObjectStreamField.java,v
retrieving revision 1.10
diff -u -r1.10 ObjectStreamField.java
--- ObjectStreamField.java      21 Jun 2003 11:43:41 -0000      1.10
+++ ObjectStreamField.java      26 Nov 2003 20:49:34 -0000
@@ -48,7 +48,9 @@
   private String typename;
   private int offset = -1; // XXX make sure this is correct
   private boolean unshared;
-  
+  private boolean persistent = false;
+  private boolean toset = true;
+
   public ObjectStreamField (String name, Class type)
   {
     this (name, type, false);
@@ -56,6 +58,9 @@
 
   public ObjectStreamField (String name, Class type, boolean unshared)
   {
+    if (name == null)
+      throw new NullPointerException();
+
     this.name = name;
     this.type = type;
     this.typename = TypeSignature.getEncodingOfClass(type);
@@ -79,6 +84,19 @@
         type = Object.class; //FIXME: ???
       }
   }
+
+  ObjectStreamField (String name, String typename, ClassLoader loader){
+    this.name = name;
+    this.typename = typename;
+    try
+      {
+        type = TypeSignature.getClassForEncoding(typename, true, loader);
+      }
+    catch(ClassNotFoundException e)
+      {
+        type = Object.class; // ALSO FIXME 
+      }
+  }
   
   public String getName ()
   {
@@ -98,6 +116,8 @@
   public String getTypeString ()
   {
     // use intern()
+    if (this.type.isPrimitive())
+      return null;
     return typename.intern();
   }
 
@@ -134,6 +154,26 @@
       return 1;
 
     return getName ().compareTo (f.getName ());
+  }
+
+  protected void setPersistent(boolean persistent)
+  {
+    this.persistent = persistent;
+  }
+
+  protected boolean isPersistent()
+  {
+    return persistent;
+  }
+
+  protected void setToSet(boolean toset)
+  {
+    this.toset = toset;
+  }
+
+  protected boolean isToSet()
+  {
+    return toset;
   }
 
   public String toString ()

reply via email to

[Prev in Thread] Current Thread [Next in Thread]