This is the mail archive of the
java-patches@gcc.gnu.org
mailing list for the Java project.
FYI: Patch: java.nio view buffer fixes
- From: Michael Koch <konqueror at gmx dot de>
- To: java-patches at gcc dot gnu dot org
- Date: Tue, 13 May 2003 22:13:54 +0200
- Subject: FYI: Patch: java.nio view buffer fixes
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Hi list,
I commited the attached patch to fix some misbehaviours of java.nio's
view buffers.
Michael
- --
Homepage: http://www.worldforge.org/
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.1 (GNU/Linux)
iD8DBQE+wVICWSOgCCdjSDsRAjeAAJ4s9HxPUDJeuZo+74Iqy/pxAdtUCQCghT9u
DpI1k0v61hLUXXVmk2jViJg=
=H2m9
-----END PGP SIGNATURE-----
Index: ChangeLog
===================================================================
RCS file: /cvs/gcc/gcc/libjava/ChangeLog,v
retrieving revision 1.1893
diff -u -b -B -r1.1893 ChangeLog
--- ChangeLog 13 May 2003 12:57:31 -0000 1.1893
+++ ChangeLog 13 May 2003 20:10:26 -0000
@@ -1,5 +1,32 @@
2003-05-13 Michael Koch <konqueror@gmx.de>
+ * gnu/java/nio/CharViewBufferImpl.java
+ (CharViewBufferImpl): Fixed super constructor call, initialize offset.
+ (get): Shift bits to the right direction.
+ (put): Likewise.
+ * gnu/java/nio/DoubleViewBufferImpl.java
+ (DoubleViewBufferImpl): Fixed super constructor call, initialize offset.
+ (get): Shift bits to the right direction.
+ (put): Likewise.
+ * gnu/java/nio/FloatViewBufferImpl.java
+ (FloatViewBufferImpl): Fixed super constructor call, initialize offset.
+ (get): Shift bits to the right direction.
+ (put): Likewise.
+ * gnu/java/nio/IntViewBufferImpl.java
+ (IntViewBufferImpl): Fixed super constructor call, initialize offset.
+ (get): Shift bits to the right direction.
+ (put): Likewise.
+ * gnu/java/nio/LongViewBufferImpl.java
+ (LongViewBufferImpl): Fixed super constructor call, initialize offset.
+ (get): Shift bits to the right direction.
+ (put): Likewise.
+ * gnu/java/nio/ShortViewBufferImpl.java
+ (ShortViewBufferImpl): Fixed super constructor call, initialize offset.
+ (get): Shift bits to the right direction.
+ (put): Likewise.
+
+2003-05-13 Michael Koch <konqueror@gmx.de>
+
* gnu/java/nio/natDirectByteBufferImpl.cc
(allocateImpl): jlong -> RawData*.
(freeImpl): Likewise.
Index: gnu/java/nio/CharViewBufferImpl.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/gnu/java/nio/CharViewBufferImpl.java,v
retrieving revision 1.1
diff -u -b -B -r1.1 CharViewBufferImpl.java
--- gnu/java/nio/CharViewBufferImpl.java 12 May 2003 18:32:17 -0000 1.1
+++ gnu/java/nio/CharViewBufferImpl.java 13 May 2003 20:10:26 -0000
@@ -62,8 +62,9 @@
int limit, int position, int mark,
boolean readOnly)
{
- super (limit, limit, offset, position);
+ super (limit >> 1, limit >> 1, position >> 1, mark >> 1);
this.bb = bb;
+ this.offset = offset;
this.readOnly = readOnly;
// FIXME: What if this is called from CharViewBufferImpl and ByteBuffer has changed its endianess ?
this.endian = bb.order ();
@@ -71,25 +72,26 @@
public char get ()
{
- char result = bb.getChar ((position () >> 1) + offset);
+ char result = bb.getChar ((position () << 1) + offset);
position (position () + 1);
return result;
}
public char get (int index)
{
- return bb.getChar ((index >> 1) + offset);
+ return bb.getChar ((index << 1) + offset);
}
public CharBuffer put (char value)
{
- bb.putChar ((position () >> 1) + offset, value);
+ bb.putChar ((position () << 1) + offset, value);
+ position (position () + 1);
return this;
}
public CharBuffer put (int index, char value)
{
- bb.putChar ((index >> 1) + offset, value);
+ bb.putChar ((index << 1) + offset, value);
return this;
}
Index: gnu/java/nio/DoubleViewBufferImpl.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/gnu/java/nio/DoubleViewBufferImpl.java,v
retrieving revision 1.1
diff -u -b -B -r1.1 DoubleViewBufferImpl.java
--- gnu/java/nio/DoubleViewBufferImpl.java 12 May 2003 18:32:17 -0000 1.1
+++ gnu/java/nio/DoubleViewBufferImpl.java 13 May 2003 20:10:26 -0000
@@ -62,8 +62,9 @@
int limit, int position, int mark,
boolean readOnly)
{
- super (limit, limit, offset, position);
+ super (limit >> 3, limit >> 3, position >> 3, mark >> 3);
this.bb = bb;
+ this.offset = offset;
this.readOnly = readOnly;
// FIXME: What if this is called from DoubleViewBufferImpl and ByteBuffer has changed its endianess ?
this.endian = bb.order ();
@@ -71,25 +72,26 @@
public double get ()
{
- double result = bb.getDouble ((position () >> 3) + offset);
+ double result = bb.getDouble ((position () << 3) + offset);
position (position () + 1);
return result;
}
public double get (int index)
{
- return bb.getDouble ((index >> 3) + offset);
+ return bb.getDouble ((index << 3) + offset);
}
public DoubleBuffer put (double value)
{
- bb.putDouble ((position () >> 3) + offset, value);
+ bb.putDouble ((position () << 3) + offset, value);
+ position (position () + 1);
return this;
}
public DoubleBuffer put (int index, double value)
{
- bb.putDouble ((index >> 3) + offset, value);
+ bb.putDouble ((index << 3) + offset, value);
return this;
}
Index: gnu/java/nio/FloatViewBufferImpl.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/gnu/java/nio/FloatViewBufferImpl.java,v
retrieving revision 1.1
diff -u -b -B -r1.1 FloatViewBufferImpl.java
--- gnu/java/nio/FloatViewBufferImpl.java 12 May 2003 18:32:17 -0000 1.1
+++ gnu/java/nio/FloatViewBufferImpl.java 13 May 2003 20:10:26 -0000
@@ -62,8 +62,9 @@
int limit, int position, int mark,
boolean readOnly)
{
- super (limit, limit, offset, position);
+ super (limit >> 2, limit >> 2, position >> 2, mark >> 2);
this.bb = bb;
+ this.offset = offset;
this.readOnly = readOnly;
// FIXME: What if this is called from FloatViewBufferImpl and ByteBuffer has changed its endianess ?
this.endian = bb.order ();
@@ -71,25 +72,26 @@
public float get ()
{
- float result = bb.getFloat ((position () >> 2) + offset);
+ float result = bb.getFloat ((position () << 2) + offset);
position (position () + 1);
return result;
}
public float get (int index)
{
- return bb.getFloat ((index >> 2) + offset);
+ return bb.getFloat ((index << 2) + offset);
}
public FloatBuffer put (float value)
{
- bb.putFloat ((position () >> 2) + offset, value);
+ bb.putFloat ((position () << 2) + offset, value);
+ position (position () + 1);
return this;
}
public FloatBuffer put (int index, float value)
{
- bb.putFloat ((index >> 2) + offset, value);
+ bb.putFloat ((index << 2) + offset, value);
return this;
}
Index: gnu/java/nio/IntViewBufferImpl.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/gnu/java/nio/IntViewBufferImpl.java,v
retrieving revision 1.1
diff -u -b -B -r1.1 IntViewBufferImpl.java
--- gnu/java/nio/IntViewBufferImpl.java 12 May 2003 18:32:17 -0000 1.1
+++ gnu/java/nio/IntViewBufferImpl.java 13 May 2003 20:10:26 -0000
@@ -62,8 +62,9 @@
int limit, int position, int mark,
boolean readOnly)
{
- super (limit, limit, offset, position);
+ super (limit >> 2, limit >> 2, position >> 2, mark >> 2);
this.bb = bb;
+ this.offset = offset;
this.readOnly = readOnly;
// FIXME: What if this is called from IntViewBufferImpl and ByteBuffer has changed its endianess ?
this.endian = bb.order ();
@@ -71,25 +72,26 @@
public int get ()
{
- int result = bb.getInt ((position () >> 2) + offset);
+ int result = bb.getInt ((position () << 2) + offset);
position (position () + 1);
return result;
}
public int get (int index)
{
- return bb.getInt ((index >> 2) + offset);
+ return bb.getInt ((index << 2) + offset);
}
public IntBuffer put (int value)
{
- bb.putInt ((position () >> 2) + offset, value);
+ bb.putInt ((position () << 2) + offset, value);
+ position (position () + 1);
return this;
}
public IntBuffer put (int index, int value)
{
- bb.putInt ((index >> 2) + offset, value);
+ bb.putInt ((index << 2) + offset, value);
return this;
}
Index: gnu/java/nio/LongViewBufferImpl.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/gnu/java/nio/LongViewBufferImpl.java,v
retrieving revision 1.1
diff -u -b -B -r1.1 LongViewBufferImpl.java
--- gnu/java/nio/LongViewBufferImpl.java 12 May 2003 18:32:17 -0000 1.1
+++ gnu/java/nio/LongViewBufferImpl.java 13 May 2003 20:10:26 -0000
@@ -62,8 +62,9 @@
int limit, int position, int mark,
boolean readOnly)
{
- super (limit, limit, offset, position);
+ super (limit >> 3, limit >> 3, position >> 3, mark >> 3);
this.bb = bb;
+ this.offset = offset;
this.readOnly = readOnly;
// FIXME: What if this is called from LongViewBufferImpl and ByteBuffer has changed its endianess ?
this.endian = bb.order ();
@@ -71,25 +72,26 @@
public long get ()
{
- long result = bb.getLong ((position () >> 3) + offset);
+ long result = bb.getLong ((position () << 3) + offset);
position (position () + 1);
return result;
}
public long get (int index)
{
- return bb.getLong ((index >> 3) + offset);
+ return bb.getLong ((index << 3) + offset);
}
public LongBuffer put (long value)
{
- bb.putLong ((position () >> 3) + offset, value);
+ bb.putLong ((position () << 3) + offset, value);
+ position (position () + 1);
return this;
}
public LongBuffer put (int index, long value)
{
- bb.putLong ((index >> 3) + offset, value);
+ bb.putLong ((index << 3) + offset, value);
return this;
}
Index: gnu/java/nio/ShortViewBufferImpl.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/gnu/java/nio/ShortViewBufferImpl.java,v
retrieving revision 1.1
diff -u -b -B -r1.1 ShortViewBufferImpl.java
--- gnu/java/nio/ShortViewBufferImpl.java 12 May 2003 18:32:17 -0000 1.1
+++ gnu/java/nio/ShortViewBufferImpl.java 13 May 2003 20:10:26 -0000
@@ -62,8 +62,9 @@
int limit, int position, int mark,
boolean readOnly)
{
- super (limit, limit, offset, position);
+ super (limit >> 1, limit >> 1, position >> 1, mark >> 1);
this.bb = bb;
+ this.offset = offset;
this.readOnly = readOnly;
// FIXME: What if this is called from ShortViewBufferImpl and ByteBuffer has changed its endianess ?
this.endian = bb.order ();
@@ -71,25 +72,26 @@
public short get ()
{
- short result = bb.getShort ((position () >> 1) + offset);
+ short result = bb.getShort ((position () << 1) + offset);
position (position () + 1);
return result;
}
public short get (int index)
{
- return bb.getShort ((index >> 1) + offset);
+ return bb.getShort ((index << 1) + offset);
}
public ShortBuffer put (short value)
{
- bb.putShort ((position () >> 1) + offset, value);
+ bb.putShort ((position () << 1) + offset, value);
+ position (position () + 1);
return this;
}
public ShortBuffer put (int index, short value)
{
- bb.putShort ((index >> 1) + offset, value);
+ bb.putShort ((index << 1) + offset, value);
return this;
}