diff options
Diffstat (limited to 'libjava/gnu/java/nio/ByteBufferImpl.java')
-rw-r--r-- | libjava/gnu/java/nio/ByteBufferImpl.java | 25 |
1 files changed, 10 insertions, 15 deletions
diff --git a/libjava/gnu/java/nio/ByteBufferImpl.java b/libjava/gnu/java/nio/ByteBufferImpl.java index 7b7f72e5fb0..cc7fabb5941 100644 --- a/libjava/gnu/java/nio/ByteBufferImpl.java +++ b/libjava/gnu/java/nio/ByteBufferImpl.java @@ -53,19 +53,16 @@ import java.nio.ShortBuffer; public final class ByteBufferImpl extends ByteBuffer { private boolean readOnly; - - public ByteBufferImpl (int cap, int off, int lim) + + ByteBufferImpl (int capacity) { - super (cap, lim, off, 0); - this.backing_buffer = new byte [cap]; - readOnly = false; + this (new byte [capacity], 0, capacity, capacity, 0, -1, false); } - - public ByteBufferImpl (byte[] array, int offset, int length) + + ByteBufferImpl (byte[] buffer, int offset, int capacity, int limit, int position, int mark, boolean readOnly) { - super (array.length, length, offset, 0); - this.backing_buffer = array; - readOnly = false; + super (buffer, offset, capacity, limit, position, mark); + this.readOnly = readOnly; } public ByteBufferImpl (ByteBufferImpl copy) @@ -117,19 +114,17 @@ public final class ByteBufferImpl extends ByteBuffer public ByteBuffer slice () { - return new ByteBufferImpl (this); + return new ByteBufferImpl (backing_buffer, array_offset + position (), remaining (), remaining (), 0, -1, isReadOnly ()); } public ByteBuffer duplicate () { - return new ByteBufferImpl (this); + return new ByteBufferImpl (backing_buffer, array_offset, capacity (), limit (), position (), mark, isReadOnly ()); } public ByteBuffer asReadOnlyBuffer () { - ByteBufferImpl a = new ByteBufferImpl (this); - a.readOnly = true; - return a; + return new ByteBufferImpl (backing_buffer, array_offset, capacity (), limit (), position (), mark, true); } public ByteBuffer compact () |