[kaffe] CVS kaffe (guilhem): Synchronization with classpath. Importer file/Handler from gcj.

Kaffe CVS cvs-commits at kaffe.org
Wed Dec 31 01:39:02 PST 2003


PatchSet 4250 
Date: 2003/12/31 09:32:15
Author: guilhem
Branch: HEAD
Tag: (none) 
Log:
Synchronization with classpath. Importer file/Handler from gcj.

Members: 
	ChangeLog:1.1837->1.1838 
	libraries/javalib/gnu/java/net/protocol/file/Handler.java:1.2->1.3 
	libraries/javalib/gnu/java/net/protocol/http/Connection.java:1.5->1.6 
	libraries/javalib/java/io/ObjectStreamClass.java:1.16->1.17 
	libraries/javalib/java/net/URLConnection.java:1.13->1.14 
	libraries/javalib/java/text/CollationElementIterator.java:1.10->1.11 
	libraries/javalib/java/text/RuleBasedCollator.java:1.15->1.16 

Index: kaffe/ChangeLog
diff -u kaffe/ChangeLog:1.1837 kaffe/ChangeLog:1.1838
--- kaffe/ChangeLog:1.1837	Wed Dec 31 09:14:18 2003
+++ kaffe/ChangeLog	Wed Dec 31 09:32:15 2003
@@ -1,4 +1,16 @@
 2003-12-31  Guilhem Lavaux <guilhem at kaffe.org>
+
+	* libraries/javlaib/java/io/ObjectStreamClass.java,
+	libraries/javalib/gnu/java/net/protocol/http/Connection.java,
+	libraries/javalib/java/net/URLConnection.java:
+	Synchronized with Classpath.
+
+	* libraries/javalib/gnu/java/net/protocol/file/Handler.java:
+	Taken from GCJ. Complexity greatly reduced and fix many mauve failures.
+
+	* 
+	
+2003-12-31  Guilhem Lavaux <guilhem at kaffe.org>
 	
 	* libraries/javalib/java/io/File.java: Merged case insensitivity
 	from classpath.
Index: kaffe/libraries/javalib/gnu/java/net/protocol/file/Handler.java
diff -u kaffe/libraries/javalib/gnu/java/net/protocol/file/Handler.java:1.2 kaffe/libraries/javalib/gnu/java/net/protocol/file/Handler.java:1.3
--- kaffe/libraries/javalib/gnu/java/net/protocol/file/Handler.java:1.2	Wed Dec  3 20:33:39 2003
+++ kaffe/libraries/javalib/gnu/java/net/protocol/file/Handler.java	Wed Dec 31 09:32:16 2003
@@ -37,7 +37,6 @@
 
 package gnu.java.net.protocol.file;
 
-import gnu.java.io.PlatformHelper;
 import java.io.IOException;
 import java.net.URL;
 import java.net.URLConnection;
@@ -91,245 +90,5 @@
       }
 
     return new Connection(url);
