Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

Error looking up function from current process on Linux

未关闭
#1,698 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
35/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
停滞
技术栈
java, linux

调研方向

使用 Java 25 复现 Linux x64 案例,然后从报告的堆栈跟踪 NativeLibrary.getFunction 和 Function,以检查当前进程的符号查找。将 Native.load(null, ZstdJna.class) 与显式加载共享库的解决方法以及 Java Foreign Function & Memory API 进行比较。当无需显式加载共享库即可成功查找到报告中的 ZSTD_createDStream 时,即表示完成。

由索引模型根据 Issue 内容生成。

描述

feature request
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

  • nm seems to indicate the function is in the shared library, and isn't mangled

    Image
  • 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

主要语言
Java
星标
8.9k
派生
1.7k
PR 合并指标
30 天内没有已合并 PR

环境准备

这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

java-native-access/jna 的其他 Issue

查看 java-native-access/jna 的全部 Issue

相似的 Issue

更多 Java Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。