Skip to content
Back to skills

Jni Rs Bindings

ASecurity

jni-rs conventions for exposing a Rust core to Java/JVM: JNI export naming, JNIEnv usage, string conversion, exception checks/throws, global references, and library loading. Load when generating or reviewing jni-rs Java/JVM bindings for a Rust library.

  • 146 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added October 5, 2026
ai-agentsrustgojavaapi

Works with

  • api

Security analysis

A100/100

Scanned October 5, 2026

npx -y skills add Goldziher/ai-rulez --skill jni-rs-bindings --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Jni Rs Bindings?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Jni Rs Bindings
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/goldziher-jni-rs-bindings/badge)](https://www.skillsdirectory.com/skills/goldziher-jni-rs-bindings)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: jni-rs-bindings
description: "jni-rs conventions for exposing a Rust core to Java/JVM: JNI export naming, JNIEnv usage, string conversion, exception checks/throws, global references, and library loading. Load when generating or reviewing jni-rs Java/JVM bindings for a Rust library."
---

- Use `jni` crate for Rust-Java/JVM interop. Functions must be `#[no_mangle] pub extern "system"`.
- Follow JNI naming: `Java_com_example_ClassName_methodName`. Match Java native method signatures exactly.
- Use `JNIEnv` for all JNI operations. Access Java types via `JObject`, `JString`, `JClass` wrappers.
- String conversion: `env.get_string(&jstring)` to read, `env.new_string("value")` to create.
- Error handling: check `env.exception_check()` after JNI calls. Throw Java exceptions via `env.throw_new()`.
- Global references (`env.new_global_ref()`) for objects accessed across threads or native calls.
- Build with `cargo build --release` to produce shared library. Load in Java with `System.loadLibrary()`.
- Test Java side with JUnit, Rust core logic with standard `#[test]`. Integration tests via JNI calls.
- Keep JNI layer thin — business logic in Rust, Java provides API surface.
- Memory: JNI local references are auto-freed on native return. Use `env.delete_local_ref()` in loops.
- Anti-patterns: holding JNI references across threads without global refs, ignoring exception checks, `unwrap()` in JNI functions.

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.