-  }
-
-  /**
-   * This method overrides URLStreamHandler's for parsing url of protocol "file"
-   *
-   * @param url The URL object in which to store the results
-   * @param url_string The String-ized URL to parse
-   * @param start The position in the string to start scanning from
-   * @param end The position in the string to stop scanning
-   */
-  protected void parseURL (URL url, String url_string, int start, int end)
-  {
-    // This method does not throw an exception or return a value.  Thus our
-    // strategy when we encounter an error in parsing is to return without
-    // doing anything.
-
-    // Bunches of things should be true.  Make sure.
-    if (end < start)
-        return;
-    if (end - start < 2)
-        return;
-    if (start > url_string.length())
-        return;
-    if (end > url_string.length())
-        end = url_string.length(); // This should be safe
-    
-    // Turn end into an offset from the end of the string instead of 
-    // the beginning
-    end = url_string.length() - end;
-    
-    // Skip remains of protocol
-    url_string = url_string.substring (start);
-    
-    if ( !url.getProtocol().equals ("file"))
-      return;
-    
-    // Normalize the file separator
-    url_string = url_string.replace
-      (System.getProperty ("file.separator").charAt (0), '/');
-    
-    // Deal with the case: file:///d|/dir/dir/file and file:///d%7C/dir/dir/file
-    url_string = url_string.replace ('|', ':');
-    int i;
-    
-    if ((i = url_string.toUpperCase().indexOf ("%7C")) >= 0)
-      url_string = url_string.substring (0, i) + ":" + url_string.substring (i + 3);
-
-    boolean needContext = url.getFile() != null;
-    // Skip the leading "//"
-    if (url_string.startsWith ("//"))
-      {
-        url_string = url_string.substring (2);
-        needContext = false;
-      }
-
-    // Declare some variables
-    String host = null;
-    int port = -1;
-    String file = null;
-    String anchor = null;
-    String prefix = "/";  //root path prefix of a file: could be "/", and for some windows file: "drive:/"
-    
-    if (!needContext)
-      {
-        boolean hostpart = true; //whether host part presents
-        
-        // Deal with the UNC case: //server/file
-        if (url_string.startsWith ("//"))
-          {
-            hostpart = true;
-            url_string = url_string.substring (2);
-          }
-        else
-          {
-            // If encounter another "/", it's end of a null host part or beginning of root path 
-            if (url_string.startsWith ("/"))
-              {
-                hostpart = false;
-                // url_string = url_string.substring (1);
-              }
-          }
-        
-        // If another "/" or "drive:/" or "drive:\\" encounters, 
-        if ((i = PlatformHelper.beginWithRootPathPrefix (url_string)) > 0)
-          {
-            hostpart = false;
-            // Skip root path prefix
-            prefix = url_string.substring (0, i);
-            url_string = url_string.substring(i);
-          }
-        
-        if (hostpart)
-          {
-            // Process host and port
-            int slash_index = url_string.indexOf ("/");
-            int colon_index = url_string.indexOf (":");
-        
-            if (slash_index > (url_string.length() - end))
-              return;
-            else if (slash_index == -1)
-              slash_index = url_string.length() - end;
-        
-            if ((colon_index == -1)
-                || (colon_index > slash_index))
-              {
-                host = url_string.substring (0, slash_index);
-              }
-            else
-              {
-                host = url_string.substring (0, colon_index);
-                String port_str = url_string.substring (colon_index + 1,
-                                                        slash_index);
-
-                try
-                  {
-                    port = Integer.parseInt(port_str);
-                  }
-                catch (NumberFormatException e)
-                  {
-                    return;
-                  }
-              }
-            
-            if (slash_index < (url_string.length() - 1))
-              url_string = url_string.substring (slash_index + 1);
-            else
-              url_string = "";
-          }
-      }
-    
-    // Process file and anchor 
-    if (needContext)
-      {
-        host = url.getHost();
-        port = url.getPort();
-
-        if ((i = PlatformHelper.beginWithRootPathPrefix (url_string)) > 0)
-          { //url string is an absolute path
-            file = url.getFile();
-            int j = PlatformHelper.beginWithRootPathPrefix (file);
-
-            if (j >= i)
-              file = file.substring (0, j) + url_string.substring (i);
-            else
-              file = url_string;
-          }
-        else
-          {
-            file = url.getFile();
-
-            /*
-            // Is the following necessary?
-            java.io.File f = new java.io.File(file);
-            if(f.isDirectory() && !PlatformHelper.endWithSeparator(file)){
-                file += "/";
-            }
-            */
-            
-            int idx = file.lastIndexOf ("/");  
-
-            if (idx == -1) //context path is weird
-              file = "/" + url_string; 
-            else if (idx == (file.length() - 1))
-              //just concatenate two parts
-              file = file + url_string;
-            else
-              file = file.substring (0, idx + 1) + url_string;
-          }
-      }
-    else
-      file = prefix + url_string;  
-        
-    if (end == 0)
-      {
-        anchor = null;
-      }
-    else
-      {
-        // Only set anchor if end char is a '#'.  Otherwise assume we're
-        // just supposed to stop scanning for some reason
-        if (file.charAt (file.length() - end) == '#')
-          {
-            int len = file.length();
-            anchor = file.substring ( len - end + 1, len);
-            file = file.substring (0, len - end);
-          }
-        else
-          anchor = null;
-      }
-    
-    file = PlatformHelper.toCanonicalForm (file, '/');
-
-    if (host == null)
-      {
-        host = "";
-      }
-
-    // Now set the values
-    setURL (url, url.getProtocol(), host, port, file, anchor); 
-  }
-
-  /**
-   * This method overrides URLStreamHandler's as a specialized 
-   * and more efficient toExternalForm 
-   *
-   * @param url The URL object whose external form will be returned 
-   */
-  protected String toExternalForm (URL url)
-  { 
-    StringBuffer sb = new StringBuffer (PlatformHelper.INITIAL_MAX_PATH);
-    sb.append ("file:");
-    String prefix = url.getHost();
-
-    if (prefix != null
-        && prefix.length() > 0)
-      {
-        sb.append (prefix);
-        int port = url.getPort();
-        
-        if (port > 0)
-          {
-            sb.append (':');
-            sb.append (port);
-          }
-      }
-    
-    String file = url.getFile();
-    if (file != null)
-      sb.append (file);
-    else
-      sb.append ('/');
-    
-    String anchor = url.getRef();
-    if (anchor != null)
-      {
-        sb.append ('#');
-        sb.append (anchor);
-      }
-    
-    return sb.toString();
   }
 } // class Handler
