Error looking up function from current process on Linux
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 35/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Stale
- Tech stack
- java, linux
- Domain
- operating-systems
Research direction
Reproduce the Linux x64 case with Java 25, then trace NativeLibrary.getFunction and Function from the reported stack to inspect current-process symbol lookup. Compare Native.load(null, ZstdJna.class) with the explicit library workaround and the Java Foreign Function & Memory API. Done means the reported ZSTD_createDStream lookup succeeds without explicitly loading the shared library.
Written by the indexing model from the issue text.
Description
Description
JNA seems to be unable to look up functions from the current process, specifically on Linux x64, while the same code works fine on Windows x64 and macOS aarch64. The documentation says JNA should look into the current process if null is passed to Native.load.
Additional details
-
The Foreign Function & Memory API from Java 22 finds all functions and all tests succeed
-
nmseems to indicate the function is in the shared library, and isn't mangled -
The only workaround is to let JNA load the shared library by
Native.load("/path/to/libzstd.so", ZstdJna.class)
Repro code
Using the Linux x64 binary found at https://github.com/freya022/discord-zstd-java/actions/runs/18886251057
public interface ZstdJna extends Library {
ZstdJna INSTANCE = Native.load(null, ZstdJna.class);
Pointer ZSTD_createDStream();
}
public class Repro {
public static void main(String[] args) {
System.load("/path/to/libzstd.so");
ZstdJna.INSTANCE // Fine
.ZSTD_createDStream(); // Fails
}
}
Environment
Java Version: OpenJDK 25+36
JNA Version: 5.18.1 (also tested 4.4.0)
Operating System: Ubuntu 24.04 GitHub Actions runner (image details), also tested on a Kubuntu VM
C/C++ Compiler: GCC 13.3.0
Error
java.lang.UnsatisfiedLinkError: Error looking up function 'ZSTD_createDStream': /usr/lib/jvm/java-25-openjdk-amd64/bin/java: undefined symbol: ZSTD_createDStream
at com.sun.jna.Function.<init>(Function.java:255)
at com.sun.jna.NativeLibrary.getFunction(NativeLibrary.java:618)
at com.sun.jna.NativeLibrary.getFunction(NativeLibrary.java:594)
at com.sun.jna.NativeLibrary.getFunction(NativeLibrary.java:580)
at com.sun.jna.Library$Handler.invoke(Library.java:248)
at jdk.proxy3/jdk.proxy3.$Proxy13.ZSTD_createDStream(Unknown Source)
at dev.freya02.discord.zstd.jna.ZstdJNATest.test_decompression(ZstdJNATest.java:36)
at java.base/java.lang.reflect.Method.invoke(Method.java:565)
at java.base/java.util.ArrayList.forEach(ArrayList.java:1604)
at java.base/java.util.ArrayList.forEach(ArrayList.java:1604)
Workflow details if necessary: https://github.com/freya022/discord-zstd-java/actions/runs/18891473842
- Dominant language
- Java
- Stars
- 8.9k
- Forks
- 1.7k
- Avg merge
- 1d 13h
- Merged PRs (30d)
- 1
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from java-native-access/jna
-
Difficulty 4/5 3-5 days Newbie friendliness 66/100
java-native-access/jna#1738 ·
-
Difficulty 4/5 3-5 days Newbie friendliness 45/100
java-native-access/jna#1736 ·
-
Difficulty 3/5 1-2 days Newbie friendliness 65/100
java-native-access/jna#1717 ·
-
Windows32Exception - The parameter is incorrectPossibly taken @marktech0813 claimed this 333 days ago. Open
Difficulty 4/5 3-5 days Newbie friendliness 35/100
java-native-access/jna#1700 · 11 comments ·
-
Difficulty 4/5 3-5 days Newbie friendliness 45/100
java-native-access/jna#1694 ·
All issues in java-native-access/jna
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
floci-io/floci#5425 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
objectionary/eo-graphs#80 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
objectionary/jucs#141 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
-
bug good first issue
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
repowise-dev/repowise#3335 ·
Maintainers usually reply within 1 day