Java 7 - LinkOption - why is NOFOLLOW_LINKS the only available option?

java, java-7, linkoption, nio, symlink

Solution

Following links is the default behavior. I.e., if you don't specify NOFOLLOW_LINKS, then links are followed.

From the documentation of the `Files.getLastModifiedTime()` method (emphasis mine):

The options array may be used to indicate how symbolic links are handled for the case that the file is a symbolic link. By default, symbolic links are followed and the file attribute of the final target of the link is read. If the option NOFOLLOW_LINKS is present then symbolic links are not followed.

Problem

I think the title says it all. How would I specify FOLLOW_LINKS? Why create an enum with just one option? For example, the method java.nio.file.Files.getLastModifiedTime(Path, LinkOption...) takes an array of LinkOption-s as argument. You have to pass something, yet you can only pass the one option available. This surprised me, and would like to know more about it.

Original source