Index: kaffe/libraries/javalib/gnu/java/net/protocol/http/Connection.java
diff -u kaffe/libraries/javalib/gnu/java/net/protocol/http/Connection.java:1.5 kaffe/libraries/javalib/gnu/java/net/protocol/http/Connection.java:1.6
--- kaffe/libraries/javalib/gnu/java/net/protocol/http/Connection.java:1.5	Mon Dec 29 11:15:16 2003
+++ kaffe/libraries/javalib/gnu/java/net/protocol/http/Connection.java	Wed Dec 31 09:32:17 2003
@@ -52,6 +52,7 @@
 import java.net.Socket;
 import java.net.URL;
 import java.net.URLConnection;
+import java.util.HashMap;
 import java.util.Iterator;
 import java.util.Map;
 import gnu.java.net.HeaderFieldHelper;
@@ -119,6 +120,11 @@
   private ByteArrayOutputStream bufferedOutputStream;
 
   /**
+   * This object holds the request properties.
+   */
+  private HashMap requestProperties = new HashMap();
+
+  /**
    * This is the object that holds the header field information
    */
   private HeaderFieldHelper headers = new HeaderFieldHelper();
@@ -408,6 +414,41 @@
     else
       throw new ProtocolException ("Unsupported or unknown request method " +
                                    method);
+  }
+
+  public void addRequestProperty(String key, String value)
+  {
+    if (connected)
+      throw new IllegalStateException("Already connected");
+    
+    String old = (String) requestProperties.put(key, value);
+
+    if (old != null)
+      requestProperties.put(key, old + "," + value);
+  }
+
+  public String getRequestProperty(String key)
+  {
+    if (connected)
+      throw new IllegalStateException("Already connected");
+    
+    return (String) requestProperties.get(key);
+  }
+
+  public void setRequestProperty(String key, String value)
+  {
+    if (connected)
+      throw new IllegalStateException("Already connected");
+    
+    requestProperties.put(key, value);
+  }
+
+  public Map getRequestProperties()
+  {
+    if (connected)
+      throw new IllegalStateException("Already connected");
+    
+    return requestProperties;
   }
 
   public String getHeaderField(String name)
Index: kaffe/libraries/javalib/java/io/ObjectStreamClass.java
diff -u kaffe/libraries/javalib/java/io/ObjectStreamClass.java:1.16 kaffe/libraries/javalib/java/io/ObjectStreamClass.java:1.17
--- kaffe/libraries/javalib/java/io/ObjectStreamClass.java:1.16	Sun Dec 14 09:26:56 2003
+++ kaffe/libraries/javalib/java/io/ObjectStreamClass.java	Wed Dec 31 09:32:17 2003
@@ -2,39 +2,39 @@
    about serialized objects.
    Copyright (C) 1998, 1999, 2000, 2001, 2003  Free Software Foundation, Inc.
 
