feat(jni): JNI bindings with app.opendocument.core Java API - #617
Merged
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: cebf11c683
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
andiwand
force-pushed
the
python-bindings
branch
from
July 25, 2026 21:04
e7e94b6 to
92f4d26
Compare
Mirror the pyodr surface for Java: a hand-written JNI layer (jni/src) over the public C++ API and Java wrappers (enums, style/meta POJOs, handle-backed classes with Cleaner-based lifetime) in package app.opendocument.core. Toggled by ODR_JNI in CMake and with_jni in conan; JUnit 5 tests run via ctest with inline-generated inputs. Groundwork to replace the odr.droid CoreWrapper. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Gffw8AurchbpS1rL3kWwBd
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🤖 Generated with Claude Code
Built on the python bindings from #616 (now merged). Adds optional JNI bindings as a new top-level
jni/package, mirroring the pyodr surface for Java — groundwork to replace the ad-hoc odr.droidCoreWrapper.What's in here
ODR_JNICMake option (rootCMakeLists.txtaddsjni/), mirrored by awith_jniconan option — same pattern asODR_PYTHON/with_python.jni/CMakeLists.txtis the main build file and can also be configured standalone against an installedodrcore.jni/java/app/opendocument/core/, built intoodr-core-java.jar): mirrors the pyodr surface —Odr(open/identify/mimetype/...),GlobalParams,File/DecodedFile+ typed files,Document+ fullElementtree with typed views, style/meta POJOs,Html.translate→HtmlService/HtmlView/HtmlResource,HttpServer,OdrExceptionhierarchy mapped from the C++ exceptions.jni/src/, built intolibodr_jni): onejni_*unit per public-API area. Handles are heap copies of the C++ value handles referenced bylong; typed views are re-derived per call (as_paragraph()etc.) so no typed subobject ever sits behind a base-typed handle.NativeResourcefrees natives viaCleaner/AutoCloseable, and navigation results keep theirDocumentreachable (the JNI analogue of pyodr'skeep_alive). Strings cross as real UTF-8↔UTF-16 (not modified UTF-8); enums cross as ordinals with the order pinned to the C++ declarations.jni/tests/): JUnit 5 via ctest (odr_jni_junit, JUnit console jar fetched with a pinned SHA-256); inputs generated inline (zip-built minimal ODT incl. non-BMP characters, csv, txt) mirroringpython/tests. HTML tests skip withoutODR_CORE_DATA_PATH; the HTTP server test round-trips a served document..github/workflows/jni.yml(ubuntu + macos, conanwith_jni=True, builds and runs the JUnit suite), mirroringpython.yml's build-test job.jni/AGENTS.md(design rules: handle model, GC safety, marshalling),jni/README.md(build/usage), directory-map row in the rootAGENTS.md.Known limitations
HtmlConfig.resource_locatoris not exposed (function pointer across JNI); the standard locator is always used.HtmlConfig.resourcePath == nullkeeps the native default (odr core data path).jniCMake component.Test plan
cmake -DODR_JNI=ON+cmake --build … --target odr_jni odr_java odr_java_testson macOS (OpenJDK 25)ctest --test-dir build/jni— 25/25 JUnit tests pass locally (file open/meta, element tree incl. UTF round-trip, HTML translate offline/views, HTTP server round-trip)