Skip to content

Commit

Permalink
Use PollingWatchService for non Windows.
Browse files Browse the repository at this point in the history
  • Loading branch information
wasabii committed Nov 7, 2023
1 parent d3aeab3 commit f0e0abd
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 26 deletions.
13 changes: 8 additions & 5 deletions src/IKVM.Java/local/sun/nio/fs/DotNetFileSystem.java
Original file line number Diff line number Diff line change
Expand Up @@ -206,14 +206,17 @@ public boolean matches(Path path) {
};
}

public UserPrincipalLookupService getUserPrincipalLookupService()
{
public UserPrincipalLookupService getUserPrincipalLookupService() {
throw new UnsupportedOperationException();
}

public WatchService newWatchService() throws IOException
{
return new DotNetWatchService(this);
public WatchService newWatchService() throws IOException {
if (cli.IKVM.Runtime.RuntimeUtil.get_IsWindows()) {
return new DotNetWatchService(this);
} else {
// FileSystemWatcher implementation on .NET for Unix consumes way too many inotify queues
return new PollingWatchService();
}
}

}
25 changes: 8 additions & 17 deletions src/IKVM.Java/local/sun/nio/fs/DotNetPath.java
Original file line number Diff line number Diff line change
Expand Up @@ -510,35 +510,26 @@ public Path toRealPath(LinkOption... options) throws IOException

private static native String toRealPathImpl(String path);

public WatchKey register(WatchService watcher, WatchEvent.Kind<?>[] events, WatchEvent.Modifier... modifiers) throws IOException
{
if (!(watcher instanceof DotNetWatchService))
{
// null check
watcher.getClass();
throw new ProviderMismatchException();
}
public WatchKey register(WatchService watcher, WatchEvent.Kind<?>[] events, WatchEvent.Modifier... modifiers) throws IOException {
watcher.getClass();

SecurityManager sm = System.getSecurityManager();
if (sm != null)
{
if (sm != null) {
boolean subtree = false;
for(WatchEvent.Modifier modifier : modifiers)
{
if(modifier == ExtendedWatchEventModifier.FILE_TREE)
{
for (WatchEvent.Modifier modifier : modifiers) {
if (modifier == ExtendedWatchEventModifier.FILE_TREE) {
subtree = true;
break;
}
}

sm.checkRead(path);
if (subtree)
{
if (subtree) {
sm.checkRead(path + cli.System.IO.Path.DirectorySeparatorChar + '-');
}
}
return ((DotNetWatchService)watcher).register(this, events, modifiers);

return ((AbstractWatchService)watcher).register(this, events, modifiers);
}

public int compareTo(Path other)
Expand Down
8 changes: 4 additions & 4 deletions src/IKVM.OpenJDK.Tests/jdk/ExcludeList.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1415,7 +1415,7 @@ java/nio/file/Files/delete_on_close.sh
java/nio/file/Files/walkFileTree/find.sh generic-all
java/nio/file/Path/Misc.java linux-all,macosx-all
java/nio/file/Path/PathOps.java windows-all
java/nio/file/WatchService/Basic.java linux-all,macosx-all
#java/nio/file/WatchService/Basic.java linux-all,macosx-all
java/rmi/Naming/DefaultRegistryPort.java generic-all
java/rmi/Naming/LookupIPv6.java generic-all
java/rmi/Naming/LookupNameWithColon.java generic-all
Expand Down Expand Up @@ -3407,9 +3407,9 @@ java/nio/channels/SocketChannel/SendUrgentData.java
java/nio/channels/SocketChannel/VectorParams.java macosx-all
java/nio/charset/coders/Check.java macosx-all
java/nio/file/Path/MacPathTest.java macosx-all
java/nio/file/WatchService/LotsOfCancels.java macosx-all
java/nio/file/WatchService/LotsOfEvents.java macosx-all
java/nio/file/WatchService/MayFlies.java macosx-all
#java/nio/file/WatchService/LotsOfCancels.java macosx-all
#java/nio/file/WatchService/LotsOfEvents.java macosx-all
#java/nio/file/WatchService/MayFlies.java macosx-all
java/util/prefs/AddNodeChangeListener.java macosx-all
java/util/prefs/CommentsInXml.java macosx-all
java/util/prefs/ConflictInFlush.java macosx-all
Expand Down

0 comments on commit f0e0abd

Please sign in to comment.