re PR libgcj/21372 (FileChannel.tryLock() return value incorrect)
authorAndrew Overholt <overholt@redhat.com>
Tue, 3 May 2005 22:38:17 +0000 (22:38 +0000)
committerTom Tromey <tromey@gcc.gnu.org>
Tue, 3 May 2005 22:38:17 +0000 (22:38 +0000)
2005-05-03  Andrew Overholt  <overholt@redhat.com>

PR libgcj/21372:
* gnu/java/nio/channels/FileChannelImpl.java: Return null if lock
could not be acquired.
* java/nio/channels/FileLock.java (toString): Re-implement to be
in line with other implementations.

From-SVN: r99188

libjava/ChangeLog
libjava/gnu/java/nio/channels/FileChannelImpl.java
libjava/java/nio/channels/FileLock.java

index dc02544..17a07fd 100644 (file)
@@ -1,3 +1,11 @@
+2005-05-03  Andrew Overholt  <overholt@redhat.com>
+
+       PR libgcj/21372:
+       * gnu/java/nio/channels/FileChannelImpl.java: Return null if lock
+       could not be acquired.
+       * java/nio/channels/FileLock.java (toString): Re-implement to be
+       in line with other implementations.
+
 2005-05-03  Tom Tromey  <tromey@redhat.com>
 
        * java/lang/VMSecurityManager.java (currentClassLoader): Use
index aaa4c26..6893d81 100644 (file)
@@ -437,9 +437,11 @@ public final class FileChannelImpl extends FileChannel
     try
       {
        begin();
-        lock(position, size, shared, false);
+       boolean lockable = lock(position, size, shared, false);
        completed = true;
-       return new FileLockImpl(this, position, size, shared);
+       return (lockable
+               ? new FileLockImpl(this, position, size, shared)
+               : null);
       }
     finally
       {
index 629f5ef..a4af080 100644 (file)
@@ -132,6 +132,16 @@ public abstract class FileLock
    */
   public final String toString()
   {
-    return "file-lock:pos=" + position + "size=" + size;
+       String toReturn = getClass().getName() + 
+         "[" + position + ":" + size;
+       if (shared)
+         toReturn += " shared";
+       else
+         toReturn += " exclusive";
+       if (isValid())
+         toReturn += " valid]";
+       else
+         toReturn += " invalid]";
+       return toReturn;
   }
 }