{"id":36420232,"url":"https://github.com/aploese/jnhw","last_synced_at":"2026-01-11T17:05:58.083Z","repository":{"id":57730553,"uuid":"168463219","full_name":"aploese/jnhw","owner":"aploese","description":"JNI Header Wrapper a lightwight alternative to JNA or JNR (V 4.0.0-SNAPSHOT in branch FFM  uses JEP 454: Foreign Function \u0026 Memory API)","archived":false,"fork":false,"pushed_at":"2025-03-11T13:27:50.000Z","size":18789,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-08-02T16:02:17.476Z","etag":null,"topics":["ffm","foreign-function-and-memory-api","jep-442","jep-454","jna","jni","jnr"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/aploese.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.LGPL-3.0.txt","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":"2019-01-31T04:32:18.000Z","updated_at":"2025-05-10T16:03:13.000Z","dependencies_parsed_at":"2024-04-08T20:32:02.017Z","dependency_job_id":"2382a7c2-00da-49ff-a08b-f2a8147b59e8","html_url":"https://github.com/aploese/jnhw","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/aploese/jnhw","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aploese%2Fjnhw","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aploese%2Fjnhw/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aploese%2Fjnhw/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aploese%2Fjnhw/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/aploese","download_url":"https://codeload.github.com/aploese/jnhw/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aploese%2Fjnhw/sbom","scorecard":{"id":202913,"data":{"date":"2025-08-11","repo":{"name":"github.com/aploese/jnhw","commit":"a5b0f8afde1e59abbb90f66acf302bfacaec9a6a"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":2.9,"checks":[{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Dangerous-Workflow","score":10,"reason":"no dangerous workflow patterns detected","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Code-Review","score":0,"reason":"Found 0/30 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Token-Permissions","score":0,"reason":"detected GitHub workflow tokens with excessive permissions","details":["Warn: no topLevel permission defined: .github/workflows/maven.yml:1","Info: no jobLevel write permissions found"],"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"SAST","score":0,"reason":"no SAST tool detected","details":["Warn: no pull requests merged into dev branch"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Binary-Artifacts","score":0,"reason":"binaries present in source code","details":["Warn: binary detected: de.ibapl.jnhw.common/src/main/resources/lib/aarch64-linux-gnu/libjnhw-common.so.4:1","Warn: binary detected: de.ibapl.jnhw.common/src/main/resources/lib/arm-linux-gnueabihf/libjnhw-common.so.4:1","Warn: binary detected: de.ibapl.jnhw.common/src/main/resources/lib/i386-linux-gnu/libjnhw-common.so.4:1","Warn: binary detected: de.ibapl.jnhw.common/src/main/resources/lib/mips64el-linux-gnuabi64/libjnhw-common.so.4:1","Warn: binary detected: de.ibapl.jnhw.common/src/main/resources/lib/powerpc-linux-gnu/libjnhw-common.so.4:1","Warn: binary detected: de.ibapl.jnhw.common/src/main/resources/lib/powerpc64le-linux-gnu/libjnhw-common.so.4:1","Warn: binary detected: de.ibapl.jnhw.common/src/main/resources/lib/riscv64-linux-gnu/libjnhw-common.so.4:1","Warn: binary detected: de.ibapl.jnhw.common/src/main/resources/lib/s390x-linux-gnu/libjnhw-common.so.4:1","Warn: binary detected: de.ibapl.jnhw.common/src/main/resources/lib/x86_64-apple-darwin/libjnhw-common.4.dylib:1","Warn: binary detected: de.ibapl.jnhw.common/src/main/resources/lib/x86_64-linux-gnu/libjnhw-common.so.4:1","Warn: binary detected: de.ibapl.jnhw.common/src/main/resources/lib/x86_64-windows-pe32+/libjnhw-common-4.dll:1"],"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE.LGPL-3.0.txt:0","Info: FSF or OSI recognized license: GNU Lesser General Public License v3.0 only: LICENSE.LGPL-3.0.txt:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"Pinned-Dependencies","score":6,"reason":"dependency not pinned by hash detected -- score normalized to 6","details":["Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/maven.yml:23: update your workflow using https://app.stepsecurity.io/secureworkflow/aploese/jnhw/maven.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/maven.yml:25: update your workflow using https://app.stepsecurity.io/secureworkflow/aploese/jnhw/maven.yml/master?enable=pin","Info:   0 out of   2 GitHub-owned GitHubAction dependencies pinned","Info:   1 out of   1 third-party GitHubAction dependencies pinned"],"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}}]},"last_synced_at":"2025-08-16T23:07:58.561Z","repository_id":57730553,"created_at":"2025-08-16T23:07:58.561Z","updated_at":"2025-08-16T23:07:58.561Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28314264,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-11T14:58:17.114Z","status":"ssl_error","status_checked_at":"2026-01-11T14:55:53.580Z","response_time":60,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["ffm","foreign-function-and-memory-api","jep-442","jep-454","jna","jni","jnr"],"created_at":"2026-01-11T17:05:58.008Z","updated_at":"2026-01-11T17:05:58.072Z","avatar_url":"https://github.com/aploese.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Java Native Header Wrapper (JNHW)\n\nJNI Header Wrapper a lightweight alternative to JNA or JNR\nand a helper to resolve a native lib by name and libtool version.\n\nUnlike JNR or JNA\n* all macro constants are natively resolved.\n* all structures will be natively allocated and its filed natively accessed. [StructTermios in Termios.java](./de.ibapl.jnhw.posix/src/main/java/de/ibapl/jnhw/posix/Termios.java) and the jni bindings [Termios_Termios.c](de.ibapl.jnhw.posix/src/main/native/Termios_Termios.c) and [TermiosDefines.c](de.ibapl.jnhw.posix/src/main/native/TermiosDefines.c) and [TermiosFunctions.c](de.ibapl.jnhw.posix/src/main/native/TermiosFunctions.c) . Struct termios varies over the OS and even on Linux on different architectures like (i.e. mips is different from the rest).\n* different sizes, alignments and offset of struct members are handled natively like stuct mcontext_t [Tests testAlignOfMcontext_t testSizeOfMcontext_t in SignalTest.java](./de.ibapl.jnhw.posix/src/test/java/de/ibapl/jnhw/posix/SignalTest.java).\n  Examples for [struct and union](./it/fun-with-memory-and-function-pointers/src/main/java/de/ibapl/jnhw/it/fun_with_memory_and_function_pointers/Struct.java)\n  and [function pointer](./it/fun-with-memory-and-function-pointers/src/main/java/de/ibapl/jnhw/it/fun_with_memory_and_function_pointers/FunctionPointer.java) are in teh exaples modules.\n* it does not use sun.misc.Unsafe but allocate the memory by itself.\n* callbacks from and calls of native functions are supported [Callback_I_V_Impl.java](de.ibapl.jnhw.common/src/main/java/de/ibapl/jnhw/common/callback/Callback_I_V_Impl.java),\n  and its counterpart [CallNative_J_V.java](de.ibapl.jnhw.common/src/main/java/de/ibapl/jnhw/common/nativecall/CallNative_J_V.java),\n  and their common ancestor [FunctionPtr_I_V.java](de.ibapl.jnhw.common/src/main/java/de/ibapl/jnhw/common/nativepointer/FunctionPtr_I_V.java).\n\nA running \"real life\" comparison can be found here: [JNHW-Example: Compare JNHW, JNR, JNA](./it/jnhw-jna-jnr/src/main/java/de/ibapl/jnhw/it/jnhw_jna_jnr/).\n\nAdd this dependency for POSIX.\n\n```\n\u003cdependency\u003e\n    \u003cgroupId\u003ede.ibapl.jnhw\u003c/groupId\u003e\n    \u003cartifactId\u003ede.ibapl.jnhw.posix\u003c/artifactId\u003e\n    \u003cversion\u003e[3.0.0,4.0.0)\u003c/version\u003e\n\u003c/dependency\u003e\n```\nand this for the Windows API\n\n```\n\u003cdependency\u003e\n    \u003cgroupId\u003ede.ibapl.jnhw\u003c/groupId\u003e\n    \u003cartifactId\u003ede.ibapl.jnhw.winapi\u003c/artifactId\u003e\n    \u003cversion\u003e[3.0.0,4.0.0)\u003c/version\u003e\n\u003c/dependency\u003e\n```\n# Usage\n\n# Error Handling\n\nIf an native error occured and the called function flags an error condition to the caller. One calls for ISO C errno and for the windows API GetLastError(). this is done in the jni wrapper which throws the checked exception [NativeErrorException](./de.ibapl.jnhw.common/src/main/java/de/ibapl/jnhw/NativeErrorException.java) in that case.\n\n# State\n\n## Branch master\n\n| Test Platform         | VM version | Hotspot VM (Java Foreign)  | Zero VM (Java Foreign)     | Hotspot VM (JNI)           | Zero VM (JNI)              |\n| :-------------------- | :--------- | :------------------------: | :------------------------: | :------------------------: | :------------------------: |\n| aarch64-freebsd-bsd   | 23         | no OpenJDK23    2025-02-17 | no OpenJDK23    2025-02-17 | no OpenJDK23    2025-02-17 | no OpenJDK23    2025-02-17 |\n| aarch64-linux-gnu     | 23.0.2     | success         2025-02-26 | no JFF          2025-02-26 | not included by default    | not included by default    |\n| aarch64-netbsd-bsd    | 23         | no OpenJDK23    2025-02-17 | no OpenJDK23    2025-02-17 | no OpenJDK23    2025-02-17 | no OpenJDK23    2025-02-17 |\n| aarch64-openbsd-bsd   | 23         | no OpenJDK23    2025-02-17 | no OpenJDK23    2025-02-17 | no OpenJDK23    2025-02-17 | no OpenJDK23    2025-02-17 |\n| arm-freebsd-bsd       | 23         | no OpenJDK23    2025-02-17 | no OpenJDK23    2025-02-17 | no OpenJDK23    2025-02-17 | no OpenJDK23    2025-02-17 |\n| arm-linux-gnueabihf   | 23.0.2     | no Server VM    2025-02-26 | success         2025-02-26 | not included by default    | not included by default    |\n| arm-netbsd-bsd        | 23         | no OpenJDK23    2025-02-17 | no OpenJDK23    2025-02-17 | no OpenJDK23    2025-02-17 | no OpenJDK23    2025-02-17 |\n| arm-openbsd-bsd       | 23         | no OpenJDK23    2025-02-17 | no OpenJDK23    2025-02-17 | no OpenJDK23    2025-02-17 | no OpenJDK23    2025-02-17 |\n| i386-freebsd-bsd      | 23         | no OpenJDK23    2025-02-17 | no OpenJDK23    2025-02-17 | no OpenJDK23    2025-02-17 | no OpenJDK23    2025-02-17 |\n| i386-linux-gnu        | 23.0.2     | no Server VM    2025-02-26 | success         2025-02-26 | not included by default    | not included by default    |\n| i386-netbsd-bsd       | 23         | no OpenJDK23    2025-02-17 | no OpenJDK23    2025-02-17 | no OpenJDK23    2025-02-17 | no OpenJDK23    2025-02-17 |\n| i386-openbsd-bsd      | 23         | no OpenJDK23    2025-02-17 | no OpenJDK23    2025-02-17 | no OpenJDK23    2025-02-17 | no OpenJDK23    2025-02-17 |\n| mips64el-linux-gnu    | 23.0.2     | success         2025-02-24 | Test Garbage    2025-02-24 | not included by default    | not included by default    |\n| powerpc-linux-gnu     | 23.0.2     | no Server VM    2025-02-26 | JFF is broken   2025-02-26 | not included by default    | not included by default    |\n| powerpc64le-linux-gnu | 23.0.2     | success         2025-02-26 | no JFF          2025-02-26 | not included by default    | not included by default    |\n| riscv64-linux-gnu     | 23.0.2     | success         2025-02-26 | no JFF          2025-02-26 | not included by default    | not included by default    |\n| s390x-linux-gnu       | 23.0.2     | success         2025-02-26 | no JFF          2025-02-26 | not included by default    | not included by default    |\n| x86_64-apple-darwin   | 23.0.2     | success         2025-03-11 | n.a.            2025-03-11 | success         2025-03-11 | n.a.            2025-03-11 |\n| x86_64-freebsd-bsd    | 23         | no OpenJDK23    2025-02-17 | no OpenJDK23    2025-02-17 | no OpenJDK23    2025-02-17 | no OpenJDK23    2025-02-17 |\n| x86_64-linux-gnu      | 23.0.2     | success         2025-02-26 | no JFF          2025-02-26 | not included by default    | not included by default    |\n| x86_64-netbsd-bsd     | 23         | no OpenJDK23    2025-02-17 | no OpenJDK23    2025-02-17 | no OpenJDK23    2025-02-17 | no OpenJDK23    2025-02-17 |\n| x86_64-openbsd-bsd    | 23         | no OpenJDK23    2025-02-17 | no OpenJDK23    2025-02-17 | no OpenJDK23    2025-02-17 | no OpenJDK23    2025-02-17 |\n| x86_64-windows-pe32+  | 19.0.1     | success         2023-01-26 | n.a.            2023-01-27 | not included by default    | not included by default    |\n\nn.a. ... the feature are not available.\n\n# Demos\n## Hello World\nSee [subdirectory it/hello-world/](./it/hello-world).\nrun `mvn exec:java -Dexec.mainClass=\"de.ibapl.jnhw.it.hello_world.App\"` in `it/hello_world`.\n\n### POSIX\n\nImport Unistd in a static manner so the code may become less noisy.\n\n```java\npackage de.ibapl.jnhw.it.hello_world;\n\nimport de.ibapl.jnhw.NativeErrorException;\n//Import only the needed define from the wrapper of posix's unistd.h.h\nimport static de.ibapl.jnhw.posix.Unistd.STDOUT_FILENO;\n//Import only the needed method from the wrapper of iso c's unistd.h.h\nimport static de.ibapl.jnhw.posix.Unistd.write;\n\npublic class Posix {\n\n\tpublic static void sayHello() throws NativeErrorException {\n\t\tint bytesWritten = write(STDOUT_FILENO, \"Hello World! from POSIX\\n\".getBytes());\n                System.out.println(\"Bytes written: \" + bytesWritten);\n\t}\n\n}\n```\n\n### Windows API\n\n```java\npackage de.ibapl.jnhw.it.hello_world;\n\nimport de.ibapl.jnhw.NativeErrorException;\n//Import only the needed define from the wrapper of processenv.h\nimport static de.ibapl.jnhw.winapi.Winbase.STD_OUTPUT_HANDLE;\n//Import only the needed method from the wrapper of processenv.h\nimport static de.ibapl.jnhw.winapi.ProcessEnv.GetStdHandle;\n//Import only the needed method from the wrapper of fileapi.h\nimport static de.ibapl.jnhw.winapi.Fileapi.WriteFile;\n\npublic class Windows {\n\n\tpublic static void sayHello() throws NativeErrorException {\n\t\tint bytesWritten = WriteFile(GetStdHandle(STD_OUTPUT_HANDLE), \"Hello World! from WIN API\\n\".getBytes());\n                System.out.println(\"Bytes written: \" + bytesWritten);\n\t}\n\n}\n```\n\ncreate a file named test.c and include the needed headers.\nrun\n```sh\ngcc  -dD -dI -E test.c  | less\n```\nto see the preprocessed defines\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faploese%2Fjnhw","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faploese%2Fjnhw","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faploese%2Fjnhw/lists"}