diff options
Diffstat (limited to 'libjava/java/nio/MappedByteBufferImpl.java')
-rw-r--r-- | libjava/java/nio/MappedByteBufferImpl.java | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/libjava/java/nio/MappedByteBufferImpl.java b/libjava/java/nio/MappedByteBufferImpl.java index c5cf355..bc8ee80 100644 --- a/libjava/java/nio/MappedByteBufferImpl.java +++ b/libjava/java/nio/MappedByteBufferImpl.java @@ -138,9 +138,14 @@ final class MappedByteBufferImpl extends MappedByteBuffer public ByteBuffer slice() { int rem = remaining(); - return new DirectByteBufferImpl + if (isReadOnly()) + return new DirectByteBufferImpl.ReadOnly (this, VMDirectByteBuffer.adjustAddress(address, position()), - rem, rem, 0, isReadOnly()); + rem, rem, 0); + else + return new DirectByteBufferImpl.ReadWrite + (this, VMDirectByteBuffer.adjustAddress(address, position()), + rem, rem, 0); } private ByteBuffer duplicate(boolean readOnly) @@ -149,9 +154,14 @@ final class MappedByteBufferImpl extends MappedByteBuffer reset(); int mark = position(); position(pos); - DirectByteBufferImpl result - = new DirectByteBufferImpl(this, address, capacity(), limit(), - pos, readOnly); + DirectByteBufferImpl result; + if (readOnly) + result = new DirectByteBufferImpl.ReadOnly(this, address, capacity(), + limit(), pos); + else + result = new DirectByteBufferImpl.ReadWrite(this, address, capacity(), + limit(), pos); + if (mark != pos) { result.position(mark); |