Skip to content

fix(jni): require a jdk for the jar rather than shipping without it - #712

Merged
andiwand merged 3 commits into
mainfrom
fix/jni-require-jdk
Aug 20, 2026
Merged

fix(jni): require a jdk for the jar rather than shipping without it#712
andiwand merged 3 commits into
mainfrom
fix/jni-require-jdk

Conversation

@andiwand

Copy link
Copy Markdown
Member

🤖 Generated with Claude Code

Closes #637.

jni/CMakeLists.txt looked for a JDK without REQUIRED on android, so that the AAR build — which compiles jni/java/ with the android toolchain — would not need one. The cost was that a build machine with no javac produced an android odrcore package with libodr_jni.so and no odr-core-java.jar, even though the option asked for was with_jni=True. OpenDocument.droid takes the jar out of that package, so the failure surfaced much later as a FileNotFoundError on the deployer's path.

The jar is not an android-vs-not question, so this asks it directly:

  • ODR_JNI_JAR (default ON) says whether the java half is wanted. With it on, find_package(Java 11 REQUIRED COMPONENTS Development) runs everywhere, android included.
  • android/build_native.py passes -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 behind if (NOT ANDROID): the NDK sysroot ships jni.h and 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_HOME carrying no JDK:

configure before after
android, ODR_JNI_JAR=OFF (the AAR build) ok ok — no find_package(Java) at all
android, default (with_jni=True) ok, package missing the jar Could NOT find Java, configure fails
host build, default Could NOT find Java Could NOT find Java

And with a JDK present, cmake --build … --target odr_java still produces odr-core-java.jar.

@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: 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".

Comment thread jni/README.md Outdated
andiwand and others added 3 commits August 20, 2026 14:10
`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
andiwand force-pushed the fix/jni-require-jdk branch from f142780 to 91ef4e0 Compare August 20, 2026 12:11
@andiwand
andiwand enabled auto-merge (squash) August 20, 2026 12:12
@andiwand
andiwand disabled auto-merge August 20, 2026 12:12
@andiwand
andiwand merged commit 3e911ed into main Aug 20, 2026
27 checks passed
@andiwand
andiwand deleted the fix/jni-require-jdk branch August 20, 2026 12:12
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.

android: with_jni silently ships no odr-core-java.jar when no JDK is on the build machine

1 participant