-This file is part of GNU Classpath.
+   This file is part of GNU Classpath.
 
-GNU Classpath is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2, or (at your option)
-any later version.
+   GNU Classpath is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 2, or (at your option)
+   any later version.
  
-GNU Classpath is distributed in the hope that it will be useful, but
-WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU Classpath; see the file COPYING.  If not, write to the
-Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 USA.
-
-Linking this library statically or dynamically with other modules is
-making a combined work based on this library.  Thus, the terms and
-conditions of the GNU General Public License cover the whole
-combination.
-
-As a special exception, the copyright holders of this library give you
-permission to link this library with independent modules to produce an
-executable, regardless of the license terms of these independent
-modules, and to copy and distribute the resulting executable under
-terms of your choice, provided that you also meet, for each linked
-independent module, the terms and conditions of the license of that
-module.  An independent module is a module which is not derived from
-or based on this library.  If you modify this library, you may extend
-this exception to your version of the library, but you are not
-obligated to do so.  If you do not wish to do so, delete this
-exception statement from your version. */
+   GNU Classpath is distributed in the hope that it will be useful, but
+   WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with GNU Classpath; see the file COPYING.  If not, write to the
+   Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.
+
+   Linking this library statically or dynamically with other modules is
+   making a combined work based on this library.  Thus, the terms and
+   conditions of the GNU General Public License cover the whole
+   combination.
+
+   As a special exception, the copyright holders of this library give you
+   permission to link this library with independent modules to produce an
+   executable, regardless of the license terms of these independent
+   modules, and to copy and distribute the resulting executable under
+   terms of your choice, provided that you also meet, for each linked
+   independent module, the terms and conditions of the license of that
+   module.  An independent module is a module which is not derived from
+   or based on this library.  If you modify this library, you may extend
+   this exception to your version of the library, but you are not
+   obligated to do so.  If you do not wish to do so, delete this
+   exception statement from your version. */
 
 
 package java.io;
@@ -55,29 +55,29 @@
 import java.util.Vector;
 import gnu.java.io.NullOutputStream;
 import gnu.java.lang.reflect.TypeSignature;
