---------------- test code ----------------------------
FileChannel fc ;
MappedByteBuffer b ;
byte[] srcData = Helper.getRandomByteArray(MIN_DATA_SIZE, MAX_DATA_SIZE);
// start at 25% of buffer, and map 75% of total size
int offset = srcData.length/2 - srcData.length/4 ;
int mapSize = srcData.length/2 + srcData.length/4 ;
try {
fc = Helper.openRWTempFileChannel(fileName) ;
fc.write(ByteBuffer.wrap(srcData));
System.out.println("offset=" + offset + ", mapSize=" + mapSize);
b = fc.map(FileChannel.MAP_RW, offset, mapSize);
System.out.println(b);
} catch (IOException e) {
return TestHelper.testFail(testName + " FAIL: Unexpected Exception", e);
}
--------- results on Windows NT ------------
java FCmap^M
:
offset=1206060, mapSize=3618180^M
mapTest02 (file size=4824241) FAIL: Unexpected Exception^M
java.io.IOException: Access is denied^M
at sun.nio.ch.FileChannelImpl.map0(Native Method)^M
at sun.nio.ch.FileChannelImpl.map(FileChannelImpl.java:399)^M
at FCmap.mapTest02(FCmap.java:323)^M
:
---------------------
Works fine on Solaris and Linux.
Merlin Build B-73.
FileChannel fc ;
MappedByteBuffer b ;
byte[] srcData = Helper.getRandomByteArray(MIN_DATA_SIZE, MAX_DATA_SIZE);
// start at 25% of buffer, and map 75% of total size
int offset = srcData.length/2 - srcData.length/4 ;
int mapSize = srcData.length/2 + srcData.length/4 ;
try {
fc = Helper.openRWTempFileChannel(fileName) ;
fc.write(ByteBuffer.wrap(srcData));
System.out.println("offset=" + offset + ", mapSize=" + mapSize);
b = fc.map(FileChannel.MAP_RW, offset, mapSize);
System.out.println(b);
} catch (IOException e) {
return TestHelper.testFail(testName + " FAIL: Unexpected Exception", e);
}
--------- results on Windows NT ------------
java FCmap^M
:
offset=1206060, mapSize=3618180^M
mapTest02 (file size=4824241) FAIL: Unexpected Exception^M
java.io.IOException: Access is denied^M
at sun.nio.ch.FileChannelImpl.map0(Native Method)^M
at sun.nio.ch.FileChannelImpl.map(FileChannelImpl.java:399)^M
at FCmap.mapTest02(FCmap.java:323)^M
:
---------------------
Works fine on Solaris and Linux.
Merlin Build B-73.
- duplicates
-
JDK-4482584 (fs) Cannot map from file channel after position 65535
-
- Closed
-