summaryrefslogtreecommitdiffstats
path: root/libjava/classpath/java/nio
diff options
context:
space:
mode:
Diffstat (limited to 'libjava/classpath/java/nio')
-rw-r--r--libjava/classpath/java/nio/Buffer.java18
-rw-r--r--libjava/classpath/java/nio/ByteBuffer.java16
-rw-r--r--libjava/classpath/java/nio/ByteBufferImpl.java18
-rw-r--r--libjava/classpath/java/nio/CharBuffer.java18
-rw-r--r--libjava/classpath/java/nio/CharBufferImpl.java12
-rw-r--r--libjava/classpath/java/nio/CharSequenceBuffer.java9
-rw-r--r--libjava/classpath/java/nio/CharViewBufferImpl.java20
-rw-r--r--libjava/classpath/java/nio/DirectByteBufferImpl.java6
-rw-r--r--libjava/classpath/java/nio/DoubleBuffer.java15
-rw-r--r--libjava/classpath/java/nio/DoubleBufferImpl.java18
-rw-r--r--libjava/classpath/java/nio/DoubleViewBufferImpl.java18
-rw-r--r--libjava/classpath/java/nio/FloatBuffer.java15
-rw-r--r--libjava/classpath/java/nio/FloatBufferImpl.java9
-rw-r--r--libjava/classpath/java/nio/FloatViewBufferImpl.java18
-rw-r--r--libjava/classpath/java/nio/IntBuffer.java18
-rw-r--r--libjava/classpath/java/nio/IntBufferImpl.java6
-rw-r--r--libjava/classpath/java/nio/IntViewBufferImpl.java18
-rw-r--r--libjava/classpath/java/nio/LongBuffer.java15
-rw-r--r--libjava/classpath/java/nio/LongBufferImpl.java18
-rw-r--r--libjava/classpath/java/nio/LongViewBufferImpl.java18
-rw-r--r--libjava/classpath/java/nio/MappedByteBuffer.java8
-rw-r--r--libjava/classpath/java/nio/MappedByteBufferImpl.java5
-rw-r--r--libjava/classpath/java/nio/ShortBuffer.java16
-rw-r--r--libjava/classpath/java/nio/ShortBufferImpl.java18
-rw-r--r--libjava/classpath/java/nio/ShortViewBufferImpl.java18
-rw-r--r--libjava/classpath/java/nio/channels/FileLock.java5
26 files changed, 205 insertions, 168 deletions
diff --git a/libjava/classpath/java/nio/Buffer.java b/libjava/classpath/java/nio/Buffer.java
index c2569eea975..fce60c88ce2 100644
--- a/libjava/classpath/java/nio/Buffer.java
+++ b/libjava/classpath/java/nio/Buffer.java
@@ -45,19 +45,21 @@ import gnu.classpath.Pointer;
*/
public abstract class Buffer
{
- int cap = 0;
- int limit = 0;
- int pos = 0;
- int mark = -1;
- Pointer address;
+ private final int cap;
+ int limit;
+ int pos;
+ int mark;
+ final Pointer address;
/**
* Creates a new Buffer.
*
* Should be package private.
*/
- Buffer (int capacity, int limit, int position, int mark)
+ Buffer (int capacity, int limit, int position, int mark, Pointer address)
{
+ this.address = address;
+
if (capacity < 0)
throw new IllegalArgumentException ();
@@ -72,6 +74,10 @@ public abstract class Buffer
this.mark = mark;
}
+ else
+ {
+ this.mark = -1;
+ }
}
/**
diff --git a/libjava/classpath/java/nio/ByteBuffer.java b/libjava/classpath/java/nio/ByteBuffer.java
index 78ad4471836..94aae4bf021 100644
--- a/libjava/classpath/java/nio/ByteBuffer.java
+++ b/libjava/classpath/java/nio/ByteBuffer.java
@@ -38,6 +38,10 @@ exception statement from your version. */
package java.nio;
+// GCJ LOCAL: Change gnu.classpath.Pointer to RawData
+import gnu.gcj.RawData;
+import gnu.classpath.Pointer;
+
/**
* @since 1.4
*/
@@ -45,13 +49,15 @@ public abstract class ByteBuffer extends Buffer
implements Comparable<ByteBuffer>
{
ByteOrder endian = ByteOrder.BIG_ENDIAN;
+ final byte[] backing_buffer;
+ final int array_offset;
- int array_offset;
- byte[] backing_buffer;
-
- ByteBuffer (int capacity, int limit, int position, int mark)
+ ByteBuffer (int capacity, int limit, int position, int mark,
+ RawData address, byte[] backing_buffer, int array_offset)
{
- super (capacity, limit, position, mark);
+ super (capacity, limit, position, mark, address);
+ this.backing_buffer = backing_buffer;
+ this.array_offset = array_offset;
}
/**
diff --git a/libjava/classpath/java/nio/ByteBufferImpl.java b/libjava/classpath/java/nio/ByteBufferImpl.java
index aa51a65bdd5..6a1ac4681da 100644
--- a/libjava/classpath/java/nio/ByteBufferImpl.java
+++ b/libjava/classpath/java/nio/ByteBufferImpl.java
@@ -43,13 +43,12 @@ package java.nio;
*/
final class ByteBufferImpl extends ByteBuffer
{
- private boolean readOnly;
+ private final boolean readOnly;
- ByteBufferImpl (byte[] buffer, int offset, int capacity, int limit, int position, int mark, boolean readOnly)
+ ByteBufferImpl (byte[] buffer, int offset, int capacity, int limit,
+ int position, int mark, boolean readOnly)
{
- super (capacity, limit, position, mark);
- this.backing_buffer = buffer;
- this.array_offset = offset;
+ super (capacity, limit, position, mark, null, buffer, offset);
this.readOnly = readOnly;
}
@@ -90,17 +89,20 @@ final class ByteBufferImpl extends ByteBuffer
public ByteBuffer slice ()
{
- return new ByteBufferImpl (backing_buffer, array_offset + position (), remaining (), remaining (), 0, -1, isReadOnly ());
+ return new ByteBufferImpl (backing_buffer, array_offset + position (),
+ remaining (), remaining (), 0, -1, isReadOnly ());
}
public ByteBuffer duplicate ()
{
- return new ByteBufferImpl (backing_buffer, array_offset, capacity (), limit (), position (), mark, isReadOnly ());
+ return new ByteBufferImpl (backing_buffer, array_offset, capacity (),
+ limit (), position (), mark, isReadOnly ());
}
public ByteBuffer asReadOnlyBuffer ()
{
- return new ByteBufferImpl (backing_buffer, array_offset, capacity (), limit (), position (), mark, true);
+ return new ByteBufferImpl (backing_buffer, array_offset, capacity (),
+ limit (), position (), mark, true);
}
void shiftDown (int dst_offset, int src_offset, int count)
diff --git a/libjava/classpath/java/nio/CharBuffer.java b/libjava/classpath/java/nio/CharBuffer.java
index 2feada4c817..969b5bb3df3 100644
--- a/libjava/classpath/java/nio/CharBuffer.java
+++ b/libjava/classpath/java/nio/CharBuffer.java
@@ -38,6 +38,9 @@ exception statement from your version. */
package java.nio;
+// GCJ LOCAL: Use RawData instead of gnu.classpath.Pointer
+import gnu.gcj.RawData;
+
import java.io.IOException;
/**
@@ -46,13 +49,15 @@ import java.io.IOException;
public abstract class CharBuffer extends Buffer
implements Comparable<CharBuffer>, CharSequence, Readable, Appendable
{
- int array_offset;
- char[] backing_buffer;
+ final int array_offset;
+ final char[] backing_buffer;
- CharBuffer (int capacity, int limit, int position, int mark)
+ CharBuffer (int capacity, int limit, int position, int mark,
+ RawData address, char[] backing_buffer, int array_offset)
{
- super (capacity, limit, position, mark);
- array_offset = 0;
+ super (capacity, limit, position, mark, address);
+ this.backing_buffer = backing_buffer;
+ this.array_offset = array_offset;
}
/**
@@ -78,7 +83,8 @@ public abstract class CharBuffer extends Buffer
*/
public static final CharBuffer wrap(char[] array, int offset, int length)
{
- return new CharBufferImpl(array, 0, array.length, offset + length, offset, -1, false);
+ return new CharBufferImpl(array, 0, array.length, offset + length, offset,
+ -1, false);
}
/**
diff --git a/libjava/classpath/java/nio/CharBufferImpl.java b/libjava/classpath/java/nio/CharBufferImpl.java
index e6097cb7516..d35ca5962f1 100644
--- a/libjava/classpath/java/nio/CharBufferImpl.java
+++ b/libjava/classpath/java/nio/CharBufferImpl.java
@@ -43,7 +43,7 @@ package java.nio;
*/
final class CharBufferImpl extends CharBuffer
{
- private boolean readOnly;
+ private final boolean readOnly;
CharBufferImpl (int capacity)
{
@@ -52,18 +52,14 @@ final class CharBufferImpl extends CharBuffer
CharBufferImpl (char[] buffer, int offset, int capacity, int limit, int position, int mark, boolean readOnly)
{
- super (capacity, limit, position, mark);
- this.backing_buffer = buffer;
- this.array_offset = offset;
+ super (capacity, limit, position, mark, null, buffer, offset);
this.readOnly = readOnly;
}
public CharBufferImpl (CharBufferImpl copy)
{
- super (copy.capacity (), copy.limit (), copy.position (), 0);
- backing_buffer = copy.backing_buffer;
- array_offset = copy.array_offset;
- readOnly = copy.isReadOnly ();
+ super (copy.capacity (), copy.limit (), copy.position (), 0, null, copy.backing_buffer, copy.array_offset);
+ this.readOnly = copy.isReadOnly ();
}
public boolean isReadOnly ()
diff --git a/libjava/classpath/java/nio/CharSequenceBuffer.java b/libjava/classpath/java/nio/CharSequenceBuffer.java
index 26aad1c38ac..3003670d83c 100644
--- a/libjava/classpath/java/nio/CharSequenceBuffer.java
+++ b/libjava/classpath/java/nio/CharSequenceBuffer.java
@@ -48,7 +48,7 @@ final class CharSequenceBuffer
/**
* The wrapped char sequence.
*/
- private CharSequence charSequence;
+ private final CharSequence charSequence;
/**
* Creates a new CharSequenceBuffer.
@@ -63,9 +63,8 @@ final class CharSequenceBuffer
CharSequenceBuffer(CharSequence charSeq, int capacity, int limit,
int position, int mark, int offs)
{
- super(capacity, limit, position, mark);
- charSequence = charSeq;
- array_offset = offs;
+ super(capacity, limit, position, mark, null, null, offs);
+ this.charSequence = charSeq;
}
/**
@@ -105,7 +104,7 @@ final class CharSequenceBuffer
*/
public CharBuffer duplicate()
{
- return new CharSequenceBuffer(charSequence, cap, limit, pos, mark, 0);
+ return new CharSequenceBuffer(charSequence, capacity(), limit, pos, mark, 0);
}
/**
diff --git a/libjava/classpath/java/nio/CharViewBufferImpl.java b/libjava/classpath/java/nio/CharViewBufferImpl.java
index 33bbac8b000..98a27a6e601 100644
--- a/libjava/classpath/java/nio/CharViewBufferImpl.java
+++ b/libjava/classpath/java/nio/CharViewBufferImpl.java
@@ -41,33 +41,33 @@ package java.nio;
class CharViewBufferImpl extends CharBuffer
{
/** Position in bb (i.e. a byte offset) where this buffer starts. */
- private int offset;
- private ByteBuffer bb;
- private boolean readOnly;
- private ByteOrder endian;
+ private final int offset;
+ private final ByteBuffer bb;
+ private final boolean readOnly;
+ private final ByteOrder endian;
CharViewBufferImpl (ByteBuffer bb, int capacity)
{
- super (capacity, capacity, 0, -1);
+ super (capacity, capacity, 0, -1, bb.isDirect() ?
+ VMDirectByteBuffer.adjustAddress(bb.address, bb.position()) : null,
+ null, 0);
this.bb = bb;
this.offset = bb.position();
this.readOnly = bb.isReadOnly();
this.endian = bb.order();
- if (bb.isDirect())
- this.address = VMDirectByteBuffer.adjustAddress(bb.address, offset);
}
public CharViewBufferImpl (ByteBuffer bb, int offset, int capacity,
int limit, int position, int mark,
boolean readOnly, ByteOrder endian)
{
- super (capacity, limit, position, mark);
+ super (capacity, limit, position, mark, bb.isDirect() ?
+ VMDirectByteBuffer.adjustAddress(bb.address, offset) : null,
+ null, 0);
this.bb = bb;
this.offset = offset;
this.readOnly = readOnly;
this.endian = endian;
- if (bb.isDirect())
- this.address = VMDirectByteBuffer.adjustAddress(bb.address, offset);
}
/**
diff --git a/libjava/classpath/java/nio/DirectByteBufferImpl.java b/libjava/classpath/java/nio/DirectByteBufferImpl.java
index 8c907f597f0..60df3611ac9 100644
--- a/libjava/classpath/java/nio/DirectByteBufferImpl.java
+++ b/libjava/classpath/java/nio/DirectByteBufferImpl.java
@@ -104,18 +104,16 @@ abstract class DirectByteBufferImpl extends ByteBuffer
DirectByteBufferImpl(int capacity)
{
- super(capacity, capacity, 0, -1);
+ super(capacity, capacity, 0, -1, VMDirectByteBuffer.allocate(capacity), null, 0);
this.owner = this;
- this.address = VMDirectByteBuffer.allocate(capacity);
}
DirectByteBufferImpl(Object owner, Pointer address,
int capacity, int limit,
int position)
{
- super(capacity, limit, position, -1);
+ super(capacity, limit, position, -1, address, null, 0);
this.owner = owner;
- this.address = address;
}
/**
diff --git a/libjava/classpath/java/nio/DoubleBuffer.java b/libjava/classpath/java/nio/DoubleBuffer.java
index be7861cbd5e..1a51f1889be 100644
--- a/libjava/classpath/java/nio/DoubleBuffer.java
+++ b/libjava/classpath/java/nio/DoubleBuffer.java
@@ -38,19 +38,24 @@ exception statement from your version. */
package java.nio;
+// GCJ LOCAL: Change gnu.classpath.Pointer to RawData
+import gnu.gcj.RawData;
+
/**
* @since 1.4
*/
public abstract class DoubleBuffer extends Buffer
implements Comparable<DoubleBuffer>
{
- int array_offset;
- double[] backing_buffer;
+ final int array_offset;
+ final double[] backing_buffer;
- DoubleBuffer (int capacity, int limit, int position, int mark)
+ DoubleBuffer (int capacity, int limit, int position, int mark,
+ RawData address, double[] backing_buffer, int array_offset)
{
- super (capacity, limit, position, mark);
- array_offset = 0;
+ super (capacity, limit, position, mark, address);
+ this.backing_buffer = backing_buffer;
+ this.array_offset = array_offset;
}
/**
diff --git a/libjava/classpath/java/nio/DoubleBufferImpl.java b/libjava/classpath/java/nio/DoubleBufferImpl.java
index 98e8e974fff..bc292df646d 100644
--- a/libjava/classpath/java/nio/DoubleBufferImpl.java
+++ b/libjava/classpath/java/nio/DoubleBufferImpl.java
@@ -43,18 +43,17 @@ package java.nio;
*/
final class DoubleBufferImpl extends DoubleBuffer
{
- private boolean readOnly;
+ private final boolean readOnly;
DoubleBufferImpl (int capacity)
{
this (new double [capacity], 0, capacity, capacity, 0, -1, false);
}
- DoubleBufferImpl (double[] buffer, int offset, int capacity, int limit, int position, int mark, boolean readOnly)
+ DoubleBufferImpl (double[] buffer, int offset, int capacity, int limit,
+ int position, int mark, boolean readOnly)
{
- super (capacity, limit, position, mark);
- this.backing_buffer = buffer;
- this.array_offset = offset;
+ super (capacity, limit, position, mark, null, buffer, offset);
this.readOnly = readOnly;
}
@@ -65,17 +64,20 @@ final class DoubleBufferImpl extends DoubleBuffer
public DoubleBuffer slice ()
{
- return new DoubleBufferImpl (backing_buffer, array_offset + position (), remaining (), remaining (), 0, -1, isReadOnly ());
+ return new DoubleBufferImpl (backing_buffer, array_offset + position (),
+ remaining (), remaining (), 0, -1, isReadOnly ());
}
public DoubleBuffer duplicate ()
{
- return new DoubleBufferImpl (backing_buffer, array_offset, capacity (), limit (), position (), mark, isReadOnly ());
+ return new DoubleBufferImpl (backing_buffer, array_offset, capacity (),
+ limit (), position (), mark, isReadOnly ());
}
public DoubleBuffer asReadOnlyBuffer ()
{
- return new DoubleBufferImpl (backing_buffer, array_offset, capacity (), limit (), position (), mark, true);
+ return new DoubleBufferImpl (backing_buffer, array_offset, capacity (),
+ limit (), position (), mark, true);
}
public DoubleBuffer compact ()
diff --git a/libjava/classpath/java/nio/DoubleViewBufferImpl.java b/libjava/classpath/java/nio/DoubleViewBufferImpl.java
index d1399154a71..d82fa92c4a7 100644
--- a/libjava/classpath/java/nio/DoubleViewBufferImpl.java
+++ b/libjava/classpath/java/nio/DoubleViewBufferImpl.java
@@ -41,33 +41,31 @@ package java.nio;
final class DoubleViewBufferImpl extends DoubleBuffer
{
/** Position in bb (i.e. a byte offset) where this buffer starts. */
- private int offset;
- private ByteBuffer bb;
- private boolean readOnly;
- private ByteOrder endian;
+ private final int offset;
+ private final ByteBuffer bb;
+ private final boolean readOnly;
+ private final ByteOrder endian;
DoubleViewBufferImpl (ByteBuffer bb, int capacity)
{
- super (capacity, capacity, 0, -1);
+ super (capacity, capacity, 0, -1, bb.isDirect() ?
+ VMDirectByteBuffer.adjustAddress(bb.address, bb.position()) : null, null, 0);
this.bb = bb;
this.offset = bb.position();
this.readOnly = bb.isReadOnly();
this.endian = bb.order();
- if (bb.isDirect())
- this.address = VMDirectByteBuffer.adjustAddress(bb.address, offset);
}
public DoubleViewBufferImpl (ByteBuffer bb, int offset, int capacity,
int limit, int position, int mark,
boolean readOnly, ByteOrder endian)
{
- super (capacity, limit, position, mark);
+ super (capacity, limit, position, mark, bb.isDirect() ?
+ VMDirectByteBuffer.adjustAddress(bb.address, bb.position()) : null, null, 0);
this.bb = bb;
this.offset = offset;
this.readOnly = readOnly;
this.endian = endian;
- if (bb.isDirect())
- this.address = VMDirectByteBuffer.adjustAddress(bb.address, offset);
}
/**
diff --git a/libjava/classpath/java/nio/FloatBuffer.java b/libjava/classpath/java/nio/FloatBuffer.java
index 62e353a6818..ce40a09e37b 100644
--- a/libjava/classpath/java/nio/FloatBuffer.java
+++ b/libjava/classpath/java/nio/FloatBuffer.java
@@ -38,19 +38,24 @@ exception statement from your version. */
package java.nio;
+// GCJ LOCAL: Change gnu.classpath.Pointer to RawData
+import gnu.gcj.RawData;
+
/**
* @since 1.4
*/
public abstract class FloatBuffer extends Buffer
implements Comparable<FloatBuffer>
{
- int array_offset;
- float[] backing_buffer;
+ final int array_offset;
+ final float[] backing_buffer;
- FloatBuffer (int capacity, int limit, int position, int mark)
+ FloatBuffer (int capacity, int limit, int position, int mark,
+ RawData address, float[] backing_buffer, int array_offset)
{
- super (capacity, limit, position, mark);
- array_offset = 0;
+ super (capacity, limit, position, mark, address);
+ this.backing_buffer = backing_buffer;
+ this.array_offset = array_offset;
}
/**
diff --git a/libjava/classpath/java/nio/FloatBufferImpl.java b/libjava/classpath/java/nio/FloatBufferImpl.java
index f1182ba38f3..5d0e7ca8590 100644
--- a/libjava/classpath/java/nio/FloatBufferImpl.java
+++ b/libjava/classpath/java/nio/FloatBufferImpl.java
@@ -43,18 +43,17 @@ package java.nio;
*/
final class FloatBufferImpl extends FloatBuffer
{
- private boolean readOnly;
+ private final boolean readOnly;
FloatBufferImpl (int capacity)
{
this (new float [capacity], 0, capacity, capacity, 0, -1, false);
}
- FloatBufferImpl (float[] buffer, int offset, int capacity, int limit, int position, int mark, boolean readOnly)
+ FloatBufferImpl (float[] buffer, int offset, int capacity, int limit,
+ int position, int mark, boolean readOnly)
{
- super (capacity, limit, position, mark);
- this.backing_buffer = buffer;
- this.array_offset = offset;
+ super (capacity, limit, position, mark, null, buffer, offset);
this.readOnly = readOnly;
}
diff --git a/libjava/classpath/java/nio/FloatViewBufferImpl.java b/libjava/classpath/java/nio/FloatViewBufferImpl.java
index 8bb342d103d..9f10d824fe0 100644
--- a/libjava/classpath/java/nio/FloatViewBufferImpl.java
+++ b/libjava/classpath/java/nio/FloatViewBufferImpl.java
@@ -41,33 +41,31 @@ package java.nio;
final class FloatViewBufferImpl extends FloatBuffer
{
/** Position in bb (i.e. a byte offset) where this buffer starts. */
- private int offset;
- private ByteBuffer bb;
- private boolean readOnly;
- private ByteOrder endian;
+ private final int offset;
+ private final ByteBuffer bb;
+ private final boolean readOnly;
+ private final ByteOrder endian;
FloatViewBufferImpl (ByteBuffer bb, int capacity)
{
- super (capacity, capacity, 0, -1);
+ super (capacity, capacity, 0, -1, bb.isDirect() ?
+ VMDirectByteBuffer.adjustAddress(bb.address, bb.position()):null, null, 0);
this.bb = bb;
this.offset = bb.position();
this.readOnly = bb.isReadOnly();
this.endian = bb.order();
- if (bb.isDirect())
- this.address = VMDirectByteBuffer.adjustAddress(bb.address, offset);
}
public FloatViewBufferImpl (ByteBuffer bb, int offset, int capacity,
int limit, int position, int mark,
boolean readOnly, ByteOrder endian)
{
- super (capacity, limit, position, mark);
+ super (capacity, limit, position, mark, bb.isDirect() ?
+ VMDirectByteBuffer.adjustAddress(bb.address, offset):null, null, 0);
this.bb = bb;
this.offset = offset;
this.readOnly = readOnly;
this.endian = endian;
- if (bb.isDirect())
- this.address = VMDirectByteBuffer.adjustAddress(bb.address, offset);
}
/**
diff --git a/libjava/classpath/java/nio/IntBuffer.java b/libjava/classpath/java/nio/IntBuffer.java
index d6fcb51ddf0..9234c33ef6d 100644
--- a/libjava/classpath/java/nio/IntBuffer.java
+++ b/libjava/classpath/java/nio/IntBuffer.java
@@ -38,19 +38,24 @@ exception statement from your version. */
package java.nio;
+// GCJ LOCAL: Change gnu.classpath.Pointer to RawData
+import gnu.gcj.RawData;
+
/**
* @since 1.4
*/
public abstract class IntBuffer extends Buffer
implements Comparable<IntBuffer>
{
- int array_offset;
- int[] backing_buffer;
+ final int array_offset;
+ final int[] backing_buffer;
- IntBuffer (int capacity, int limit, int position, int mark)
+ IntBuffer (int capacity, int limit, int position, int mark, RawData address,
+ int[] backing_buffer, int array_offset)
{
- super (capacity, limit, position, mark);
- array_offset = 0;
+ super (capacity, limit, position, mark, address);
+ this.backing_buffer = backing_buffer;
+ this.array_offset = array_offset;
}
/**
@@ -70,7 +75,8 @@ public abstract class IntBuffer extends Buffer
*/
public static final IntBuffer wrap (int[] array, int offset, int length)
{
- return new IntBufferImpl (array, 0, array.length, offset + length, offset, -1, false);
+ return new IntBufferImpl (array, 0, array.length, offset + length, offset,
+ -1, false);
}
/**
diff --git a/libjava/classpath/java/nio/IntBufferImpl.java b/libjava/classpath/java/nio/IntBufferImpl.java
index 2bd1842440e..c332715fbda 100644
--- a/libjava/classpath/java/nio/IntBufferImpl.java
+++ b/libjava/classpath/java/nio/IntBufferImpl.java
@@ -43,7 +43,7 @@ package java.nio;
*/
final class IntBufferImpl extends IntBuffer
{
- private boolean readOnly;
+ private final boolean readOnly;
IntBufferImpl (int capacity)
{
@@ -52,9 +52,7 @@ final class IntBufferImpl extends IntBuffer
IntBufferImpl (int[] buffer, int offset, int capacity, int limit, int position, int mark, boolean readOnly)
{
- super (capacity, limit, position, mark);
- this.backing_buffer = buffer;
- this.array_offset = offset;
+ super (capacity, limit, position, mark, null, buffer, offset);
this.readOnly = readOnly;
}
diff --git a/libjava/classpath/java/nio/IntViewBufferImpl.java b/libjava/classpath/java/nio/IntViewBufferImpl.java
index cd8307f3ebd..9af5d58a4dc 100644
--- a/libjava/classpath/java/nio/IntViewBufferImpl.java
+++ b/libjava/classpath/java/nio/IntViewBufferImpl.java
@@ -41,33 +41,31 @@ package java.nio;
final class IntViewBufferImpl extends IntBuffer
{
/** Position in bb (i.e. a byte offset) where this buffer starts. */
- private int offset;
- private ByteBuffer bb;
- private boolean readOnly;
- private ByteOrder endian;
+ private final int offset;
+ private final ByteBuffer bb;
+ private final boolean readOnly;
+ private final ByteOrder endian;
IntViewBufferImpl (ByteBuffer bb, int capacity)
{
- super (capacity, capacity, 0, -1);
+ super (capacity, capacity, 0, -1, bb.isDirect() ?
+ VMDirectByteBuffer.adjustAddress(bb.address, bb.position()):null, null, 0);
this.bb = bb;
this.offset = bb.position();
this.readOnly = bb.isReadOnly();
this.endian = bb.order();
- if (bb.isDirect())
- this.address = VMDirectByteBuffer.adjustAddress(bb.address, offset);
}
public IntViewBufferImpl (ByteBuffer bb, int offset, int capacity,
int limit, int position, int mark,
boolean readOnly, ByteOrder endian)
{
- super (capacity, limit, position, mark);
+ super (capacity, limit, position, mark, bb.isDirect() ?
+ VMDirectByteBuffer.adjustAddress(bb.address, offset):null, null, 0);
this.bb = bb;
this.offset = offset;
this.readOnly = readOnly;
this.endian = endian;
- if (bb.isDirect())
- this.address = VMDirectByteBuffer.adjustAddress(bb.address, offset);
}
/**
diff --git a/libjava/classpath/java/nio/LongBuffer.java b/libjava/classpath/java/nio/LongBuffer.java
index 9c3bfa62741..1195cc88ce2 100644
--- a/libjava/classpath/java/nio/LongBuffer.java
+++ b/libjava/classpath/java/nio/LongBuffer.java
@@ -38,19 +38,24 @@ exception statement from your version. */
package java.nio;
+// GCJ LOCAL: Change gnu.classpath.Pointer to RawData
+import gnu.gcj.RawData;
+
/**
* @since 1.4
*/
public abstract class LongBuffer extends Buffer
implements Comparable<LongBuffer>
{
- int array_offset;
- long[] backing_buffer;
+ final int array_offset;
+ final long[] backing_buffer;
- LongBuffer (int capacity, int limit, int position, int mark)
+ LongBuffer (int capacity, int limit, int position, int mark,
+ RawData address, long[] backing_buffer, int array_offset)
{
- super (capacity, limit, position, mark);
- array_offset = 0;
+ super (capacity, limit, position, mark, address);
+ this.backing_buffer = backing_buffer;
+ this.array_offset = array_offset;
}
/**
diff --git a/libjava/classpath/java/nio/LongBufferImpl.java b/libjava/classpath/java/nio/LongBufferImpl.java
index c04c41775a9..4cf922b149d 100644
--- a/libjava/classpath/java/nio/LongBufferImpl.java
+++ b/libjava/classpath/java/nio/LongBufferImpl.java
@@ -43,18 +43,17 @@ package java.nio;
*/
final class LongBufferImpl extends LongBuffer
{
- private boolean readOnly;
+ private final boolean readOnly;
LongBufferImpl (int capacity)
{
this (new long [capacity], 0, capacity, capacity, 0, -1, false);
}
- LongBufferImpl (long[] buffer, int offset, int capacity, int limit, int position, int mark, boolean readOnly)
+ LongBufferImpl (long[] buffer, int offset, int capacity, int limit,
+ int position, int mark, boolean readOnly)
{
- super (capacity, limit, position, mark);
- this.backing_buffer = buffer;
- this.array_offset = offset;
+ super (capacity, limit, position, mark, null, buffer, offset);
this.readOnly = readOnly;
}
@@ -65,17 +64,20 @@ final class LongBufferImpl extends LongBuffer
public LongBuffer slice ()
{
- return new LongBufferImpl (backing_buffer, array_offset + position (), remaining (), remaining (), 0, -1, isReadOnly ());
+ return new LongBufferImpl (backing_buffer, array_offset + position (),
+ remaining (), remaining (), 0, -1, isReadOnly ());
}
public LongBuffer duplicate ()
{
- return new LongBufferImpl (backing_buffer, array_offset, capacity (), limit (), position (), mark, isReadOnly ());
+ return new LongBufferImpl (backing_buffer, array_offset, capacity (), limit (),
+ position (), mark, isReadOnly ());
}
public LongBuffer asReadOnlyBuffer ()
{
- return new LongBufferImpl (backing_buffer, array_offset, capacity (), limit (), position (), mark, true);
+ return new LongBufferImpl (backing_buffer, array_offset, capacity (), limit (),
+ position (), mark, true);
}
public LongBuffer compact ()
diff --git a/libjava/classpath/java/nio/LongViewBufferImpl.java b/libjava/classpath/java/nio/LongViewBufferImpl.java
index eefbcbdc8dd..b775a99462f 100644
--- a/libjava/classpath/java/nio/LongViewBufferImpl.java
+++ b/libjava/classpath/java/nio/LongViewBufferImpl.java
@@ -41,33 +41,31 @@ package java.nio;
final class LongViewBufferImpl extends LongBuffer
{
/** Position in bb (i.e. a byte offset) where this buffer starts. */
- private int offset;
- private ByteBuffer bb;
- private boolean readOnly;
- private ByteOrder endian;
+ private final int offset;
+ private final ByteBuffer bb;
+ private final boolean readOnly;
+ private final ByteOrder endian;
LongViewBufferImpl (ByteBuffer bb, int capacity)
{
- super (capacity, capacity, 0, -1);
+ super (capacity, capacity, 0, -1, bb.isDirect() ?
+ VMDirectByteBuffer.adjustAddress(bb.address, bb.position()):null, null, 0);
this.bb = bb;
this.offset = bb.position();
this.readOnly = bb.isReadOnly();
this.endian = bb.order();
- if (bb.isDirect())
- this.address = VMDirectByteBuffer.adjustAddress(bb.address, offset);
}
public LongViewBufferImpl (ByteBuffer bb, int offset, int capacity,
int limit, int position, int mark,
boolean readOnly, ByteOrder endian)
{
- super (capacity, limit, position, mark);
+ super (capacity, limit, position, mark, bb.isDirect() ?
+ VMDirectByteBuffer.adjustAddress(bb.address, offset):null, null, 0);
this.bb = bb;
this.offset = offset;
this.readOnly = readOnly;
this.endian = endian;
- if (bb.isDirect())
- this.address = VMDirectByteBuffer.adjustAddress(bb.address, offset);
}
/**
diff --git a/libjava/classpath/java/nio/MappedByteBuffer.java b/libjava/classpath/java/nio/MappedByteBuffer.java
index 25b0993079a..1f82f823f5a 100644
--- a/libjava/classpath/java/nio/MappedByteBuffer.java
+++ b/libjava/classpath/java/nio/MappedByteBuffer.java
@@ -38,15 +38,19 @@ exception statement from your version. */
package java.nio;
+// GCJ LOCAL: Use RawData instead of gnu.classpath.Pointer
+import gnu.gcj.RawData;
+
/**
* @author Michael Koch (konqueror@gmx.de)
* @since 1.4
*/
public abstract class MappedByteBuffer extends ByteBuffer
{
- MappedByteBuffer (int capacity, int limit, int position, int mark)
+ MappedByteBuffer (int capacity, int limit, int position, int mark,
+ RawData address)
{
- super (capacity, limit, position, mark);
+ super (capacity, limit, position, mark, address, null, 0);
}
void forceImpl()
diff --git a/libjava/classpath/java/nio/MappedByteBufferImpl.java b/libjava/classpath/java/nio/MappedByteBufferImpl.java
index a53040f576c..f11d1e72eb2 100644
--- a/libjava/classpath/java/nio/MappedByteBufferImpl.java
+++ b/libjava/classpath/java/nio/MappedByteBufferImpl.java
@@ -44,7 +44,7 @@ import java.io.IOException;
final class MappedByteBufferImpl extends MappedByteBuffer
{
- boolean readOnly;
+ private final boolean readOnly;
/** Posix uses this for the pointer returned by mmap;
* Win32 uses it for the pointer returned by MapViewOfFile. */
@@ -56,8 +56,7 @@ final class MappedByteBufferImpl extends MappedByteBuffer
public MappedByteBufferImpl(Pointer address, int size, boolean readOnly)
throws IOException
{
- super(size, size, 0, -1);
- this.address = address;
+ super(size, size, 0, -1, address);
this.readOnly = readOnly;
}
diff --git a/libjava/classpath/java/nio/ShortBuffer.java b/libjava/classpath/java/nio/ShortBuffer.java
index 33e458a4b1e..f15c0635577 100644
--- a/libjava/classpath/java/nio/ShortBuffer.java
+++ b/libjava/classpath/java/nio/ShortBuffer.java
@@ -38,19 +38,25 @@ exception statement from your version. */
package java.nio;
+// GCJ LOCAL: Use RawData instead of gnu.classpath.Pointer
+import gnu.gcj.RawData;
+
/**
* @since 1.4
*/
public abstract class ShortBuffer extends Buffer
implements Comparable<ShortBuffer>
{
- int array_offset;
- short[] backing_buffer;
+ final int array_offset;
+ final short[] backing_buffer;
- ShortBuffer (int capacity, int limit, int position, int mark)
+ ShortBuffer (int capacity, int limit, int position,
+ int mark, RawData address, short[] backing_buffer,
+ int array_offset)
{
- super (capacity, limit, position, mark);
- array_offset = 0;
+ super (capacity, limit, position, mark, address);
+ this.backing_buffer = backing_buffer;
+ this.array_offset = array_offset;
}
/**
diff --git a/libjava/classpath/java/nio/ShortBufferImpl.java b/libjava/classpath/java/nio/ShortBufferImpl.java
index 50f65ecbfc0..3a8ff57f822 100644
--- a/libjava/classpath/java/nio/ShortBufferImpl.java
+++ b/libjava/classpath/java/nio/ShortBufferImpl.java
@@ -43,18 +43,17 @@ package java.nio;
*/
final class ShortBufferImpl extends ShortBuffer
{
- private boolean readOnly;
+ private final boolean readOnly;
ShortBufferImpl (int capacity)
{
this (new short [capacity], 0, capacity, capacity, 0, -1, false);
}
- ShortBufferImpl (short[] buffer, int offset, int capacity, int limit, int position, int mark, boolean readOnly)
+ ShortBufferImpl (short[] buffer, int offset, int capacity,
+ int limit, int position, int mark, boolean readOnly)
{
- super (capacity, limit, position, mark);
- this.backing_buffer = buffer;
- this.array_offset = offset;
+ super (capacity, limit, position, mark, null, buffer, offset);
this.readOnly = readOnly;
}
@@ -65,17 +64,20 @@ final class ShortBufferImpl extends ShortBuffer
public ShortBuffer slice ()
{
- return new ShortBufferImpl (backing_buffer, array_offset + position (), remaining (), remaining (), 0, -1, isReadOnly ());
+ return new ShortBufferImpl (backing_buffer, array_offset + position (),
+ remaining (), remaining (), 0, -1, isReadOnly ());
}
public ShortBuffer duplicate ()
{
- return new ShortBufferImpl (backing_buffer, array_offset, capacity (), limit (), position (), mark, isReadOnly ());
+ return new ShortBufferImpl (backing_buffer, array_offset, capacity (),
+ limit (), position (), mark, isReadOnly ());
}
public ShortBuffer asReadOnlyBuffer ()
{
- return new ShortBufferImpl (backing_buffer, array_offset, capacity (), limit (), position (), mark, true);
+ return new ShortBufferImpl (backing_buffer, array_offset, capacity (), limit (),
+ position (), mark, true);
}
public ShortBuffer compact ()
diff --git a/libjava/classpath/java/nio/ShortViewBufferImpl.java b/libjava/classpath/java/nio/ShortViewBufferImpl.java
index df7133612d2..3c7c7747802 100644
--- a/libjava/classpath/java/nio/ShortViewBufferImpl.java
+++ b/libjava/classpath/java/nio/ShortViewBufferImpl.java
@@ -41,33 +41,31 @@ package java.nio;
final class ShortViewBufferImpl extends ShortBuffer
{
/** Position in bb (i.e. a byte offset) where this buffer starts. */
- private int offset;
- private ByteBuffer bb;
- private boolean readOnly;
- private ByteOrder endian;
+ private final int offset;
+ private final ByteBuffer bb;
+ private final boolean readOnly;
+ private final ByteOrder endian;
ShortViewBufferImpl (ByteBuffer bb, int capacity)
{
- super (capacity, capacity, 0, -1);
+ super (capacity, capacity, 0, -1, bb.isDirect() ?
+ VMDirectByteBuffer.adjustAddress(bb.address, bb.position()):null, null, 0);
this.bb = bb;
this.offset = bb.position();
this.readOnly = bb.isReadOnly();
this.endian = bb.order();
- if (bb.isDirect())
- this.address = VMDirectByteBuffer.adjustAddress(bb.address, offset);
}
public ShortViewBufferImpl (ByteBuffer bb, int offset, int capacity,
int limit, int position, int mark,
boolean readOnly, ByteOrder endian)
{
- super (capacity, limit, position, mark);
+ super (capacity, limit, position, mark, bb.isDirect() ?
+ VMDirectByteBuffer.adjustAddress(bb.address, offset):null, null, 0);
this.bb = bb;
this.offset = offset;
this.readOnly = readOnly;
this.endian = endian;
- if (bb.isDirect())
- this.address = VMDirectByteBuffer.adjustAddress(bb.address, offset);
}
/**
diff --git a/libjava/classpath/java/nio/channels/FileLock.java b/libjava/classpath/java/nio/channels/FileLock.java
index c46695837a7..78210b34d4d 100644
--- a/libjava/classpath/java/nio/channels/FileLock.java
+++ b/libjava/classpath/java/nio/channels/FileLock.java
@@ -37,8 +37,9 @@ exception statement from your version. */
package java.nio.channels;
-import java.io.IOException;
+import gnu.java.lang.CPStringBuilder;
+import java.io.IOException;
/**
* @since 1.4
@@ -132,7 +133,7 @@ public abstract class FileLock
*/
public final String toString()
{
- StringBuffer buf = new StringBuffer(getClass().getName());
+ CPStringBuilder buf = new CPStringBuilder(getClass().getName());
buf.append("[");
buf.append(position);
buf.append(":");
OpenPOWER on IntegriCloud