[kaffe] CVS kaffe (dalibor): Resynced with GNU Classpath: Various small networking and nio fixes

Kaffe CVS cvs-commits at kaffe.org
Mon Mar 8 05:52:02 PST 2004


PatchSet 4488 
Date: 2004/03/08 13:49:08
Author: dalibor
Branch: HEAD
Tag: (none) 
Log:
Resynced with GNU Classpath: Various small networking and nio fixes

2004-03-08  Dalibor Topic <robilad at kaffe.org>

        Resynced with GNU Classpath

        2004-02-12  Michael Koch  <konqueror at gmx.de>

        * java/net/MulticastSocket.java
        (setLoopbackMode): Use Boolean.valueOf() instead of creating a new
        Boolean object.

        2004-02-27  Michael Koch  <konqueror at gmx.de>

        * java/net/URLConnection.java
        (dateFormat1, dateformat2, dateformat3): New fields.
        (dateformats_initialized): New field for lazy initialization of date
        format fields.
        (getHeaderFieldDate): Rewritten to use DateFormat.parse() instead of
        the deprecated Date(String) constructor. This implementation
        (initializeDateFormats): New method,

        2004-02-27  Michael Koch  <konqueror at gmx.de>

        * java/nio/channels/FileChannel.java
        (MapMode.READ_ONLY): Made final.
        (MapMode.READ_WRITE): Made final.
        (MapMode.PRIVATE): Made final.
        * java/nio/channels/SocketChannel.java
        (open): Simplified code.
        * java/nio/channels/spi/AbstractSelectableChannel.java
        (registered): Unused, removed.
        (keyFor): Check channel is open, only locate key
        and not add a new one.
        (register): Don't delete attachments.

Members: 
	ChangeLog:1.2068->1.2069 
	libraries/javalib/java/net/MulticastSocket.java:1.12->1.13 
	libraries/javalib/java/net/URLConnection.java:1.16->1.17 
	libraries/javalib/java/nio/ByteOrder.java:1.5->1.6 
	libraries/javalib/java/nio/channels/FileChannel.java:1.5->1.6 
	libraries/javalib/java/nio/channels/SocketChannel.java:1.2->1.3 
	libraries/javalib/java/nio/channels/spi/AbstractSelectableChannel.java:1.6->1.7 

Index: kaffe/ChangeLog
diff -u kaffe/ChangeLog:1.2068 kaffe/ChangeLog:1.2069
--- kaffe/ChangeLog:1.2068	Sun Mar  7 17:10:52 2004
+++ kaffe/ChangeLog	Mon Mar  8 13:49:08 2004
@@ -1,3 +1,37 @@
+2004-03-08  Dalibor Topic <robilad at kaffe.org>
+
+        Resynced with GNU Classpath
+
+	2004-02-12  Michael Koch  <konqueror at gmx.de>
+
+        * java/net/MulticastSocket.java
+        (setLoopbackMode): Use Boolean.valueOf() instead of creating a new
+        Boolean object.
+
+	2004-02-27  Michael Koch  <konqueror at gmx.de>
+
+        * java/net/URLConnection.java
+        (dateFormat1, dateformat2, dateformat3): New fields.
+        (dateformats_initialized): New field for lazy initialization of date
+        format fields.
+        (getHeaderFieldDate): Rewritten to use DateFormat.parse() instead of
+        the deprecated Date(String) constructor. This implementation
+        (initializeDateFormats): New method,
+
+	2004-02-27  Michael Koch  <konqueror at gmx.de>
+
+        * java/nio/channels/FileChannel.java
+        (MapMode.READ_ONLY): Made final.
+        (MapMode.READ_WRITE): Made final.
+        (MapMode.PRIVATE): Made final.
+        * java/nio/channels/SocketChannel.java
+        (open): Simplified code.
+        * java/nio/channels/spi/AbstractSelectableChannel.java
+        (registered): Unused, removed.
+        (keyFor): Check channel is open, only locate key
+        and not add a new one.
+        (register): Don't delete attachments.
+
 2004-03-07  Dalibor Topic <robilad at kaffe.org>
 
         Resynced with GNU Classpath
