What happens when you get a read error while accessing a memory mapped file? Let's try it:
RandomAccessFile raf = new RandomAccessFile("\\\\server\\share\\filename", "r");
FileChannel channel = raf.getChannel();
MappedByteBuffer map = channel.map(FileChannel.MapMode.READ_ONLY, 0, 5 * 1024 * 1024);
map.get(10 * 1024);
System.out.println("read byte at 10K -- waiting");
map.get(500 * 1024);
System.out.println("read byte at 500K");
Running this on JDK 1.6 (x64) and removing the network cable during the sleep will result in an Internal Error in the VM. Not exactly what I had hoped for.
Interestingly, on IKVM doing the same results in a
cli.System.Runtime.InteropServices.SEHException being thrown.