The following small program throws an assertion error when asserts
are enabled. I don't see anything wrong with the program and it clearly
finds the file properly so I think the bug is in NIO
import java.io.*;
import java.nio.*;
import java.nio.channels.*;
public class Map {
public static void main(String [] args) {
try {
RandomAccessFile raf = new RandomAccessFile("/etc/passwd", "r");
FileChannel fc = raf.getChannel();
long fileSize = fc.size();
System.out.println("filesize = " + fileSize);
MappedByteBuffer mapBuf =
fc.map(FileChannel.MapMode.READ_ONLY, 0l, fileSize);
} catch (Throwable t) {
t.printStackTrace();
}
}
}
% /import/java/jdk1.5/solaris-sparc/bin/java -esa Map
filesize = 467
java.lang.AssertionError
at sun.nio.ch.FileChannelImpl.map(FileChannelImpl.java:745)
at Map.main(Map.java:13)
are enabled. I don't see anything wrong with the program and it clearly
finds the file properly so I think the bug is in NIO
import java.io.*;
import java.nio.*;
import java.nio.channels.*;
public class Map {
public static void main(String [] args) {
try {
RandomAccessFile raf = new RandomAccessFile("/etc/passwd", "r");
FileChannel fc = raf.getChannel();
long fileSize = fc.size();
System.out.println("filesize = " + fileSize);
MappedByteBuffer mapBuf =
fc.map(FileChannel.MapMode.READ_ONLY, 0l, fileSize);
} catch (Throwable t) {
t.printStackTrace();
}
}
}
% /import/java/jdk1.5/solaris-sparc/bin/java -esa Map
filesize = 467
java.lang.AssertionError
at sun.nio.ch.FileChannelImpl.map(FileChannelImpl.java:745)
at Map.main(Map.java:13)
- duplicates
-
JDK-4910156 28 JCK1.5-runtime tests fail with java.lang.AssertionError
- Closed