oracle / graal

GraalVM compiles Java applications into native executables that start instantly, scale fast, and use fewer compute resources 🚀
https://www.graalvm.org
Other
20.26k stars 1.62k forks source link

"Failed to link native method: EspressoMethod..." #7434

Open kohlschuetter opened 1 year ago

kohlschuetter commented 1 year ago

Describe GraalVM and your environment :

Have you verified this issue still happens when using the latest snapshot? Yes, still happening with graalvm-espresso-community-openjdk-21+35.1

Describe the issue When running my project's selftest jar, I see the following error message in the output (twice)

[java] WARNING: Failed to link native method: EspressoMethod<Lorg/newsclub/net/unix/NativeUnixSocket;.noop()V>

The method in question is a JNI no-op (hence the name, "noop"):

JNIEXPORT void JNICALL Java_org_newsclub_net_unix_NativeUnixSocket_noop
(JNIEnv *env, jclass clazz) {
    // no-op
    return;
}

Code snippet or code repository that reproduces the issue

selftest from https://github.com/kohlschutter/junixsocket/

Steps to reproduce the issue

  1. wget https://github.com/kohlschutter/junixsocket/releases/download/junixsocket-2.7.2/junixsocket-selftest-2.7.2-jar-with-dependencies.jar
  2. java -truffle -jar junixsocket-selftest-2.7.2-jar-with-dependencies.jar

Expected behavior A clear and concise description of what you expected to happen.

No "Failed to link native method" warning

Additional context

Other than the warning, the code seems to work as expected, but the warning line is unwarranted.

mukel commented 1 year ago

Thanks for the great bug report! The warning is a leftover artifact. At some point, linking native methods was somehow brittle, but this is an non-issue these days.
Sadly the logging is too coarse-grained as it uses the context logger, instead of something more specific; but you can disable the logging with --log.java.level=OFF or SEVERE.