JDK-7133447 : (fs) Need WatchService optimized for macOS
  • Type: Enhancement
  • Component: core-libs
  • Sub-Component: java.nio
  • Priority: P3
  • Status: Closed
  • Resolution: Duplicate
  • OS: os_x
  • CPU: x86
  • Submitted: 2012-01-26
  • Updated: 2022-09-08
  • Resolved: 2022-08-30
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.

To download the current JDK release, click here.
Other
tbdResolved
Related Reports
Duplicate :  
Relates :  
Relates :  
Description
From http://java.net/jira/browse/MACOSX_PORT-208

Comments
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.
08-09-2022

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.
26-02-2020