JDK-7133447 : (fs) Need WatchService optimized for macOS
The Version table provides details related to the release that this issue/RFE will be addressed.
Unresolved : Release in which this issue/RFE will be addressed. Resolved: Release in which this issue/RFE has been resolved. Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.
For the record, I implemented a WatchService for macOS using the kqueue set of system calls. This works and is fast but has some problems with closing and using too many file descriptors. The latter problem is inherent to kqueue which has other problems with respect to this purpose. One is that there is no way to tell when a file is added to a directory other than detecting the event on the directory and then scanning the directory to find the new file. Another file descriptor is added for each new file as there is no other way to tell when the file is modified (modifying a file does not generate an event on the containing directory's descriptor). So in effect there is one file descriptor used for each directory and one for each file in each directory which eventually results in too many open descriptors if many files and directories are being watched.
The macOS port is currently using the portable polling WatchService implementation and this is sufficient for 7u4. When time permits, we should replace it with a native based implementation so that it performs as will as the Linux and Windows implementations.