{"id":22928925,"url":"https://github.com/ammbra/treasures","last_synced_at":"2026-04-14T03:32:57.406Z","repository":{"id":267858314,"uuid":"868194911","full_name":"ammbra/treasures","owner":"ammbra","description":"Sample code for running jextract over native libraries' headers for C, OpenGL, Python.","archived":false,"fork":false,"pushed_at":"2024-10-07T13:57:32.000Z","size":896,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-10T17:18:06.362Z","etag":null,"topics":["c","java22","java23","jdk22","jdk23","jextract","opengl","python3"],"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/ammbra.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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,"zenodo":null}},"created_at":"2024-10-05T18:08:56.000Z","updated_at":"2025-09-25T18:55:08.000Z","dependencies_parsed_at":null,"dependency_job_id":"471715b5-965c-4f9f-90e1-aec44c8d6568","html_url":"https://github.com/ammbra/treasures","commit_stats":null,"previous_names":["ammbra/treasures"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/ammbra/treasures","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ammbra%2Ftreasures","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ammbra%2Ftreasures/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ammbra%2Ftreasures/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ammbra%2Ftreasures/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ammbra","download_url":"https://codeload.github.com/ammbra/treasures/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ammbra%2Ftreasures/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31781292,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-14T02:24:21.117Z","status":"ssl_error","status_checked_at":"2026-04-14T02:24:20.627Z","response_time":153,"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":["c","java22","java23","jdk22","jdk23","jextract","opengl","python3"],"created_at":"2024-12-14T09:28:24.513Z","updated_at":"2026-04-14T03:32:57.401Z","avatar_url":"https://github.com/ammbra.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# From native code gems to Java treasures\n\n## Prerequisites\n\nYou need the following components to run the samples provided here:\n\n* [JDK 22+](https://jdk.java.net/) installed on your machine.\n* [jextract binaries](https://jdk.java.net/jextract/).\n* Python installed for running the Python example.\n\n## How to use the sample with C code\n\n1. Obtain Java bindings to C by running in a terminal window:\n\n```shell\n# macOS compatible command\nexport C_INCLUDE_PATH=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include\njextract --output src -t org.unix -I $C_INCLUDE_PATH $C_INCLUDE_PATH/time.h\n\n# Linux\nexport C_INCLUDE_PATH=/usr/include/\njextract --output src -t org.unix -I $C_INCLUDE_PATH $C_INCLUDE_PATH/time.h\n```\n\n2. Run `TimeTranslator.java` with the following command:\n\n```shell\n# macOS and Linux compatible command\njava --enable-native-access=ALL-UNNAMED --enable-preview --source 23 src/TimeTranslator.java\n```\n\u003e The `--enable-native-access=ALL-UNNAMED` option enables warning-free use for all code on the class path.\n\n## How to use the sample with Python code\n\n1. Obtain Java bindings to Python by running in a terminal window:\n\n```shell\n# macOS and Linux compatible command\njextract --output src \\\n    -l :/Library/Frameworks/Python.framework/Versions/3.11/lib/libpython3.11.dylib \\\n    -I $/Library/Frameworks/Python.framework/Versions/3.11/include/python3.11 \\\n    -t org.python \\\n    /Library/Frameworks/Python.framework/Versions/3.11/include/python3.11/Python.h\n```\n\n2. Run `PyDukerMaker.java` with the following command:\n\n```shell\n# macOS and Linux compatible command\njava --enable-native-access=ALL-UNNAMED --enable-preview --source 23 src/PyDukeMaker.java\n```\n\n## How to use the sample for OpenGL \n\nIn order to run successfully, the  following commands need also the presence of _compile_flags.txt_.\n\n1. Dump of all the symbols encountered in a header file:\n\n```shell\n# macOS and Linux compatible command\njextract --output src \\\n    -l :/opt/homebrew/Cellar/freeglut/3.6.0/lib \\\n    -I /opt/homebrew/Cellar/freeglut \\\n    -I /opt/homebrew/Cellar/mesa \\\n    -I /opt/homebrew/Cellar/mesa-glu \\\n    -t org.freeglut \\\n    --dump-includes glut.symbols \\\n    /opt/homebrew/Cellar/freeglut/3.6.0/include/GL/freeglut.h\n```\n\n2. Obtain Java bindings to OpenGL by running the filtering file:\n\n```shell\n# macOS and Linux compatible command\njextract --output src \\\n    -l :/opt/homebrew/Cellar/freeglut/3.6.0/lib \\\n    -I /opt/homebrew/Cellar/freeglut \\\n    -I /opt/homebrew/Cellar/mesa \\\n    -I /opt/homebrew/Cellar/mesa-glu \\\n    -t org.freeglut @glut.symbols \\\n    /opt/homebrew/Cellar/freeglut/3.6.0/include/GL/freeglut.h\n```\n\n3. Run `Teapot.java` with:\n\n```shell\njava -XstartOnFirstThread --enable-native-access=ALL-UNNAMED src/Teapot.java\n```\n\n\u003e The JVM flag `-XstartOnFirstThread` is used to ensure that the Java application starts on the main thread of the first available GUI event dispatching thread when running on Mac OS X.\n\nWhen debugging an application is useful to inspect the parameters passed to a native call. Code generated by jextract supports tracing of native calls, meaning parameters passed to native calls can be printed on the standard output.\n\nTo enable the tracing support, just pass the `-Djextract.trace.downcalls=true` flag as a VM argument when launching your application:\n\n```shell\n# macOS and Linux compatible command\njava -XstartOnFirstThread -Djextract.trace.downcalls=true --enable-native-access=ALL-UNNAMED src/Teapot.java\n```\n\n## How to run the sample with Rust\n\nThis example was created by Jorn Vernee and you can find out all about it by reading his blog post https://jornvernee.github.io/java/panama/rust/panama-ffi/2021/09/03/rust-panama-helloworld.html.\n\n1. Obtain Java bindings to Rust by running in a terminal window:\n\n```shell\njextract --output src -t org.rust --include-function hello_world \\\n  -l :./rust-panama-helloworld/target/debug/librust_panama_helloworld.dylib \\\n  rust-panama-helloworld/lib.h \n```\n\n2. Run `SimpleRust.java` by using the following command:\n\n```shell\njava --enable-native-access=ALL-UNNAMED --enable-preview --source 23 src/SimpleRust.java\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fammbra%2Ftreasures","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fammbra%2Ftreasures","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fammbra%2Ftreasures/lists"}