I've run into a baffling problem porting a Java program over to a FreeBSD system from Trustix. When I try to obtain a file lock on a RandomAccessFile I get an "Invalid Argument" exception.
When searching for a fix I found reference to 64-bit systems having problems with this, but that has been fixed in java 1.4.3 (IIRC). I did try passing in a block size to tryLock() (ie: tryLock(0L, 1024L, false) ) but that did not change the result.
See code snippet for code and exception.
FreeBSD 7.1, 64bit
java: jdk 1.6.0
Anyone have any input on this?
FileChannel channel = new RandomAccessFile("fileLockTest","rw").getChannel();
FileLock lock = channel.tryLock();
java.io.IOException: Invalid argument
at sun.nio.ch.FileChannelImpl.lock0(Native Method)