-//import gnu.java.security.provider.Gnu;
+import gnu.java.security.provider.Gnu;
 
 
 public class ObjectStreamClass implements Serializable
 {
   /**
-     Returns the <code>ObjectStreamClass</code> for <code>cl</code>.
-     If <code>cl</code> is null, or is not <code>Serializable</code>,
-     null is returned.  <code>ObjectStreamClass</code>'s are memorized;
-     later calls to this method with the same class will return the
-     same <code>ObjectStreamClass</code> object and no recalculation
-     will be done.
-
-     @see java.io.Serializable
-  */
-  public static ObjectStreamClass lookup (Class cl)
+   * Returns the <code>ObjectStreamClass</code> for <code>cl</code>.
+   * If <code>cl</code> is null, or is not <code>Serializable</code>,
+   * null is returned.  <code>ObjectStreamClass</code>'s are memorized;
+   * later calls to this method with the same class will return the
+   * same <code>ObjectStreamClass</code> object and no recalculation
+   * will be done.
+   *
+   * @see java.io.Serializable
+   */
+  public static ObjectStreamClass lookup(Class cl)
   {
     if (cl == null)
       return null;
-    if (! (Serializable.class).isAssignableFrom (cl))
+    if (! (Serializable.class).isAssignableFrom(cl))
       return null;
 
-    return lookupForClassObject (cl);
+    return lookupForClassObject(cl);
   }
 
   /**
@@ -85,57 +85,57 @@
    * we have a java.lang.Class object C for class A, though A is not
    * serializable, but it's okay to serialize C.
    */
-  static ObjectStreamClass lookupForClassObject (Class cl)
+  static ObjectStreamClass lookupForClassObject(Class cl)
   {
     if (cl == null)
       return null;
 
-    ObjectStreamClass osc = (ObjectStreamClass)classLookupTable.get (cl);
+    ObjectStreamClass osc = (ObjectStreamClass) classLookupTable.get(cl);
 
     if (osc != null)
       return osc;
     else
-    {
-      osc = new ObjectStreamClass (cl);
-      classLookupTable.put (cl, osc);
-      return osc;
-    }
+      {
+	osc = new ObjectStreamClass(cl);
+	classLookupTable.put(cl, osc);
+	return osc;
+      }
   }
 
 
   /**
-     Returns the name of the class that this
-     <code>ObjectStreamClass</code> represents.
-  */
-  public String getName ()
+   * Returns the name of the class that this
+   * <code>ObjectStreamClass</code> represents.
+   */
+  public String getName()
   {
     return name;
   }
 
 
   /**
-     Returns the class that this <code>ObjectStreamClass</code>
-     represents.  Null could be returned if this
-     <code>ObjectStreamClass</code> was read from an
-     <code>ObjectInputStream</code> and the class it represents cannot
-     be found or loaded.
-
-     @see java.io.ObjectInputStream
-  */
-  public Class forClass ()
+   * Returns the class that this <code>ObjectStreamClass</code>
+   * represents.  Null could be returned if this
+   * <code>ObjectStreamClass</code> was read from an
+   * <code>ObjectInputStream</code> and the class it represents cannot
+   * be found or loaded.
+   *
+   * @see java.io.ObjectInputStream
+   */
+  public Class forClass()
   {
     return clazz;
   }
 
 
   /**
-     Returns the serial version stream-unique identifier for the class
-     represented by this <code>ObjectStreamClass</code>.  This SUID is
-     either defined by the class as <code>static final long
-     serialVersionUID</code> or is calculated as specified in
-     Javasoft's "Object Serialization Specification" XXX: add reference
-  */
-  public long getSerialVersionUID ()
+   * Returns the serial version stream-unique identifier for the class
+   * represented by this <code>ObjectStreamClass</code>.  This SUID is
+   * either defined by the class as <code>static final long
+   * serialVersionUID</code> or is calculated as specified in
+   * Javasoft's "Object Serialization Specification" XXX: add reference
+   */
+  public long getSerialVersionUID()
   {
     return uid;
   }
@@ -145,10 +145,10 @@
   // of the class represented by this ObjectStreamClass.  The Fields
   // are sorted by name.
   // XXX doc
-  public ObjectStreamField[] getFields ()
+  public ObjectStreamField[] getFields()
   {
     ObjectStreamField[] copy = new ObjectStreamField[ fields.length ];
-    System.arraycopy (fields, 0, copy, 0, fields.length);
+    System.arraycopy(fields, 0, copy, 0, fields.length);
     return copy;
   }
 
@@ -158,8 +158,8 @@
   // primitiveness.
   public ObjectStreamField getField (String name)
   {
-    for (int i=0; i < fields.length; i++)
-      if (fields[i].getName ().equals (name))
+    for (int i = 0; i < fields.length; i++)
+      if (fields[i].getName().equals(name))
 	return fields[i];
     return null;
   }
@@ -174,7 +174,7 @@
    * @see #getSerialVersionUID()
    * @see #getName()
    */
-  public String toString ()
+  public String toString()
   {
     return "java.io.ObjectStreamClass< " + name + ", " + uid + " >";
   }
@@ -187,7 +187,7 @@
   //
   // This method is used by the class to override default
   // serialization behavior.
-  boolean hasWriteMethod ()
+  boolean hasWriteMethod()
   {
     return (flags & ObjectStreamConstants.SC_WRITE_METHOD) != 0;
   }
@@ -200,24 +200,24 @@
   //
   // This method is used by the class to override default
   // serialization behavior.
-  boolean hasReadMethod ()
+  boolean hasReadMethod()
   {
-      try
+    try
       {
-	  Class[] readObjectParams = { ObjectInputStream.class };
-	  forClass ().getDeclaredMethod ("readObject", readObjectParams);
-	  return true;
+	Class[] readObjectParams = { ObjectInputStream.class };
+	forClass().getDeclaredMethod("readObject", readObjectParams);
+	return true;
       }
-      catch (NoSuchMethodException e)
+    catch (NoSuchMethodException e)
       {
-	  return false;
+	return false;
       }
   }
 
 
   // Returns true iff the class that this ObjectStreamClass represents
   // implements Serializable but does *not* implement Externalizable.
-  boolean isSerializable ()
+  boolean isSerializable()
   {
     return (flags & ObjectStreamConstants.SC_SERIALIZABLE) != 0;
   }
@@ -225,7 +225,7 @@
 
   // Returns true iff the class that this ObjectStreamClass represents
   // implements Externalizable.
-  boolean isExternalizable ()
+  boolean isExternalizable()
   {
     return (flags & ObjectStreamConstants.SC_EXTERNALIZABLE) != 0;
   }
@@ -235,7 +235,7 @@
   // class that is the superclass of the class this
   // <code>ObjectStreamClass</code> represents.  If the superclass is
   // not Serializable, null is returned.
-  ObjectStreamClass getSuper ()
+  ObjectStreamClass getSuper()
   {
     return superClass;
   }
@@ -245,30 +245,30 @@
   // classes of CLAZZ and CLAZZ itself in order from most super to
   // CLAZZ.  ObjectStreamClass[0] is the highest superclass of CLAZZ
   // that is serializable.
-  static ObjectStreamClass[] getObjectStreamClasses (Class clazz)
+  static ObjectStreamClass[] getObjectStreamClasses(Class clazz)
   {
-    ObjectStreamClass osc = ObjectStreamClass.lookup (clazz);
+    ObjectStreamClass osc = ObjectStreamClass.lookup(clazz);
 
     if (osc == null)
       return new ObjectStreamClass[0];
     else
-    {
-      Vector oscs = new Vector ();
-
-      while (osc != null)
       {
-	oscs.addElement (osc);
-	osc = osc.getSuper ();
-      }
+	Vector oscs = new Vector();
+
+	while (osc != null)
+	  {
+	    oscs.addElement (osc);
+	    osc = osc.getSuper();
+	  }
 
-      int count = oscs.size ();
-      ObjectStreamClass[] sorted_oscs = new ObjectStreamClass[ count ];
+	int count = oscs.size();
+	ObjectStreamClass[] sorted_oscs = new ObjectStreamClass[ count ];
 
-      for (int i = count - 1; i >= 0; i--)
-	sorted_oscs[ count - i - 1 ] = (ObjectStreamClass)oscs.elementAt (i);
+	for (int i = count - 1; i >= 0; i--)
+	  sorted_oscs[ count - i - 1 ] = (ObjectStreamClass) oscs.elementAt(i);
 
-      return sorted_oscs;
-    }
+	return sorted_oscs;
+      }
   }
 
 
