graal
graal copied to clipboard
[GR-30885] native-image says error looking up CFStringCreateWithCharacters on MacOS
Describe the issue
I'm using a Java library io.methvin.directory-watcher version 0.15.0 and from what I can gather it uses the MacOS native CFStringCreateWithCharacters at some point of its process, but GraalVM native image will prompt an error that it could not look this function up.
Steps to reproduce the issue Please include both build steps as well as run steps
- Install
io.methvin.directory-watchervia Maven, version 0.15.0 - Implement a basic watching like so:
DirectoryWatcher watcher = DirectoryWatcher.builder()
.path(Paths.get(this.resources_dir)) // or use paths(directoriesToWatch)
.listener(event -> {
System.out.println("change occured");
})
.fileHasher(FileHasher.LAST_MODIFIED_TIME)
// .logger(logger) // defaults to LoggerFactory.getLogger(DirectoryWatcher.class)
// .watchService(watchService) // defaults based on OS to either JVM WatchService or the JNA macOS WatchService
.build();
watcher.watch();
- Compile with native-image and try to run it
Describe GraalVM and your environment:
- GraalVM Version 21.0.0.2 (Java Version 1.8.0_282-b07)
- JDK major version: 8
- OS: MacOS Big Sur
- Architecture: AMD64
More details
Full error I am getting:
Exception in thread "main" java.lang.UnsatisfiedLinkError: Error looking up function 'CFStringCreateWithCharacters': com.sun.jna.Native.findSymbol(JLjava/lang/String;)J [symbol: Java_com_sun_jna_Native_findSymbol or Java_com_sun_jna_Native_findSymbol__JLjava_lang_String_2]
at com.sun.jna.Function.<init>(Function.java:252)
at com.sun.jna.NativeLibrary.getFunction(NativeLibrary.java:600)
at com.sun.jna.NativeLibrary.getFunction(NativeLibrary.java:576)
at com.sun.jna.NativeLibrary.getFunction(NativeLibrary.java:562)
at com.sun.jna.Library$Handler.invoke(Library.java:243)
at com.sun.proxy.$Proxy133.CFStringCreateWithCharacters(Unknown Source)
at io.methvin.watchservice.jna.CFStringRef.toCFString(CFStringRef.java:23)
at io.methvin.watchservice.MacOSXListeningWatchService.register(MacOSXListeningWatchService.java:127)
at io.methvin.watchservice.WatchablePath.register(WatchablePath.java:50)
at io.methvin.watcher.DirectoryWatcher.register(DirectoryWatcher.java:400)
at io.methvin.watcher.DirectoryWatcher.registerAll(DirectoryWatcher.java:373)
at io.methvin.watcher.DirectoryWatcher.<init>(DirectoryWatcher.java:193)
at io.methvin.watcher.DirectoryWatcher$Builder.build(DirectoryWatcher.java:122)
at com.soynomm.bloggo.Bloggo.run(Bloggo.java:248)
at com.soynomm.bloggo.Main.main(Main.java:7)
@soynomm thanks for reporting the issue we will check it out and get back to you
On further investigation I think it's because it's using JNA (Java Native Access) behind the scenes, and (I think) it's not supported by GraalVM. I'm not sure if this helps at all, but it's all I got.
@soynomm I have create a bug for the Dev team, it will be fixed in future releases