This is the mail archive of the java-patches@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

FYI: Patch: several little java.nio fixes


Hi list,


I just commited the attached patch to do some little fixes for java.nio.
The ones in java/nio/channels/spi/AbstractSelectableChannel.java are 
inspired by a mail/patch from Matthew J Toseland from freenet project.


Michael


2004-02-26  Michael Koch  <konqueror@gmx.de>

	* gnu/java/nio/FileLockImpl.java
	(finalize): Made protected.
	* 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.

Index: gnu/java/nio/FileLockImpl.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/gnu/java/nio/FileLockImpl.java,v
retrieving revision 1.7
diff -u -b -B -r1.7 FileLockImpl.java
--- gnu/java/nio/FileLockImpl.java	23 Jan 2004 15:53:51 -0000	1.7
+++ gnu/java/nio/FileLockImpl.java	26 Feb 2004 19:44:28 -0000
@@ -68,7 +68,7 @@
     this.fd = fd;
   }
 
-  public void finalize()
+  protected void finalize()
   {
     try
       {
Index: java/nio/channels/FileChannel.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/nio/channels/FileChannel.java,v
retrieving revision 1.4
diff -u -b -B -r1.4 FileChannel.java
--- java/nio/channels/FileChannel.java	27 Jun 2003 13:34:12 -0000	1.4
+++ java/nio/channels/FileChannel.java	26 Feb 2004 19:44:28 -0000
@@ -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: java/nio/channels/SocketChannel.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/nio/channels/SocketChannel.java,v
retrieving revision 1.6
diff -u -b -B -r1.6 SocketChannel.java
--- java/nio/channels/SocketChannel.java	11 Feb 2003 06:48:53 -0000	1.6
+++ java/nio/channels/SocketChannel.java	26 Feb 2004 19:44:28 -0000
@@ -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: java/nio/channels/spi/AbstractSelectableChannel.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/nio/channels/spi/AbstractSelectableChannel.java,v
retrieving revision 1.8
diff -u -b -B -r1.8 AbstractSelectableChannel.java
--- java/nio/channels/spi/AbstractSelectableChannel.java	30 Jan 2004 13:43:21 -0000	1.8
+++ java/nio/channels/spi/AbstractSelectableChannel.java	26 Feb 2004 19:44:28 -0000
@@ -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,6 +201,7 @@
 
         if (key != null)
           {
+	    if (att != null)
             key.attach (att);
           }
         else

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]