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: java.nio fixes


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi list,


I commited the attached patch to java.nio to fix some issues.


Michael
- -- 
Homepage: http://www.worldforge.org/
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.1 (GNU/Linux)

iD8DBQE+yIFSWSOgCCdjSDsRAu0jAJsEzM63gaGS+fYZUVVP5xg9bpk44QCfeSAy
1Fg8BAXC+vess3197hi3MNI=
=W8bp
-----END PGP SIGNATURE-----
Index: ChangeLog
===================================================================
RCS file: /cvs/gcc/gcc/libjava/ChangeLog,v
retrieving revision 1.1896
diff -u -b -B -r1.1896 ChangeLog
--- ChangeLog	16 May 2003 08:09:30 -0000	1.1896
+++ ChangeLog	19 May 2003 06:56:11 -0000
@@ -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: gnu/java/nio/ByteBufferImpl.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/gnu/java/nio/ByteBufferImpl.java,v
retrieving revision 1.8
diff -u -b -B -r1.8 ByteBufferImpl.java
--- gnu/java/nio/ByteBufferImpl.java	13 May 2003 06:04:19 -0000	1.8
+++ gnu/java/nio/ByteBufferImpl.java	19 May 2003 06:56:11 -0000
@@ -311,14 +311,14 @@
   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 @@
   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 @@
   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 @@
   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: gnu/java/nio/DirectByteBufferImpl.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/gnu/java/nio/DirectByteBufferImpl.java,v
retrieving revision 1.2
diff -u -b -B -r1.2 DirectByteBufferImpl.java
--- gnu/java/nio/DirectByteBufferImpl.java	12 May 2003 20:45:19 -0000	1.2
+++ gnu/java/nio/DirectByteBufferImpl.java	19 May 2003 06:56:11 -0000
@@ -291,14 +291,14 @@
   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 @@
   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 @@
   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 @@
   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: gnu/java/nio/FileLockImpl.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/gnu/java/nio/FileLockImpl.java,v
retrieving revision 1.3
diff -u -b -B -r1.3 FileLockImpl.java
--- gnu/java/nio/FileLockImpl.java	14 May 2003 06:37:59 -0000	1.3
+++ gnu/java/nio/FileLockImpl.java	19 May 2003 06:56:11 -0000
@@ -62,7 +62,8 @@
   
   public boolean isValid ()
   {
-    return (released || !channel.isOpen ());
+    return (released
+            || !channel ().isOpen ());
   }
 
   private native void releaseImpl () throws IOException;
Index: java/nio/Buffer.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/nio/Buffer.java,v
retrieving revision 1.3
diff -u -b -B -r1.3 Buffer.java
--- java/nio/Buffer.java	11 Feb 2003 07:42:17 -0000	1.3
+++ java/nio/Buffer.java	19 May 2003 06:56:11 -0000
@@ -57,7 +57,7 @@
     limit (limit);
     position (position);
     
-    if (mark > 0)
+    if (mark >= 0)
     {
       if (mark > pos)
         throw new IllegalArgumentException ();
Index: java/nio/ByteBuffer.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/nio/ByteBuffer.java,v
retrieving revision 1.11
diff -u -b -B -r1.11 ByteBuffer.java
--- java/nio/ByteBuffer.java	13 May 2003 06:04:19 -0000	1.11
+++ java/nio/ByteBuffer.java	19 May 2003 06:56:12 -0000
@@ -63,6 +63,7 @@
     this.backing_buffer = buffer;
     this.array_offset = offset;
   }
+  
   /**
    * Allocates a new direct byte buffer.
    */ 
Index: java/nio/CharBuffer.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/nio/CharBuffer.java,v
retrieving revision 1.11
diff -u -b -B -r1.11 CharBuffer.java
--- java/nio/CharBuffer.java	12 May 2003 20:45:19 -0000	1.11
+++ java/nio/CharBuffer.java	19 May 2003 06:56:12 -0000
@@ -113,7 +113,7 @@
         buffer [i] = a.charAt (i);
       }
     
-    return wrap (buffer, offset, length);
+    return wrap (buffer, offset, length).asReadOnlyBuffer ();
   }
 
   /**
@@ -426,7 +426,7 @@
       return new String (array (), position (), length ());
 
     char[] buf = new char [length ()];
-    get (buf);
+    get (position (), buf);
     return new String (buf);
   }
 

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