4833719: (bf) Views of MappedByteBuffers are not MappedByteBuffers, and cannot be forced

Reviewed-by: adinn
This commit is contained in:
Brian Burkhalter 2021-03-25 15:30:50 +00:00
parent 8307aa6dcb
commit b006f22f1f
3 changed files with 214 additions and 13 deletions

View file

@ -152,10 +152,20 @@ public abstract class MappedByteBuffer
* @return true if the file was mapped using one of the sync map
* modes, otherwise false.
*/
private boolean isSync() {
final boolean isSync() { // package-private
return isSync;
}
/**
* Returns the {@code FileDescriptor} associated with this
* {@code MappedByteBuffer}.
*
* @return the buffer's file descriptor; may be {@code null}
*/
final FileDescriptor fileDescriptor() { // package-private
return fd;
}
/**
* Tells whether or not this buffer's content is resident in physical
* memory.
@ -205,7 +215,10 @@ public abstract class MappedByteBuffer
/**
* Forces any changes made to this buffer's content to be written to the
* storage device containing the mapped file.
* storage device containing the mapped file. The region starts at index
* zero in this buffer and is {@code capacity()} bytes. An invocation of
* this method behaves in exactly the same way as the invocation
* {@link force(int,int) force(0,capacity())}.
*
* <p> If the file mapped into this buffer resides on a local storage
* device then when this method returns it is guaranteed that all changes
@ -362,4 +375,41 @@ public abstract class MappedByteBuffer
super.rewind();
return this;
}
/**
* {@inheritDoc}
*
* <p> Reading bytes into physical memory by invoking {@code load()} on the
* returned buffer, or writing bytes to the storage device by invoking
* {@code force()} on the returned buffer, will only act on the sub-range
* of this buffer that the returned buffer represents, namely
* {@code [position(),limit())}.
*/
@Override
public abstract MappedByteBuffer slice();
/**
* {@inheritDoc}
*
* <p> Reading bytes into physical memory by invoking {@code load()} on the
* returned buffer, or writing bytes to the storage device by invoking
* {@code force()} on the returned buffer, will only act on the sub-range
* of this buffer that the returned buffer represents, namely
* {@code [index,index+length)}, where {@code index} and {@code length} are
* assumed to satisfy the preconditions.
*/
@Override
public abstract MappedByteBuffer slice(int index, int length);
/**
* {@inheritDoc}
*/
@Override
public abstract MappedByteBuffer duplicate();
/**
* {@inheritDoc}
*/
@Override
public abstract MappedByteBuffer compact();
}