Skip to content

feat(jni): JNI bindings with app.opendocument.core Java API - #617

Merged
andiwand merged 1 commit into
mainfrom
jni-bindings
Jul 26, 2026
Merged

feat(jni): JNI bindings with app.opendocument.core Java API#617
andiwand merged 1 commit into
mainfrom
jni-bindings

Conversation

@andiwand

@andiwand andiwand commented Jul 25, 2026

Copy link
Copy Markdown
Member

🤖 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.droid CoreWrapper.

What's in here

  • Toggles: ODR_JNI CMake option (root CMakeLists.txt adds jni/), mirrored by a with_jni conan option — same pattern as ODR_PYTHON/with_python. jni/CMakeLists.txt is the main build file and can also be configured standalone against an installed odrcore.
  • Java API (jni/java/app/opendocument/core/, built into odr-core-java.jar): mirrors the pyodr surface — Odr (open/identify/mimetype/...), GlobalParams, File/DecodedFile + typed files, Document + full Element tree with typed views, style/meta POJOs, Html.translateHtmlService/HtmlView/HtmlResource, HttpServer, OdrException hierarchy mapped from the C++ exceptions.
  • JNI layer (jni/src/, built into libodr_jni): one jni_* unit per public-API area. Handles are heap copies of the C++ value handles referenced by long; typed views are re-derived per call (as_paragraph() etc.) so no typed subobject ever sits behind a base-typed handle. NativeResource frees natives via Cleaner/AutoCloseable, and navigation results keep their Document reachable (the JNI analogue of pyodr's keep_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.
  • Tests (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) mirroring python/tests. HTML tests skip without ODR_CORE_DATA_PATH; the HTTP server test round-trips a served document.
  • CI: .github/workflows/jni.yml (ubuntu + macos, conan with_jni=True, builds and runs the JUnit suite), mirroring python.yml's build-test job.
  • Docs: jni/AGENTS.md (design rules: handle model, GC safety, marshalling), jni/README.md (build/usage), directory-map row in the root AGENTS.md.

Known limitations

  • HtmlConfig.resource_locator is not exposed (function pointer across JNI); the standard locator is always used. HtmlConfig.resourcePath == null keeps the native default (odr core data path).
  • Distribution (Maven/AAR packaging) is intentionally out of scope for this PR; the jar + shared lib install via the jni CMake component.

Test plan

  • cmake -DODR_JNI=ON + cmake --build … --target odr_jni odr_java odr_java_tests on 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)

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread jni/java/app/opendocument/core/HttpServer.java
Comment thread jni/CMakeLists.txt
Base automatically changed from python-bindings to main July 25, 2026 21:31
@andiwand andiwand changed the title feat(jni): JNI bindings with app.opendocument Java API feat(jni): JNI bindings with app.opendocument.core Java API Jul 25, 2026
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
@andiwand
andiwand merged commit ddf18fa into main Jul 26, 2026
21 checks passed
@andiwand
andiwand deleted the jni-bindings branch July 26, 2026 06:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant