{"id":16358349,"url":"https://github.com/digitalsmile/native-memory-processor","last_synced_at":"2026-02-22T21:03:24.751Z","repository":{"id":246484742,"uuid":"794948354","full_name":"DigitalSmile/native-memory-processor","owner":"DigitalSmile","description":"Java FFM API code generation library","archived":false,"fork":false,"pushed_at":"2025-03-30T06:03:28.000Z","size":48520,"stargazers_count":1,"open_issues_count":7,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-08T04:42:46.916Z","etag":null,"topics":["c","clang","code-generation","cpp","java","java-22","java-ffm","libclang","native-code"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/DigitalSmile.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-05-02T09:29:35.000Z","updated_at":"2025-03-30T06:03:32.000Z","dependencies_parsed_at":"2024-08-10T21:07:51.469Z","dependency_job_id":null,"html_url":"https://github.com/DigitalSmile/native-memory-processor","commit_stats":{"total_commits":58,"total_committers":1,"mean_commits":58.0,"dds":0.0,"last_synced_commit":"c00f722a2b46b172bf2b9c30bb7e4e578ec970d8"},"previous_names":["digitalsmile/native-memory-processor"],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/DigitalSmile/native-memory-processor","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DigitalSmile%2Fnative-memory-processor","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DigitalSmile%2Fnative-memory-processor/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DigitalSmile%2Fnative-memory-processor/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DigitalSmile%2Fnative-memory-processor/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/DigitalSmile","download_url":"https://codeload.github.com/DigitalSmile/native-memory-processor/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DigitalSmile%2Fnative-memory-processor/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":276074540,"owners_count":25580903,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-20T02:00:10.207Z","response_time":63,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["c","clang","code-generation","cpp","java","java-22","java-ffm","libclang","native-code"],"created_at":"2024-10-11T02:05:23.662Z","updated_at":"2025-09-20T09:24:28.112Z","avatar_url":"https://github.com/DigitalSmile.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Java Native Memory Processing\n![](https://img.shields.io/badge/Java-22+-success)\n![Maven Central Version](https://img.shields.io/maven-central/v/io.github.digitalsmile.native/annotation?label=annotation)\n![Maven Central Version](https://img.shields.io/maven-central/v/io.github.digitalsmile.native/annotation-processor?label=annotation-processor)\n![GitHub Actions Workflow Status](https://img.shields.io/github/actions/workflow/status/digitalsmile/native-memory-processor/gradle.yml)\n\n#### Create an interop code with ease.\n\n## Introduction\n\nWith the release of JDK 22 the new Foreign Function \u0026 Memory API (FFM API) has been introduced from preview phase.\n\nThis API is intended to substitute Java Native Interface (JNI) and become a standard of interacting with native code from Java.\n\nWhile FFM API itself is very powerful and can provide access to onheap/offheap memory segments and call a native function, it is lacking of extended features of converting C/C++ structures to Java classes. \nOf course, we have `jextract` tool, but the code it generates is kind of messy and hard to understand.\n\nThis project goal is to combine the power of FFM API and Java, like annotation processing, to make you happy while working with native functions and structures.\n\n## Features\n- two separate libraries - `annotation` and `annotation-processor` working with code generation during compile time\n- C/C++ types support in top level: struct, union, enum (including anonymous and opaque)\n- context based generation: combine several native libraries within one code base \n- can load third party native libraries or use already loaded by classloader\n- flexible native-to-java function declarations\n- pass to native functions primitives and objects, by value or just a pointer\n- java exceptions with the power of errno/strerr \n- safe and clean code generation\n- useful helpers to work with structures, like `.createEmpty()`\n- ready to write your project unit tests with generated native structures\n\n## Requirements\n\n- `JDK22+` with FFM API enabled ( use `--enable-native-access=ALL-UNNAMED` run parameter or add `Enable-Native-Access: ALL-UNNAMED` to jar manifest file)\n- `glibc 2.31+` (ubuntu 20.04+ or MacOS Sonoma+) on host machine where annotation processor is running (requirement for `libclang`). \nWindows hosts are not yet supported.\n\n## Quick start\n\n1) Add dependencies to your `build.gradle`:\n```groovy\ndependencies {\n    // Annotations to use for code generation\n    implementation 'io.github.digitalsmile.native:annotation:${version}'\n    // Process annotations and generate code at compile time\n    annotationProcessor 'io.github.digitalsmile.native:annotation-processor:${version}'\n}\n```\n\n2) Define interface class and run your build:\n```java\n@NativeMemory(header = \"gpio.h\")\n@Structs\n@Enums\npublic interface GPIO {\n    @NativeManualFunction(name = \"ioctl\", useErrno = true)\n    int nativeCall(int fd, long command, int data) throws NativeMemoryException;\n}\n```\nThis code snippet will generate all structures and enums within the header file `gpio.h` (located in `resources` folder), as well as `GPIONative` class with call implementation of `ioctl` native function.\n\nObserve concepts in [doucmentation](CONCEPTS.md) or find more examples in [getting started](USAGE.md). You can also look at [tests](annotation-processor-test/src/test/java/io/github/digitalsmile/gpio) or in my other project https://github.com/digitalsmile/gpio \n\n3) Enjoy! :)\n\n## Plans\n\n- more support of native C/C++ types and patterns\n- validation of structures parameters and custom validation support","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdigitalsmile%2Fnative-memory-processor","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdigitalsmile%2Fnative-memory-processor","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdigitalsmile%2Fnative-memory-processor/lists"}