8259032: MappedMemorySegmentImpl#makeMappedSegment() ignores Unmapper#pagePosition
Co-authored-by: Uwe Schindler <uschindler@openjdk.org> Reviewed-by: alanb
This commit is contained in:
parent
80110dac91
commit
e66187d885
@ -889,7 +889,7 @@ public class FileChannelImpl
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long address() {
|
public long address() {
|
||||||
return address;
|
return address + pagePosition;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -464,6 +464,28 @@ public class TestByteBuffer {
|
|||||||
MemorySegment.mapFile(f.toPath(), -1, 1, FileChannel.MapMode.READ_WRITE);
|
MemorySegment.mapFile(f.toPath(), -1, 1, FileChannel.MapMode.READ_WRITE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testMapOffset() throws IOException {
|
||||||
|
File f = new File("testMapOffset.out");
|
||||||
|
f.createNewFile();
|
||||||
|
f.deleteOnExit();
|
||||||
|
|
||||||
|
int SIZE = Byte.MAX_VALUE;
|
||||||
|
|
||||||
|
try (MemorySegment segment = MemorySegment.mapFile(f.toPath(), 0, SIZE, FileChannel.MapMode.READ_WRITE)) {
|
||||||
|
for (byte offset = 0; offset < SIZE; offset++) {
|
||||||
|
MemoryAccess.setByteAtOffset(segment, offset, offset);
|
||||||
|
}
|
||||||
|
MappedMemorySegments.force(segment);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int offset = 0 ; offset < SIZE ; offset++) {
|
||||||
|
try (MemorySegment segment = MemorySegment.mapFile(f.toPath(), offset, SIZE - offset, FileChannel.MapMode.READ_ONLY)) {
|
||||||
|
assertEquals(MemoryAccess.getByte(segment), offset);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testMapZeroSize() throws IOException {
|
public void testMapZeroSize() throws IOException {
|
||||||
File f = new File("testPos1.out");
|
File f = new File("testPos1.out");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user