2003-05-19 Michael Koch <konqueror@gmx.de>
authorMichael Koch <konqueror@gmx.de>
Mon, 19 May 2003 06:59:23 +0000 (06:59 +0000)
committerMichael Koch <mkoch@gcc.gnu.org>
Mon, 19 May 2003 06:59:23 +0000 (06:59 +0000)
* gnu/java/nio/ByteBufferImpl.java
(putLong): Fixed conversion to bytes.
(putDouble): Fixed conversion to bytes.
* gnu/java/nio/DirectByteBufferImpl.java
(putLong): Fixed conversion to bytes.
(putDouble): Fixed conversion to bytes.
* gnu/java/nio/FileLockImpl.java
(isValid): Reformatted.
* java/nio/Buffer.java
(Buffer): Fixed off-by-one bug in handling mark.
* java/nio/ByteBuffer.java:
Added newline.
* java/nio/CharBuffer.java
(toString): Don't use relative get to get string data.

From-SVN: r66946

libjava/ChangeLog
libjava/gnu/java/nio/ByteBufferImpl.java
libjava/gnu/java/nio/DirectByteBufferImpl.java
libjava/gnu/java/nio/FileLockImpl.java
libjava/java/nio/Buffer.java
libjava/java/nio/ByteBuffer.java
libjava/java/nio/CharBuffer.java

index 991730d704340aff30945c613a12d447b47e3e04..0846261dcf5960ebc1633381a142a83fa49ee6a7 100644 (file)
@@ -1,3 +1,20 @@
+2003-05-19  Michael Koch  <konqueror@gmx.de>
+
+       * gnu/java/nio/ByteBufferImpl.java
+       (putLong): Fixed conversion to bytes.
+       (putDouble): Fixed conversion to bytes.
+       * gnu/java/nio/DirectByteBufferImpl.java
+       (putLong): Fixed conversion to bytes.
+       (putDouble): Fixed conversion to bytes.
+       * gnu/java/nio/FileLockImpl.java
+       (isValid): Reformatted.
+       * java/nio/Buffer.java
+       (Buffer): Fixed off-by-one bug in handling mark.
+       * java/nio/ByteBuffer.java:
+       Added newline.
+       * java/nio/CharBuffer.java
+       (toString): Don't use relative get to get string data.
+
 2003-05-16  Michael Koch  <konqueror@gmx.de>
 
        * java/io/natFileDescriptorPosix.cc
index cc7fabb594106a3679c58161575b22cb6142b59e..f9de8c7d1520991d18fc4997b6a61449c96baa49 100644 (file)
@@ -311,14 +311,14 @@ public final class ByteBufferImpl extends ByteBuffer
   final public ByteBuffer putLong (long value)
   {
     // FIXME: this handles big endian only
-    put ((byte) ((((int) value) & 0xff00000000000000) >> 56));
-    put ((byte) ((((int) value) & 0x00ff000000000000) >> 48));
-    put ((byte) ((((int) value) & 0x0000ff0000000000) >> 40));
-    put ((byte) ((((int) value) & 0x000000ff00000000) >> 32));
-    put ((byte) ((((int) value) & 0x00000000ff000000) >> 24));
-    put ((byte) ((((int) value) & 0x0000000000ff0000) >> 16));
-    put ((byte) ((((int) value) & 0x000000000000ff00) >> 8));
-    put ((byte) (((int) value) & 0x00000000000000ff));
+    put ((byte) ((value & 0xff00000000000000L) >> 56));
+    put ((byte) ((value & 0x00ff000000000000L) >> 48));
+    put ((byte) ((value & 0x0000ff0000000000L) >> 40));
+    put ((byte) ((value & 0x000000ff00000000L) >> 32));
+    put ((byte) ((value & 0x00000000ff000000L) >> 24));
+    put ((byte) ((value & 0x0000000000ff0000L) >> 16));
+    put ((byte) ((value & 0x000000000000ff00L) >> 8));
+    put ((byte) (value & 0x00000000000000ffL));
     return this;
   }
   
