FileChannel doc

Jeff Hain jeffhain at rocketmail.com
Mon Oct 1 15:27:22 PDT 2012


Hello.

I was digging through FileChannel(Impl)
(to do a mock of it, and have my unit tests not
slowed down by the drive, nor burning it out),
and found some perfectibilities:

- lock(), tryLock() and tryLock(long,long,boolean) docs
  should be aligned with lock(long,long,boolean) doc,
  regarding NonReadableChannelException and
  NonWritableChannelException:
     * @throws  NonReadableChannelException
     *          If <tt>shared</tt> is <tt>true</tt> this channel was not
     *          opened for reading
     *
     * @throws  NonWritableChannelException
     *          If <tt>shared</tt> is <tt>false</tt> but this channel was not
     *          opened for writing

- in all 4 lock/tryLock methods, in the doc for
  OverlappingFileLockException, "in this method" could be
  replaced with "in a lock method", since there are multiple
  blocking lock methods, and tryLock methods are not blocking.

Something else I found perfectible was the order of checks
(open/writable/etc.), which varies across methods, and some
"if (position > size) return 0" that could be replaced with
"if (position >= size) return 0".
Changing that could break some bad programs, but don't they
deserve to break? ;)

-Jeff
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.openjdk.java.net/pipermail/nio-dev/attachments/20121001/81f172b9/attachment.html 


More information about the nio-dev mailing list