8286671: (fc) Modify sun.nio.ch.FileChannelImpl.map0() to accept a FileDescriptor parameter

Reviewed-by: alanb, jpai
This commit is contained in:
Brian Burkhalter 2022-05-13 17:46:52 +00:00
parent 1e843c3d4f
commit 583a61aabb
3 changed files with 13 additions and 21 deletions

View file

@ -1239,7 +1239,7 @@ public class FileChannelImpl
mapSize = size + pagePosition;
try {
// If map0 did not throw an exception, the address is valid
addr = map0(prot, mapPosition, mapSize, isSync);
addr = map0(fd, prot, mapPosition, mapSize, isSync);
} catch (OutOfMemoryError x) {
// An OutOfMemoryError may indicate that we've exhausted
// memory so force gc and re-attempt map
@ -1250,7 +1250,7 @@ public class FileChannelImpl
Thread.currentThread().interrupt();
}
try {
addr = map0(prot, mapPosition, mapSize, isSync);
addr = map0(fd, prot, mapPosition, mapSize, isSync);
} catch (OutOfMemoryError y) {
// After a second OOME, fail
throw new IOException("Map failed", y);
@ -1500,7 +1500,8 @@ public class FileChannelImpl
// -- Native methods --
// Creates a new mapping
private native long map0(int prot, long position, long length, boolean isSync)
private native long map0(FileDescriptor fd, int prot, long position,
long length, boolean isSync)
throws IOException;
// Removes an existing mapping
@ -1514,12 +1515,12 @@ public class FileChannelImpl
// Retrieves the maximum size of a transfer
private static native int maxDirectTransferSize0();
// Caches fieldIDs
private static native long initIDs();
// Retrieves allocation granularity
private static native long allocationGranularity0();
static {
IOUtil.load();
allocationGranularity = initIDs();
allocationGranularity = allocationGranularity0();
MAX_DIRECT_TRANSFER_SIZE = maxDirectTransferSize0();
}
}