@@ -338,14 +338,14 @@ public final class ByteBufferImpl extends ByteBuffer
   final public ByteBuffer putLong (int index, long value)
   {
     // FIXME: this handles big endian only
-    put (index, (byte) ((((int) value) & 0xff00000000000000) >> 56));
-    put (index + 1, (byte) ((((int) value) & 0x00ff000000000000) >> 48));
-    put (index + 2, (byte) ((((int) value) & 0x0000ff0000000000) >> 40));
-    put (index + 3, (byte) ((((int) value) & 0x000000ff00000000) >> 32));
-    put (index + 4, (byte) ((((int) value) & 0x00000000ff000000) >> 24));
-    put (index + 5, (byte) ((((int) value) & 0x0000000000ff0000) >> 16));
-    put (index + 6, (byte) ((((int) value) & 0x000000000000ff00) >> 8));
-    put (index + 7, (byte) (((int) value) & 0x00000000000000ff));
+    put (index, (byte) ((value & 0xff00000000000000L) >> 56));
+    put (index + 1, (byte) ((value & 0x00ff000000000000L) >> 48));
+    put (index + 2, (byte) ((value & 0x0000ff0000000000L) >> 40));
+    put (index + 3, (byte) ((value & 0x000000ff00000000L) >> 32));
+    put (index + 4, (byte) ((value & 0x00000000ff000000L) >> 24));
+    put (index + 5, (byte) ((value & 0x0000000000ff0000L) >> 16));
+    put (index + 6, (byte) ((value & 0x000000000000ff00L) >> 8));
+    put (index + 7, (byte) (value & 0x00000000000000ffL));
     return this;
   }
 
@@ -403,14 +403,14 @@ public final class ByteBufferImpl extends ByteBuffer
   final public ByteBuffer putDouble (double value)
   {
     // FIXME: this handles big endian only
-    put ((byte) ((((int) value) & 0xff00000000000000) >> 56));
-    put ((byte) ((((int) value) & 0x00ff000000000000) >> 48));
-    put ((byte) ((((int) value) & 0x0000ff0000000000) >> 40));
-    put ((byte) ((((int) value) & 0x000000ff00000000) >> 32));
-    put ((byte) ((((int) value) & 0x00000000ff000000) >> 24));
-    put ((byte) ((((int) value) & 0x0000000000ff0000) >> 16));
-    put ((byte) ((((int) value) & 0x000000000000ff00) >> 8));
-    put ((byte) (((int) value) & 0x00000000000000ff));
+    put ((byte) ((((long) value) & 0xff00000000000000L) >> 56));
+    put ((byte) ((((long) value) & 0x00ff000000000000L) >> 48));
+    put ((byte) ((((long) value) & 0x0000ff0000000000L) >> 40));
+    put ((byte) ((((long) value) & 0x000000ff00000000L) >> 32));
+    put ((byte) ((((long) value) & 0x00000000ff000000L) >> 24));
+    put ((byte) ((((long) value) & 0x0000000000ff0000L) >> 16));
+    put ((byte) ((((long) value) & 0x000000000000ff00L) >> 8));
+    put ((byte) (((long) value) & 0x00000000000000ffL));
     return this;
   }
   
@@ -430,14 +430,14 @@ public final class ByteBufferImpl extends ByteBuffer
   final public ByteBuffer putDouble (int index, double value)
   {
     // FIXME: this handles big endian only
-    put (index, (byte) ((((int) value) & 0xff00000000000000) >> 56));
-    put (index + 1, (byte) ((((int) value) & 0x00ff000000000000) >> 48));
-    put (index + 2, (byte) ((((int) value) & 0x0000ff0000000000) >> 40));
-    put (index + 3, (byte) ((((int) value) & 0x000000ff00000000) >> 32));
-    put (index + 4, (byte) ((((int) value) & 0x00000000ff000000) >> 24));
-    put (index + 5, (byte) ((((int) value) & 0x0000000000ff0000) >> 16));
-    put (index + 6, (byte) ((((int) value) & 0x000000000000ff00) >> 8));
-    put (index + 7, (byte) (((int) value) & 0x00000000000000ff));
+    put (index, (byte) ((((long) value) & 0xff00000000000000L) >> 56));
+    put (index + 1, (byte) ((((long) value) & 0x00ff000000000000L) >> 48));
+    put (index + 2, (byte) ((((long) value) & 0x0000ff0000000000L) >> 40));
+    put (index + 3, (byte) ((((long) value) & 0x000000ff00000000L) >> 32));
+    put (index + 4, (byte) ((((long) value) & 0x00000000ff000000L) >> 24));
+    put (index + 5, (byte) ((((long) value) & 0x0000000000ff0000L) >> 16));
+    put (index + 6, (byte) ((((long) value) & 0x000000000000ff00L) >> 8));
+    put (index + 7, (byte) (((long) value) & 0x00000000000000ffL));
     return this;
   }
 }
index 47b76bb8142b3f70afd9453fa5b7bf19534a0975..d214f0c4d832d73329d4bb98ef43442e36bcdc52 100644 (file)
@@ -291,14 +291,14 @@ public class DirectByteBufferImpl extends ByteBuffer
   final public ByteBuffer putLong (long value)
   {
     // FIXME: this handles big endian only
-    put ((byte) ((((int) value) & 0xff00000000000000) >> 56));
-    put ((byte) ((((int) value) & 0x00ff000000000000) >> 48));
-    put ((byte) ((((int) value) & 0x0000ff0000000000) >> 40));
-    put ((byte) ((((int) value) & 0x000000ff00000000) >> 32));
-    put ((byte) ((((int) value) & 0x00000000ff000000) >> 24));
-    put ((byte) ((((int) value) & 0x0000000000ff0000) >> 16));
-    put ((byte) ((((int) value) & 0x000000000000ff00) >> 8));
-    put ((byte) (((int) value) & 0x00000000000000ff));
+    put ((byte) ((value & 0xff00000000000000L) >> 56));
+    put ((byte) ((value & 0x00ff000000000000L) >> 48));
+    put ((byte) ((value & 0x0000ff0000000000L) >> 40));
+    put ((byte) ((value & 0x000000ff00000000L) >> 32));
+    put ((byte) ((value & 0x00000000ff000000L) >> 24));
+    put ((byte) ((value & 0x0000000000ff0000L) >> 16));
+    put ((byte) ((value & 0x000000000000ff00L) >> 8));
+    put ((byte) (value & 0x00000000000000ffL));
     return this;
   }
   
@@ -318,14 +318,14 @@ public class DirectByteBufferImpl extends ByteBuffer
   final public ByteBuffer putLong (int index, long value)
   {
     // FIXME: this handles big endian only
-    put (index, (byte) ((((int) value) & 0xff00000000000000) >> 56));
-    put (index + 1, (byte) ((((int) value) & 0x00ff000000000000) >> 48));
-    put (index + 2, (byte) ((((int) value) & 0x0000ff0000000000) >> 40));
-    put (index + 3, (byte) ((((int) value) & 0x000000ff00000000) >> 32));
-    put (index + 4, (byte) ((((int) value) & 0x00000000ff000000) >> 24));
-    put (index + 5, (byte) ((((int) value) & 0x0000000000ff0000) >> 16));
-    put (index + 6, (byte) ((((int) value) & 0x000000000000ff00) >> 8));
-    put (index + 7, (byte) (((int) value) & 0x00000000000000ff));
+    put (index, (byte) ((value & 0xff00000000000000L) >> 56));
+    put (index + 1, (byte) ((value & 0x00ff000000000000L) >> 48));
+    put (index + 2, (byte) ((value & 0x0000ff0000000000L) >> 40));
+    put (index + 3, (byte) ((value & 0x000000ff00000000L) >> 32));
+    put (index + 4, (byte) ((value & 0x00000000ff000000L) >> 24));
+    put (index + 5, (byte) ((value & 0x0000000000ff0000L) >> 16));
+    put (index + 6, (byte) ((value & 0x000000000000ff00L) >> 8));
+    put (index + 7, (byte) (value & 0x00000000000000ffL));
     return this;
   }
 
@@ -383,14 +383,14 @@ public class DirectByteBufferImpl extends ByteBuffer
   final public ByteBuffer putDouble (double value)
   {
     // FIXME: this handles big endian only
-    put ((byte) ((((int) value) & 0xff00000000000000) >> 56));
-    put ((byte) ((((int) value) & 0x00ff000000000000) >> 48));
-    put ((byte) ((((int) value) & 0x0000ff0000000000) >> 40));
-    put ((byte) ((((int) value) & 0x000000ff00000000) >> 32));
-    put ((byte) ((((int) value) & 0x00000000ff000000) >> 24));
-    put ((byte) ((((int) value) & 0x0000000000ff0000) >> 16));
-    put ((byte) ((((int) value) & 0x000000000000ff00) >> 8));
-    put ((byte) (((int) value) & 0x00000000000000ff));
+    put ((byte) ((((long) value) & 0xff00000000000000L) >> 56));
+    put ((byte) ((((long) value) & 0x00ff000000000000L) >> 48));
+    put ((byte) ((((long) value) & 0x0000ff0000000000L) >> 40));
+    put ((byte) ((((long) value) & 0x000000ff00000000L) >> 32));
+    put ((byte) ((((long) value) & 0x00000000ff000000L) >> 24));
+    put ((byte) ((((long) value) & 0x0000000000ff0000L) >> 16));
+    put ((byte) ((((long) value) & 0x000000000000ff00L) >> 8));
+    put ((byte) (((long) value) & 0x00000000000000ffL));
     return this;
   }
   
@@ -410,14 +410,14 @@ public class DirectByteBufferImpl extends ByteBuffer
   final public ByteBuffer putDouble (int index, double value)
   {
     // FIXME: this handles big endian only
-    put (index, (byte) ((((int) value) & 0xff00000000000000) >> 56));
-    put (index + 1, (byte) ((((int) value) & 0x00ff000000000000) >> 48));
-    put (index + 2, (byte) ((((int) value) & 0x0000ff0000000000) >> 40));
-    put (index + 3, (byte) ((((int) value) & 0x000000ff00000000) >> 32));
-    put (index + 4, (byte) ((((int) value) & 0x00000000ff000000) >> 24));
-    put (index + 5, (byte) ((((int) value) & 0x0000000000ff0000) >> 16));
-    put (index + 6, (byte) ((((int) value) & 0x000000000000ff00) >> 8));
-    put (index + 7, (byte) (((int) value) & 0x00000000000000ff));
+    put (index, (byte) ((((long) value) & 0xff00000000000000L) >> 56));
+    put (index + 1, (byte) ((((long) value) & 0x00ff000000000000L) >> 48));
+    put (index + 2, (byte) ((((long) value) & 0x0000ff0000000000L) >> 40));
+    put (index + 3, (byte) ((((long) value) & 0x000000ff00000000L) >> 32));
+    put (index + 4, (byte) ((((long) value) & 0x00000000ff000000L) >> 24));
+    put (index + 5, (byte) ((((long) value) & 0x0000000000ff0000L) >> 16));
+    put (index + 6, (byte) ((((long) value) & 0x000000000000ff00L) >> 8));
+    put (index + 7, (byte) (((long) value) & 0x00000000000000ffL));
     return this;
   }
 }
index 088e552bea26992bbc6cc64d7694c4f3e68cc38f..189e03ac81e6acb8222abafd92bec35c1775f3a8 100644 (file)
@@ -62,7 +62,8 @@ public class FileLockImpl extends FileLock
   
   public boolean isValid ()
   {
-    return (released || !channel.isOpen ());
+    return (released
+            || !channel ().isOpen ());
   }
 
   private native void releaseImpl () throws IOException;
index 7d291bedbc135b6379ce76c73d619e3eb8152839..693765f3e4652abf1b04ea09a592e2760b61e6bf 100644 (file)
@@ -57,7 +57,7 @@ public abstract class Buffer
     limit (limit);
     position (position);
     
-    if (mark > 0)
+    if (mark >= 0)
     {
       if (mark > pos)
         throw new IllegalArgumentException ();
index 66c31ed76bbc7b1c27ab4261c9e63b53126fb107..cb743c799c760778dda08621aeab7e8105f74713 100644 (file)
@@ -63,6 +63,7 @@ public abstract class ByteBuffer extends Buffer
     this.backing_buffer = buffer;
     this.array_offset = offset;
   }
+  
   /**
    * Allocates a new direct byte buffer.
    */ 
index fbee6dfb9dd93285b20a3c95a49f1137883c938a..f2fde710417038ba1922f166c538ec2ab1b2572e 100644 (file)
@@ -113,7 +113,7 @@ public abstract class CharBuffer extends Buffer
         buffer [i] = a.charAt (i);
       }
     
-    return wrap (buffer, offset, length);
+    return wrap (buffer, offset, length).asReadOnlyBuffer ();
   }
 
   /**
@@ -426,7 +426,7 @@ public abstract class CharBuffer extends Buffer
       return new String (array (), position (), length ());
 
     char[] buf = new char [length ()];
-    get (buf);
+    get (position (), buf);
     return new String (buf);
   }