java调用rust 共享库的一些方法简单说明

java 与rust 的调用,核心还是基于jni 进行处理,rust社区实现了不少方便的工具可以提供rust 到c 的处理(比如生成头文件)
以下是整理的一些资料,方便学习

几个不错的包

  • jni-rs 
    目前还在活跃更新中,同时github 的start 也比较多,同时不少开源软件在用,比如questdb
  • robusta 
    一个比较新的项目,使用上比较简单,但是目前还是有一些缺点,具体可以参考官方文档
  • panama以及周边项目 
    实际上panama并不是rust 周边的,但是可以加速jni 的开发,比如我们已经构建好rust 的共享库之后,基于此可以 
    方便java 代码使用
  • graalvm 的native 能力 
    graalvm 对于native 的处理也比较强大,而且是oracle 官方的,也是不错的选择

说明

参考资料中包含了一些链接,可以方便参考学习

参考资料

https://openjdk.org/projects/panama/
https://github.com/openjdk/jextract
https://github.com/jni-rs/jni-rs
https://docs.rs/jni/latest/jni/
https://github.com/mozilla/cbindgen
https://github.com/MaulingMonkey/jni-bindgen
https://github.com/mozilla/uniffi-rs
https://questdb.io/blog/leveraging-rust-in-our-high-performance-java-database/
https://github.com/questdb/rust-maven-plugin
https://github.com/giovanniberti/robusta
https://github.com/java-native-access/jna
https://www.graalvm.org/latest/reference-manual/native-image/guides/build-native-shared-library/
https://www.baeldung.com/java-project-panama
https://docs.oracle.com/javase/8/docs/technotes/guides/jni/
https://www.baeldung.com/jni
https://docs.oracle.com/javase/8/docs/technotes/guides/jni/spec/jniTOC.html
https://www.graalvm.org/latest/reference-manual/native-image/native-code-interoperability/
https://www.graalvm.org/latest/reference-manual/native-image/native-code-interoperability/C-API/
https://www.graalvm.org/latest/reference-manual/native-image/dynamic-features/JNI/

posted on 2023-12-29 10:17  荣锋亮  阅读(149)  评论(0编辑  收藏  举报

导航