graalvm : 19.0.0
linux (Mint 19.1)
The following will cause an exception at the native-image runtime:
WatchService service = fileSystem.newWatchService()
Exception in thread "Thread-3" java.lang.UnsatisfiedLinkError: sun.nio.fs.LinuxWatchService.inotifyInit()I [symbol: Java_sun_nio_fs_LinuxWatchService_inotifyInit or Java_sun_nio_fs_LinuxWatchService_inotifyInit__]
at com.oracle.svm.jni.access.JNINativeLinkage.getOrFindEntryPoint(JNINativeLinkage.java:145)
Thanks for finding this issue. Could you attach the whole file that we can use to reproduce it?
Added file as .txt (it is .java but the window wasn't accepting it).
Pasting code here too:
package test;
import java.io.IOException;
import java.nio.file.FileSystem;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.WatchService;
public class WatchServiceTest {
public static void main(String[] args) throws IOException {
Path path = Paths.get(args[0]);
FileSystem fileSystem = path.getFileSystem();
System.out.println("Before");
try (
//Graal 1.0.0-rc16, 19.0.0, 19.1.0, 19.2.0:
// Java Runtime
// Linux (Mint 19.1 at least) works
// OSX works.
// native-image
// Linux (Mint 19.1 at least) fails at runtime with an UnsatisfiedLinkError
// OSX works
WatchService watchService = fileSystem.newWatchService();
) {
} catch (UnsatisfiedLinkError e) {
e.printStackTrace();
//java.lang.UnsatisfiedLinkError: sun.nio.fs.LinuxWatchService.inotifyInit()I [symbol: Java_sun_nio_fs_LinuxWatchService_inotifyInit or Java_sun_nio_fs_LinuxWatchService_inotifyInit__]
// at com.oracle.svm.jni.access.JNINativeLinkage.getOrFindEntryPoint(JNINativeLinkage.java:145)
// at com.oracle.svm.jni.JNIGeneratedMethodSupport.nativeCallAddress(JNIGeneratedMethodSupport.java:57)
// at sun.nio.fs.LinuxWatchService.inotifyInit(LinuxWatchService.java)
// at sun.nio.fs.LinuxWatchService.<init>(LinuxWatchService.java:59)
// at sun.nio.fs.LinuxFileSystem.newWatchService(LinuxFileSystem.java:47)
// at test.WatchServiceTest.main(WatchServiceTest.java:15)
}
System.out.println("After");
}
}
Same issue on 19.0.2 ce.
I'm getting the same issue on GraalVM Version 19.1.0 CE.
Same issue on 19.2.0 ce.
Can we have an update on this? Is this an easy fix and just hasn't been prioritized or is there a bigger issue at hand?
@pejovica @olpaw will this be fixed by the JNI platform?
@pejovica @olpaw will this be fixed by the JNI platform?
Yes.
> mx native-image -Dsvm.platform='org.graalvm.nativeimage.impl.InternalPlatform$LINUX_JNI_AMD64' test.WatchServiceTest
[test.watchservicetest:9171] classlist: 1,924.21 ms
[test.watchservicetest:9171] (cap): 641.47 ms
[test.watchservicetest:9171] setup: 1,835.47 ms
[test.watchservicetest:9171] (typeflow): 6,415.66 ms
[test.watchservicetest:9171] (objects): 6,362.41 ms
[test.watchservicetest:9171] (features): 335.14 ms
[test.watchservicetest:9171] analysis: 13,396.65 ms
[test.watchservicetest:9171] (clinit): 215.40 ms
[test.watchservicetest:9171] universe: 524.82 ms
[test.watchservicetest:9171] (parse): 828.92 ms
[test.watchservicetest:9171] (inline): 1,557.65 ms
[test.watchservicetest:9171] (compile): 5,702.54 ms
[test.watchservicetest:9171] compile: 8,488.65 ms
[test.watchservicetest:9171] image: 749.31 ms
[test.watchservicetest:9171] write: 132.84 ms
[test.watchservicetest:9171] [total]: 27,277.83 ms
> ./test.watchservicetest testfile
Before
After
Thanks, so there is no point in fixing this the other way as JNI will become the default.
Confirmed fixed in 19.3.0 on linux.
Most helpful comment
Thanks, so there is no point in fixing this the other way as JNI will become the default.