<div dir="ltr"><div>WatchService on MacOS is still implemented by the generic PollingWatchService, which continuously re-scans the directory consuming CPU, introduces large latencies to the generated WatchEvent's, and misses changes that occur faster than the re-scan interval. At the same time, there are two technologies available on the platform to receive the necessary information from the OS similar to what is available on Windows and Linux: Kernel Queues and File System Events, the latter being more suitable for implementing the WatchServie functionality.</div><div><br></div><div>There are several stand-alone implementations out there that utilize one or the other (or even both), which suggests that demand exists for WatchService on MacOS to be more responsive and less resource-hungry. <br></div><div><br></div><div>If the community is interested in getting this functionality in OpenJDK proper, I'd be happy to contribute code that was developed, tested, and used at JetBrains for around half a year. It is based on FSEvents, supports the FILE_TREE modifier (recursive directory watch), and does not do any excessive I/O except the necessary minimum.<br></div><div><br></div><div>References</div><div>* WatchService interface <br></div><div>  - <a href="https://docs.oracle.com/en/java/javase/18/docs/api/java.base/java/nio/file/WatchService.html">https://docs.oracle.com/en/java/javase/18/docs/api/java.base/java/nio/file/WatchService.html</a></div><div>* PollingWatchService source code <br></div><div>  - <a href="https://github.com/openjdk/jdk/blob/master/src/java.base/share/classes/sun/nio/fs/PollingWatchService.java">https://github.com/openjdk/jdk/blob/master/src/java.base/share/classes/sun/nio/fs/PollingWatchService.java</a></div><div>* File System Events <br></div><div>  - <a href="https://developer.apple.com/documentation/coreservices/file_system_events?language=objc">https://developer.apple.com/documentation/coreservices/file_system_events?language=objc</a></div><div>* Kernel Queues <br></div><div>  - <a href="https://developer.apple.com/library/archive/documentation/Darwin/Conceptual/FSEvents_ProgGuide/KernelQueues/KernelQueues.html">https://developer.apple.com/library/archive/documentation/Darwin/Conceptual/FSEvents_ProgGuide/KernelQueues/KernelQueues.html</a></div></div>