Index: kaffe/libraries/javalib/java/net/MulticastSocket.java
diff -u kaffe/libraries/javalib/java/net/MulticastSocket.java:1.12 kaffe/libraries/javalib/java/net/MulticastSocket.java:1.13
--- kaffe/libraries/javalib/java/net/MulticastSocket.java:1.12	Wed Dec  3 23:18:03 2003
+++ kaffe/libraries/javalib/java/net/MulticastSocket.java	Mon Mar  8 13:49:09 2004
@@ -255,7 +255,7 @@
     if (isClosed())
       throw new SocketException("socket is closed");
 
-    getImpl().setOption (SocketOptions.IP_MULTICAST_LOOP, new Boolean (disable));
+    getImpl().setOption (SocketOptions.IP_MULTICAST_LOOP, Boolean.valueOf(disable));
   }
 
   /**
Index: kaffe/libraries/javalib/java/net/URLConnection.java
diff -u kaffe/libraries/javalib/java/net/URLConnection.java:1.16 kaffe/libraries/javalib/java/net/URLConnection.java:1.17
--- kaffe/libraries/javalib/java/net/URLConnection.java:1.16	Mon Feb  2 18:13:53 2004
+++ kaffe/libraries/javalib/java/net/URLConnection.java	Mon Mar  8 13:49:09 2004
@@ -43,6 +43,8 @@
 import java.io.OutputStream;
 import java.security.AllPermission;
 import java.security.Permission;
+import java.text.ParsePosition;
+import java.text.SimpleDateFormat;
 import java.util.Collections;
 import java.util.Date;
 import java.util.Hashtable;
@@ -161,6 +163,8 @@
    */
   protected URL url;
 