@@ -276,14 +276,14 @@
   // properties of the class represented by this ObjectStreamClass.
   // The bit-flags that could be present are those defined in
   // ObjectStreamConstants that begin with `SC_'
-  int getFlags ()
+  int getFlags()
   {
     return flags;
   }
 
 
-  ObjectStreamClass (String name, long uid, byte flags,
-		     ObjectStreamField[] fields)
+  ObjectStreamClass(String name, long uid, byte flags,
+		    ObjectStreamField[] fields)
   {
     this.name = name;
     this.uid = uid;
@@ -302,11 +302,11 @@
    * @throws InvalidClassException if an incompatibility between computed UID and
    * already set UID is found.
    */
-  void setClass (Class cl, ObjectStreamClass superClass) throws InvalidClassException
+  void setClass(Class cl, ObjectStreamClass superClass) throws InvalidClassException
   {
     this.clazz = cl;
 
-    long class_uid = getClassUID (cl);
+    long class_uid = getClassUID(cl);
     if (uid == 0)
       uid = class_uid;
     else
@@ -322,9 +322,9 @@
 	  }
       }
 
-    isProxyClass = clazz != null && Proxy.isProxyClass (clazz);
+    isProxyClass = clazz != null && Proxy.isProxyClass(clazz);
     this.superClass = superClass;
