Jna

From JetBrains/intellij-community · View interactive version

Jna is an AI agent skill from the GitHub repository JetBrains/intellij-community. Implement or debug JNA bindings and ABI layouts in Kotlin or Java.

How to use this skill

Skill file

<!-- Generated by community/.ai/render-guides.mjs; edit community/.agents/skills/jna/SKILL.md -->

JNA bindings

Verify the native declaration, target architectures, and ownership rules before changing Kotlin or Java code.

Reuse existing mappings

Search JNA Platform and the repository before declaring a native type. Prefer a maintained platform mapping when its field types, alignment, and calling convention match the target API.

Keep reflected types accessible

JNA reflects mapped classes and fields while deriving layouts and invoking callbacks. Make every Structure, Union, callback, and related declaring class JVM-accessible from com.sun.jna:

Prefer moving visibility only as far as needed over suppressing reflection errors or opening accessibility globally.

Match the native ABI

Verify without requiring native UI or permissions

Add a small JVM regression test that constructs each mapped structure and calls size() or otherwise forces JNA to derive its layout. Assert stable sizes or offsets only when they are defined for the tested architecture.

Keep permission-, hardware-, and OS-dependent native integration coverage separate.

When debugging, retain the complete cause chain: wrapper errors often hide the useful IllegalAccessException, invalid field type, alignment error, or callback exception underneath.

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.