+  private static SimpleDateFormat dateFormat1, dateFormat2, dateFormat3;
+  private static boolean dateformats_initialized = false;
 
   /**
    * Creates a URL connection to a given URL. A real connection is not made.
@@ -352,23 +356,24 @@
    */
   public long getHeaderFieldDate (String name, long defaultValue)
   {
+    if (! dateformats_initialized)
+      initializeDateFormats ();
+    
+    long result = defaultValue;
     String str = getHeaderField (name);
     
-    if (str == null)
-      return defaultValue;
+    if (str != null)
+      {
+	Date date;
+	if ((date = dateFormat1.parse (str, new ParsePosition (0))) != null)
+	  result = date.getTime ();
+	else if ((date = dateFormat2.parse (str, new ParsePosition (0))) != null)
+	  result = date.getTime ();
+	else if ((date = dateFormat3.parse (str, new ParsePosition (0))) != null)
+	  result = date.getTime ();
+      }
     
-    // This needs to change since Date(String) is deprecated, but DateFormat
-    // doesn't seem to be working for some reason
-    //DateFormat df = DateFormat.getDateInstance (DateFormat.FULL, Locale.US);
-    //df.setLenient (true);
-
-    //Date date = df.parse (value, new ParsePosition (0));
-    Date date = new Date (str);
-
-    if (date == null)
-      return defaultValue;
-       
-    return (date.getTime() / 1000);
+    return result;
   }
 
   /**
@@ -952,5 +957,22 @@
       s.checkSetFactory();
 
     fileNameMap = map;
+  }
+  
+  // We don't put these in a static initializer, because it creates problems
+  // with initializer co-dependency: SimpleDateFormat's constructors eventually 
+  // depend on URLConnection (via the java.text.*Symbols classes).
+  private synchronized void initializeDateFormats()
+  {
+    if (dateformats_initialized)
+      return;
+
+    Locale locale = new Locale("En", "Us", "Unix");
+    dateFormat1 = new SimpleDateFormat("EEE, dd MMM yyyy hh:mm:ss 'GMT'", 
+                                       locale);
+    dateFormat2 = new SimpleDateFormat("EEEE, dd-MMM-yy hh:mm:ss 'GMT'", 
+                                       locale);
+    dateFormat3 = new SimpleDateFormat("EEE MMM d hh:mm:ss yyyy", locale);
+    dateformats_initialized = true;
   }
 }
Index: kaffe/libraries/javalib/java/nio/ByteOrder.java
diff -u kaffe/libraries/javalib/java/nio/ByteOrder.java:1.5 kaffe/libraries/javalib/java/nio/ByteOrder.java:1.6
--- kaffe/libraries/javalib/java/nio/ByteOrder.java:1.5	Sat Dec 27 21:15:59 2003
+++ kaffe/libraries/javalib/java/nio/ByteOrder.java	Mon Mar  8 13:49:10 2004
@@ -63,7 +63,7 @@
    */
   public static ByteOrder nativeOrder ()
   {
-    return (System.getProperty ("gnu.cpu.endian") == "big"
+    return (System.getProperty ("gnu.cpu.endian").equals("big")
             ? BIG_ENDIAN : LITTLE_ENDIAN);
   }
 
Index: kaffe/libraries/javalib/java/nio/channels/FileChannel.java
diff -u kaffe/libraries/javalib/java/nio/channels/FileChannel.java:1.5 kaffe/libraries/javalib/java/nio/channels/FileChannel.java:1.6
--- kaffe/libraries/javalib/java/nio/channels/FileChannel.java:1.5	Sun Aug 10 18:47:53 2003
+++ kaffe/libraries/javalib/java/nio/channels/FileChannel.java	Mon Mar  8 13:49:10 2004
@@ -53,9 +53,9 @@
   {
     int m;
 
-    public static MapMode READ_ONLY  = new MapMode(0);
-    public static MapMode READ_WRITE = new MapMode(1);
-    public static MapMode PRIVATE    = new MapMode(2);
+    public static final MapMode READ_ONLY  = new MapMode(0);
+    public static final MapMode READ_WRITE = new MapMode(1);
+    public static final MapMode PRIVATE    = new MapMode(2);
 
     /**
      * Initializes the MapMode.
Index: kaffe/libraries/javalib/java/nio/channels/SocketChannel.java
diff -u kaffe/libraries/javalib/java/nio/channels/SocketChannel.java:1.2 kaffe/libraries/javalib/java/nio/channels/SocketChannel.java:1.3
--- kaffe/libraries/javalib/java/nio/channels/SocketChannel.java:1.2	Sat Dec 21 16:40:40 2002
+++ kaffe/libraries/javalib/java/nio/channels/SocketChannel.java	Mon Mar  8 13:49:10 2004
@@ -87,11 +87,7 @@
   public static SocketChannel open (SocketAddress remote) throws IOException
   {
     SocketChannel ch = open ();
-	
-    if (ch.connect (remote))
-      {
-      }
-    
+    ch.connect(remote);
     return ch;
   }
     
Index: kaffe/libraries/javalib/java/nio/channels/spi/AbstractSelectableChannel.java
diff -u kaffe/libraries/javalib/java/nio/channels/spi/AbstractSelectableChannel.java:1.6 kaffe/libraries/javalib/java/nio/channels/spi/AbstractSelectableChannel.java:1.7
--- kaffe/libraries/javalib/java/nio/channels/spi/AbstractSelectableChannel.java:1.6	Mon Feb 23 22:56:38 2004
+++ kaffe/libraries/javalib/java/nio/channels/spi/AbstractSelectableChannel.java	Mon Mar  8 13:49:10 2004
@@ -48,7 +48,6 @@
 
 public abstract class AbstractSelectableChannel extends SelectableChannel
 {
-  private int registered;
   private boolean blocking = true;
   private Object LOCK = new Object();
   private SelectorProvider provider;
@@ -135,9 +134,15 @@
    */
   public final SelectionKey keyFor(Selector selector)
   {
+    if (! isOpen())
+      return null;
+    
     try
       {
-        return register (selector, 0, null);
+        synchronized(blockingLock())
+	  {
+	    return locate (selector);
+	  }
       }
     catch (Exception e)
       {
@@ -196,7 +201,8 @@
 
         if (key != null)
           {
-            key.attach (att);
+	    if (att != null)
+	      key.attach (att);
           }
         else
           {




More information about the kaffe mailing list