Erroneous JavaDoc for Path#register

Matthias Ernst ernst.matthias at gmail.com
Thu Dec 4 04:50:51 PST 2008


On Thu, Dec 4, 2008 at 9:45 AM, Alan Bateman <Alan.Bateman at sun.com> wrote:
> Matthias Ernst wrote:
>>
>>
>> http://openjdk.java.net/projects/nio/javadoc/java/nio/file/Path.html#register(java.nio.file.WatchService,%20java.nio.file.WatchEvent.Kind[],%20java.nio.file.WatchEvent.Modifier...)
>>
>> Barring any language changes I missed, the example code does not
>> compile. It requires an explicit array creation, not?
>>
>>     WatchKey key = dir.register(watcher, new WatchEvent.Kind<?>[] {
>> ENTRY_CREATE, ENTRY_DELETE, ENTRY_MODIFY });
>>
>>
>> Given that there are no modifiers defined as of today and I would
>> expect them to be empty most of the time (that's why they're called
>> modifiers), wouldn't it be nicer if the two parameters were switched?
>>
>> Matthias
>>
>
> Long time no hear!

Yeah! work work. Haven't had a lot of time for other engagements lately :-(

>
> The code in the usage example does compile. It's using the 2-parameter form
> of the register method:
>  http://openjdk.java.net/projects/nio/javadoc/java/nio/file/Watchable.html

Aww snap. That is indeed misleading. Especially given that only one of
the overloads is re-specified in Path.java . To be consequent, both
should be present in Path or none.

> Looking at this now, it is confusing to show an example using the
> 2-parameter register method in the overloading of the 3-parameter method. As
> you said, it will not be common to use modifiers since we aren't define any
> in the spec yet (we have a few implementation specific modifiers but these
> are part of the spec).
>
> If you want a more complete example then look in
> $JDK_HOME/sample/nio/file/WatchDir.java.
>
> Good to hear from you again.

Good to hear from you!

Matthias

PS: sorry for double-posting. I was unsure which email address I'm
subscribed with. I've been posting to /dev/null instead of
concurrency-interest for months.

>
> -Alan.
>
>
>
>



More information about the nio-dev mailing list