Erroneous JavaDoc for Path#register

Alan Bateman Alan.Bateman at Sun.COM
Thu Dec 4 00:45:48 PST 2008


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!

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

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.

-Alan.






More information about the nio-dev mailing list