fix(jni): require a jdk for the jar rather than shipping without it - #712
Merged
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 68cd350bed
ℹ️ 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".
`find_package(Java)` was optional on android so the AAR build, which compiles `jni/java/` with the android toolchain, would not need a JDK. That made a missing JDK silently drop `odr-core-java.jar` from the android odrcore package too — where OpenDocument.droid takes the jar out of the package and fails much later, looking like a broken deployer. The jar is not an android-vs-not question, so ask it directly: `ODR_JNI_JAR` (default `ON`) says whether the java half is wanted, and with it on a JDK is `REQUIRED` everywhere. `android/build_native.py` turns it off, which is the one build that genuinely wants the native half alone. `find_package(JNI)` stays behind `if (NOT ANDROID)` — the NDK sysroot ships `jni.h` and the symbols come from the runtime. Closes #637 Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XDs5aK3ZGSZsEvqUUwBBXU
…ment Only on android. Everywhere else `find_package(JNI REQUIRED)` runs regardless, and CMake's `FindJNI` wants a JDK for the headers — so a host build with the jar off and no JDK still fails to configure, as it should. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XDs5aK3ZGSZsEvqUUwBBXU
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015d5RcmsA777vwXiuafjx6k
andiwand
force-pushed
the
fix/jni-require-jdk
branch
from
August 20, 2026 12:11
f142780 to
91ef4e0
Compare
andiwand
enabled auto-merge (squash)
August 20, 2026 12:12
andiwand
disabled auto-merge
August 20, 2026 12:12
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
Closes #637.
jni/CMakeLists.txtlooked for a JDK withoutREQUIREDon android, so that the AAR build — which compilesjni/java/with the android toolchain — would not need one. The cost was that a build machine with nojavacproduced an android odrcore package withlibodr_jni.soand noodr-core-java.jar, even though the option asked for waswith_jni=True. OpenDocument.droid takes the jar out of that package, so the failure surfaced much later as aFileNotFoundErroron the deployer's path.The jar is not an android-vs-not question, so this asks it directly:
ODR_JNI_JAR(defaultON) says whether the java half is wanted. With it on,find_package(Java 11 REQUIRED COMPONENTS Development)runs everywhere, android included.android/build_native.pypasses-DODR_JNI_JAR=OFF— it is the one build that genuinely wants the native half alone, and it now needs no JDK at all rather than relying on one being optional.find_package(JNI REQUIRED)stays behindif (NOT ANDROID): the NDK sysroot shipsjni.hand the symbols come from the runtime.So "no jar" is something a caller asked for rather than something the environment decided.
Verified
Configured against the repo with a
PATH/JAVA_HOMEcarrying no JDK:ODR_JNI_JAR=OFF(the AAR build)find_package(Java)at allwith_jni=True)Could NOT find Java, configure failsCould NOT find JavaCould NOT find JavaAnd with a JDK present,
cmake --build … --target odr_javastill producesodr-core-java.jar.