-    calculateOffsets ();
+    calculateOffsets();
     
     try
       {
@@ -345,47 +345,47 @@
 
 	i = 0; j = 0; k = 0;
 	while (i < fields.length && j < exportedFields.length)
-	{
-	  int comp = fields[i].getName().compareTo (exportedFields[j].getName());
+	  {
+	    int comp = fields[i].getName().compareTo(exportedFields[j].getName());
+
+	    if (comp < 0)
+	      {
+		newFieldList[k] = fields[i];
+		fields[i].setPersistent(false);
+		fields[i].setToSet(false);
+		i++;
+	      }
+	    else if (comp > 0)
+	      {
+		/* field not found in imported fields. We add it
+		 * in the list of supported fields.
+		 */
+		newFieldList[k] = exportedFields[j];
+		newFieldList[k].setPersistent(true);
+		newFieldList[k].setToSet(false);
+		j++;
+	      }
+	    else
+	      {
+		if (!fields[i].getType().equals(exportedFields[j].getType()))
+		  throw new InvalidClassException
+		    ("serialPersistentFields must be compatible with" +
+		     " imported fields (about " + fields[i].getName() + ")");
+		newFieldList[k] = fields[i];
+		fields[i].setPersistent(true);
+		i++;
+		j++;
+	      }
+	    k++;
+	  }
 
-	  if (comp < 0)
+	if (i < fields.length)
+	  for (;i<fields.length;i++,k++)
 	    {
-	      newFieldList[k] = fields[i];
 	      fields[i].setPersistent(false);
 	      fields[i].setToSet(false);
-	      i++;
-	    }
-	  else if (comp > 0)
-	    {
-	      /* field not found in imported fields. We add it
-	       * in the list of supported fields.
-	       */
-	      newFieldList[k] = exportedFields[j];
-	      newFieldList[k].setPersistent(true);
-	      newFieldList[k].setToSet(false);
-	      j++;
-	    }
-	  else
-	    {
-	      if (!fields[i].getType().equals (exportedFields[j].getType()))
-		throw new InvalidClassException (
-			    "serialPersistentFields must be compatible with" +
-			    " imported fields (about " + fields[i].getName() + ")");
 	      newFieldList[k] = fields[i];
-	      fields[i].setPersistent(true);
-	      i++;
-	      j++;
 	    }
-	  k++;
-	}
-
-	if (i < fields.length)
-	  for (;i<fields.length;i++,k++)
-	  {
-	    fields[i].setPersistent(false);
-	    fields[i].setToSet(false);
-	    newFieldList[k] = fields[i];
-	  }
 	else
 	  if (j < exportedFields.length)
 	    for (;j<exportedFields.length;j++,k++)
@@ -396,7 +396,7 @@
 	      }
 	
 	fields = new ObjectStreamField[k];
-	System.arraycopy (newFieldList, 0, fields, 0, k);
+	System.arraycopy(newFieldList, 0, fields, 0, k);
       }
     catch (NoSuchFieldException ignore)
       {
@@ -413,300 +413,304 @@
     superClass = osc;
   }
 
