ingrid.yao@Eng 2001-05-23
J2SE Version (please include all output from java -version flag):
java version "1.4.0-beta"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-beta-b64)
Java HotSpot(TM) Client VM (build 1.4.0-beta-b64, mixed mode)
Does this problem occur on J2SE 1.3? Yes / No (pick one)
Feature Not exists
Operating System Configuration Information (be specific):
Win 2000 5.00.2195 Service pack 1
Hardware Configuration Information (be specific):
x86 Family 6 Model 7 Stepping 3
Bug Description:
java.nio.MappedByteBuffer.isReadOnly() returns false, should be true
Test program
================
import java.nio.channels.FileChannel;
import java.nio.MappedByteBuffer;
import java.io.*;
public class readNIOSmap {
public static void main(String[] args) throws Exception {
readNIOSmap();
}
private static void readNIOSmap() throws IOException {
long startTime = System.currentTimeMillis();
RandomAccessFile raf = new RandomAccessFile("testFile", "r");
FileChannel channel = raf.getChannel();
MappedByteBuffer buff = channel.map(FileChannel.MAP_RO, 0, (int) raf.length());
buff.load();
System.out.println(" read NIO map: "+ buff.isDirect()+" "+buff.isLoaded()+" "+ buff.isReadOnly());
raf.close();
long tookTime = System.currentTimeMillis() - startTime;
System.out.println("Read NIO Stream mapped takes "+ (tookTime*.001) + " seconds");
}
}