mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-26 22:34:27 +02:00
6539707: (fc) MappedByteBuffer.force() method throws an IOException in a very simple test
Reviewed-by: alanb
This commit is contained in:
parent
189289d9c7
commit
46d78f0d24
5 changed files with 97 additions and 5 deletions
|
@ -26,6 +26,7 @@
|
|||
package java.nio;
|
||||
|
||||
import java.io.FileDescriptor;
|
||||
import java.io.UncheckedIOException;
|
||||
import java.lang.ref.Reference;
|
||||
import java.util.Objects;
|
||||
|
||||
|
@ -221,6 +222,10 @@ public abstract class MappedByteBuffer
|
|||
* mapping modes. This method may or may not have an effect for
|
||||
* implementation-specific mapping modes. </p>
|
||||
*
|
||||
* @throws UncheckedIOException
|
||||
* If an I/O error occurs writing the buffer's content to the
|
||||
* storage device containing the mapped file
|
||||
*
|
||||
* @return This buffer
|
||||
*/
|
||||
public final MappedByteBuffer force() {
|
||||
|
@ -272,6 +277,10 @@ public abstract class MappedByteBuffer
|
|||
* if the preconditions on the index and length do not
|
||||
* hold.
|
||||
*
|
||||
* @throws UncheckedIOException
|
||||
* If an I/O error occurs writing the buffer's content to the
|
||||
* storage device containing the mapped file
|
||||
*
|
||||
* @return This buffer
|
||||
*
|
||||
* @since 13
|
||||
|
|
|
@ -28,6 +28,8 @@ package java.nio;
|
|||
import jdk.internal.misc.Unsafe;
|
||||
|
||||
import java.io.FileDescriptor;
|
||||
import java.io.IOException;
|
||||
import java.io.UncheckedIOException;
|
||||
|
||||
/* package */ class MappedMemoryUtils {
|
||||
|
||||
|
@ -94,7 +96,11 @@ import java.io.FileDescriptor;
|
|||
} else {
|
||||
// force writeback via file descriptor
|
||||
long offset = mappingOffset(address, index);
|
||||
force0(fd, mappingAddress(address, offset, index), mappingLength(offset, length));
|
||||
try {
|
||||
force0(fd, mappingAddress(address, offset, index), mappingLength(offset, length));
|
||||
} catch (IOException cause) {
|
||||
throw new UncheckedIOException(cause);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -103,7 +109,7 @@ import java.io.FileDescriptor;
|
|||
private static native boolean isLoaded0(long address, long length, int pageCount);
|
||||
private static native void load0(long address, long length);
|
||||
private static native void unload0(long address, long length);
|
||||
private static native void force0(FileDescriptor fd, long address, long length);
|
||||
private static native void force0(FileDescriptor fd, long address, long length) throws IOException;
|
||||
|
||||
// utility methods
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue