@JRubyMethod(required = 1)
public IRubyObject flock(ThreadContext context, IRubyObject lockingConstant) {
// TODO: port exact behavior from MRI, and move most locking logic into ChannelDescriptor
// TODO: for all LOCK_NB cases, return false if they would block
ChannelDescriptor descriptor = openFile.getMainStream().getDescriptor();
// null channel always succeeds for all locking operations
if (descriptor.isNull()) return RubyFixnum.zero(context.getRuntime());
FileChannel fileChannel = (FileChannel)descriptor.getChannel();
int lockMode = RubyNumeric.num2int(lockingConstant);
// Exclusive locks in Java require the channel to be writable, otherwise
// an exception is thrown (terminating JRuby execution).
// But flock behavior of MRI is that it allows