Summary
Control which implementation of WatchService
is used on macOS.
Problem
The existing WatchService
implementation on macOS has its limitations, but it is quite stable and has characteristics users have become accustomed to over the years. The new FSEvents-based implementation, while providing much better performance, introduces a risk of new bugs and certainly changes the expected characteristics, which may not be desirable for every user.
Solution
Instead of simply replacing the existing implementation with a new one, it is proposed to provide an opt-in new implementation with the help of a system property. This way, users not wishing to switch to the new implementation are not affected by the change and those willing to give the new implementation a try can do so with ease. Over time, the default may be re-considered in favor of the new FSEvents-based implementation.
Specification
FileSystem::newWatchService
returns an object of class MacOSXWatchService
if System.getProperty("sun.nio.fs.MacOSXWatchService.use")
returns non-null
value and an object of class PollingWatchService
otherwise (the status quo).
- csr of
-
JDK-8293067 (fs) Implement WatchService using system library (macOS)
- Open