aboutsummaryrefslogtreecommitdiff
path: root/libjava/java/nio/MappedByteBufferImpl.java
diff options
context:
space:
mode:
authorJeroen Frijters <jeroen@frijters.net>2004-11-24 11:11:46 +0000
committerMichael Koch <mkoch@gcc.gnu.org>2004-11-24 11:11:46 +0000
commitb4345a57d828a55b70d6e5f5f4294c97c6acf304 (patch)
treed8acf142a0fcbab0fee8a725ea47393e31d71943 /libjava/java/nio/MappedByteBufferImpl.java
parent11dde1bb18eaf7a6981bc5e7e46cc7d945d55182 (diff)
downloadgcc-b4345a57d828a55b70d6e5f5f4294c97c6acf304.zip
gcc-b4345a57d828a55b70d6e5f5f4294c97c6acf304.tar.gz
gcc-b4345a57d828a55b70d6e5f5f4294c97c6acf304.tar.bz2
2004-11-24 Jeroen Frijters <address@bogus.example.com>
* java/nio/DirectByteBufferImpl.java (ReadOnly): New inner subclass. (ReadWrite): New inner subclass. (owner): Made final and private. (address): Made final. (DirectByteBufferImpl(int)): New constructor. (DirectByteBufferImpl(Object,RawData,int,int,int)): New constructor. (DirectByteBufferImpl(Object,RawData,int,int,int,boolean)): Removed. (allocate): Modified to instantiate ReadWrite subclass. (finalize): Fixed to only free the buffer, if we own it. (put): Removed read-only check. (slice, duplicate): Modified to instantiate appropriate subclass. (isReadOnly): Removed. * java/nio/MappedByteBufferImpl.java (slice, duplicate): Modified to instantiate appropriate DirectByteBufferImpl subclass. From-SVN: r91147
Diffstat (limited to 'libjava/java/nio/MappedByteBufferImpl.java')
-rw-r--r--libjava/java/nio/MappedByteBufferImpl.java20
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);