-
-  void calculateOffsets ()
+  void calculateOffsets()
   {
     int i;
     ObjectStreamField field;
     primFieldSize = 0;
     int fcount = fields.length;
     for (i = 0; i < fcount; ++ i)
-    {
-      field = fields[i];
-
-      if (! field.isPrimitive ())
-	break;
-
-      field.setOffset (primFieldSize);
-      switch (field.getTypeCode ())
       {
-	case 'B':
-	case 'Z':
-	  ++ primFieldSize;
-	  break;
-	case 'C':
-	case 'S':
-	  primFieldSize += 2;
-	  break;
-	case 'I':
-	case 'F':
-	  primFieldSize += 4;
-	  break;
-	case 'D':
-	case 'J':
-	  primFieldSize += 8;
+	field = fields[i];
+
+	if (! field.isPrimitive())
 	  break;
+
+	field.setOffset(primFieldSize);
+	switch (field.getTypeCode())
+	  {
+	  case 'B':
+	  case 'Z':
+	    ++ primFieldSize;
+	    break;
+	  case 'C':
+	  case 'S':
+	    primFieldSize += 2;
+	    break;
+	  case 'I':
+	  case 'F':
+	    primFieldSize += 4;
+	    break;
+	  case 'D':
+	  case 'J':
+	    primFieldSize += 8;
+	    break;
+	  }
       }
-    }
 
     for (objectFieldCount = 0; i < fcount; ++ i)
-      fields[i].setOffset (objectFieldCount++);
+      fields[i].setOffset(objectFieldCount++);
   }
 
 
-  private ObjectStreamClass (Class cl)
+  private ObjectStreamClass(Class cl)
   {
     uid = 0;
     flags = 0;
-    isProxyClass = Proxy.isProxyClass (cl);
+    isProxyClass = Proxy.isProxyClass(cl);
 
     clazz = cl;
-    name = cl.getName ();
-    setFlags (cl);
-    setFields (cl);
+    name = cl.getName();
+    setFlags(cl);
+    setFields(cl);
     // to those class nonserializable, its uid field is 0
-    if ( (Serializable.class).isAssignableFrom (cl) && !isProxyClass)
-      uid = getClassUID (cl);
-    superClass = lookup (cl.getSuperclass ());
+    if ( (Serializable.class).isAssignableFrom(cl) && !isProxyClass)
+      uid = getClassUID(cl);
+    superClass = lookup(cl.getSuperclass());
   }
 
 
   // Sets bits in flags according to features of CL.
-  private void setFlags (Class cl)
+  private void setFlags(Class cl)
   {
-    if ((java.io.Externalizable.class).isAssignableFrom (cl))
+    if ((java.io.Externalizable.class).isAssignableFrom(cl))
       flags |= ObjectStreamConstants.SC_EXTERNALIZABLE;
-    else if ((java.io.Serializable.class).isAssignableFrom (cl))
+    else if ((java.io.Serializable.class).isAssignableFrom(cl))
       // only set this bit if CL is NOT Externalizable
       flags |= ObjectStreamConstants.SC_SERIALIZABLE;
 
     try
-    {
-      Method writeMethod = cl.getDeclaredMethod ("writeObject",
-						 writeMethodArgTypes);
-      int modifiers = writeMethod.getModifiers ();
-
-      if (writeMethod.getReturnType () == Void.TYPE
-	  && Modifier.isPrivate (modifiers)
-	  && !Modifier.isStatic (modifiers))
-	flags |= ObjectStreamConstants.SC_WRITE_METHOD;
-    }
-    catch (NoSuchMethodException oh_well)
-    {}
+      {
+	Method writeMethod = cl.getDeclaredMethod("writeObject",
+						  writeMethodArgTypes);
+	int modifiers = writeMethod.getModifiers();
+
+	if (writeMethod.getReturnType() == Void.TYPE
+	    && Modifier.isPrivate(modifiers)
+	    && !Modifier.isStatic(modifiers))
+	  flags |= ObjectStreamConstants.SC_WRITE_METHOD;
+      }
+    catch(NoSuchMethodException oh_well)
+      {
+      }
   }
 
 
   // Sets fields to be a sorted array of the serializable fields of
   // clazz.
-  private void setFields (Class cl)
+  private void setFields(Class cl)
   {
-    if (! isSerializable () || isExternalizable ())
-    {
-      fields = NO_FIELDS;
-      return;
-    }
+    if (!isSerializable() || isExternalizable())
+      {
+	fields = NO_FIELDS;
+	return;
+      }
 
     try
-    {
-      Field serialPersistentFields
-	= cl.getDeclaredField ("serialPersistentFields");
-      serialPersistentFields.setAccessible(true);
-      int modifiers = serialPersistentFields.getModifiers ();
-

*** Patch too long, truncated ***




More information about the kaffe mailing list