java-ffm
Use for Java 26 Foreign Function & Memory API (FFM, Project Panama): java.lang.foreign, native library calls, off-heap memory, MemorySegment, Arena, Linker…
Skill by isp-insoft-gmbh
Install
Works with Claude Code, Claude apps, Codex, Cursor, Gemini CLI, GitHub Copilot, VS Code, OpenCode, Goose, Windsurf. Read the repository before you give any tool access to your data.
npx agentmarket install skill/isp-insoft-gmbh-java-ffm
Asks which of your tools to add it to (Claude Code, Codex, Cursor, VS Code, Windsurf, Gemini CLI, Claude Desktop) and shows the change first. See https://agentmart.dev/cli.
Get the weekly diff
The weekly diff: one email a week with new agent tools, notable updates and grade changes, plus security alerts for tools you follow. Double opt-in, one-click unsubscribe.
About
Use cases: backend
Reviews
Write a reviewNo reviews yet. Installed it? Reviews come from verified installers only. How reviews work
Permissions
What this skill can do and what it asks for, from its SKILL.md. Checked Oct 25, 2026.
- Tools
- No tools found
- Secrets
- None asked for
- Install scripts
- None found
Network hosts it talks to 1
codeload.github.com· found in install command
Files it touches
~/.claude/skills/java-ffm
What's inside
- Skill name
java-ffm- Description
- Use for Java 26 Foreign Function & Memory API (FFM, Project Panama): java.lang.foreign, native library calls, off-heap memory, MemorySegment, Arena, Linker, SymbolLookup, FunctionDescriptor, MemoryLayout, upcalls/downcalls, jextract, errno, restricted native access.
- License
- MIT
- Compatibility
- Java SE 26 / JDK 26; java.lang.foreign stable since Java 22
- Instructions
- 139 lines in SKILL.md · view on GitHub
Files (3)
- SKILL.md
- jep-454.md · examples/
- java-26-ffm.md · references/
SKILL.md (first lines)
# Java 26 FFM Skill
Use this skill when writing/reviewing Java code using the Foreign Function &
Memory API.
When active:
1. Identify C ABI/platform, exact native signatures, library loading path,
ownership/lifetime, thread access, and error convention.
2. Prefer safe FFM idioms:
arena-bound allocation, explicit layouts, exact method handle types, explicit
cleanup, minimal restricted API use.
3. Read `references/java-26-ffm.md` for distilled API facts, patterns, and
pitfalls.
4. If implementing bindings for many C declarations, recommend `jextract`;
hand-code only small bindings.
## Core model
- `MemorySegment` = contiguous memory view:
address + byte size + scope + access checks.
- `Arena` = native memory lifetime owner.
Close arena → all segments allocated by it invalid.
- `MemoryLayout` / `ValueLayout` / `AddressLayout` = data shape, size,
alignment, endianness, access handles.
- `Linker` + `SymbolLookup` + `FunctionDescriptor` = turn native symbol +
signature into `MethodHandle` downcall.
- Upcall = native code calls Java via `linker.upcallStub(methodHandle,
descriptor, arena)`.
## Default imports
```java
import java.lang.foreign.*;
import java.lang.invoke.*;
import static java.lang.foreign.ValueLayout.*;
import static java.lang.foreign.MemoryLayout.*;
import static java.lang.foreign.MemoryLayout.PathElement.*;
```
## Native access
Restricted FFM methods need native access enabled.
FFM is final in Java 26; do not add `--enable-preview` for FFM-only code.
```bash
javac --release 26 Main.java
java --enable-native-access=ALL-UNNAMED Main
java --enable-native-access=my.module Main
```
In JDK 24+, illegal native access defaults to warning; future JDK may deny.
For CI, prefer explicit `--enable-native-access=<module>` and consider
`--illegal-native-access=deny`.
## Fast checklists
Before downcall:
- Exact C prototype?
Include typedef expansion, pointer depth, varargs specialization.
- Correct platform layouts?
`long` differs:
Linux/x64 `long` = 64-bit; Windows/x64 `long` = 32-bit.
`size_t` is `JAVA_LONG` on Linux/x64, not `JAVA_INT`.
- C constants/macros?
Do not guess magic numbers; use `jextract`, generate constants, or choose APIs
without macro constants.
- Ownership?
Who allocates/frees returned pointers?
Which arena owns passed buffers/upcall stubs?
- Threading?
Confined arena only owner thread.
Shared arena for cross-thread access.
- Error path?
Return sentinel?
`errno`?
output parameter?
Before structs:
- Include explicit padding where C ABI inserts it.
- Verify `byteSize()` and `byteAlignment()` vs C `sizeof`/`alignof` if possible.
- Use named layouts + layout path var handles; avoid manual offset math.
Before pointer dereference/out params:
- Pointer from native/read memory is often zero-length.
- C `T** out` means allocate an `ADDRESS` slot, pass that slot, then read the
real `T*` with `slot.get(ADDRESS, 0)`; use the real handle for later calls,
not the address of the slot.
Common example:
`sqlite3_open(..., sqlite3**)`.
- Attach bounds via `AddressLayout.withTargetLayout(...)` when statically known,
or `segment.reinterpret(size, arena, cleanup)` when dynamically known.
- Treat `reinterpret` and target layouts as unsafe/restricted:
wrong size/lifetime can crash JVM.
## Canonical minimal downcall
```java
static final Linker LINKER = Linker.nativeLinker();
static final SymbolLookup LIBC = LINKER.defaultLookup();
static final MethodHandle strlen = LINKER.downcallHandle(
LIBC.findOrThrow("strlen"),
FunctionDescriptor.of(JAVA_LONG, ADDRESS) // Linux/x64 size_t, char*
);
static long strlen(String s) throws Throwable {
try (Arena arena = Arena.ofConfined()) {
MemorySegment cString = arena.allocateFrom(s); // UTF-8, NUL-terminated
return (long) strlen.invokeExact(cString);
}
}
```
## ExamplesFrom isp-insoft-gmbh/isp-insoft-ai-skills, MIT.
More from isp-insoft-gmbh/isp-insoft-ai-skills
- 0.570score
desloppy
isp-insoft-gmbh
Use when cleaning or refactoring existing code to remove accidental complexity, duplication, needless indirection, weak types, or overengineering without…
SkillAFreshness: AClaude Code +9 - 0.567score
fxdriver
isp-insoft-gmbh
Drive and inspect JavaFX apps through fxdriver JSON-RPC.
SkillAFreshness: AClaude Code +9 - 0.561score
fxdriver-instructions
isp-insoft-gmbh
Clarify JavaFX workflow acceptance, data safety, source-edit scope and evidence requirements before a non-trivial fxdriver run.
SkillAFreshness: AClaude Code +9 - 0.552score
coding-guidelines
isp-insoft-gmbh
Use before writing code
SkillAFreshness: AClaude Code +9 - 0.524score
java-flexible-constructors
isp-insoft-gmbh
Use when Java 25+ constructors need validation, computed arguments, or field initialization before explicit `super(...)`/`this(...)`.
SkillBFreshness: BClaude Code +9 - 0.524score
java-scoped-values
isp-insoft-gmbh
Use when Java 25+ code passes immutable contextual data through call chains or child threads, especially instead of `ThreadLocal`.
SkillBFreshness: BClaude Code +9 - 0.523score
java-markdown-doc-comments
isp-insoft-gmbh
Use when writing or reviewing JDK 23+ Javadoc comments with `///` Markdown syntax.
SkillBFreshness: BClaude Code +9 - 0.523score
java-ml-dsa
isp-insoft-gmbh
Use when Java 24+ crypto needs quantum-resistant ML-DSA signatures via standard JCA APIs.
SkillBFreshness: BClaude Code +9 - 0.523score
java-ml-kem
isp-insoft-gmbh
Use when Java 24+ crypto needs quantum-resistant ML-KEM key encapsulation via standard JCA/JCE APIs.
SkillBFreshness: BClaude Code +9 - 0.523score
java-module-imports
isp-insoft-gmbh
Use when Java 25+ source can simplify many package imports with `import module ...;`.
SkillBFreshness: BClaude Code +9 - 0.523score
java-native-access-restrictions
isp-insoft-gmbh
Use when Java 24+ JNI or FFM code triggers native-access warnings or needs explicit native access flags.
SkillBFreshness: BClaude Code +9 - 0.523score
java-record-patterns
isp-insoft-gmbh
Use when Java 21+ code deconstructs records with `instanceof` or `switch`, especially nested record patterns.
SkillBFreshness: BClaude Code +9
Signals
- Stars
- 0
- Forks
- 0
- Open issues
- 0
- Last commit (this folder)
- Sep 7, 2026 (1 month ago)
From GitHub (fetched Oct 24, 2026).
Details
- License
- MIT
- First seen
- Oct 24, 2026
- Last checked
- Oct 24, 2026
- Source
- GitHubgithub-graphql
More from isp-insoft-gmbh
- 0.570score
desloppy
isp-insoft-gmbh
Use when cleaning or refactoring existing code to remove accidental complexity, duplication, needless indirection, weak types, or overengineering without…
SkillAFreshness: AClaude Code +9 - 0.567score
fxdriver
isp-insoft-gmbh
Drive and inspect JavaFX apps through fxdriver JSON-RPC.
SkillAFreshness: AClaude Code +9 - 0.561score
fxdriver-instructions
isp-insoft-gmbh
Clarify JavaFX workflow acceptance, data safety, source-edit scope and evidence requirements before a non-trivial fxdriver run.
SkillAFreshness: AClaude Code +9 - 0.552score
coding-guidelines
isp-insoft-gmbh
Use before writing code
SkillAFreshness: AClaude Code +9 - 0.524score
java-flexible-constructors
isp-insoft-gmbh
Use when Java 25+ constructors need validation, computed arguments, or field initialization before explicit `super(...)`/`this(...)`.
SkillBFreshness: BClaude Code +9 - 0.524score
java-scoped-values
isp-insoft-gmbh
Use when Java 25+ code passes immutable contextual data through call chains or child threads, especially instead of `ThreadLocal`.
SkillBFreshness: BClaude Code +9
Cite this page
java-ffm skill. Agent Mart. https://agentmart.dev/skills/isp-insoft-gmbh-java-ffm (last updated 2026-10-24)