Repository navigation
[jnienv-gen] Remove the obsolete raw JNI backend - #13100
Merged
Merged
Conversation
The product has always selected Java.Interop when generating Android.Runtime.JNIEnv. The alternate backend is no longer usable and still emits a call to the unavailable exception-lookup helper. Remove raw JNI structs, invokers, delegates, array wrappers, exception handling, null checks, and their exclusive metadata. Keep the shared JNI function table and current Java.Interop forwarders unchanged. Rename the authoritative metadata input to JNIEnvEntries.cs to distinguish it from generated output. Retire the legacy default mode and --use-java-interop CLI selection. Generation is now always Java.Interop; update the in-tree invocation and documentation. Generated file and stdout bytes match the previous Java.Interop mode exactly, including newline behavior. Validate the own Debug SDK, explicit net11.0 managed/API builds, and 478 existing generator/codegen tests. No shipped runtime behavior or public API changes. Context: #13092 (comment) Co-authored-by: Copilot App <[email protected]>
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
The cleanup consistently removes the inactive backend while preserving the active generated output and updating all in-tree references.
0 open findings
What changed in this PR
Removes the obsolete raw JNI generation backend so jnienv-gen exclusively emits Java.Interop forwarders.
Changes:
- Removes legacy backend code and metadata.
- Renames the metadata input to
JNIEnvEntries.cs. - Updates invocation and documentation for the simplified CLI.
| File | Description |
|---|---|
Documentation/project-docs/ExploringSources.md |
Documents Java.Interop-only generation. |
build-tools/jnienv-gen/JNIEnvEntries.cs |
Removes raw-backend metadata. |
build-tools/jnienv-gen/Generator.cs |
Deletes raw generation and mode selection. |
build-tools/create-android-api/create-android-api.csproj |
Removes the retired CLI flag. |
🧠 Review effort: Balanced
Remove the description of the retired backend and mode-selection option. Keep the documentation focused on current Java.Interop generation, output options, and the metadata input. Co-authored-by: Copilot App <[email protected]>
simonrozsival
enabled auto-merge (squash)
October 13, 2026 07:29
Member
Author
|
@dalexsoto review |
jonathanpeppers
approved these changes
Oct 13, 2026
21 of 23 tasks
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
The product generates
Android.Runtime.JNIEnvthrough Java.Interop. The unused raw JNI backend is no longer usable and still emits a call to the unavailable exception-lookup helper. Delete that backend instead of maintaining unreachable alternate implementations.Remove the raw JNI struct/invoker, delegates,
Envwrappers, exception and null-check helpers, and exclusive prototype/throw/null-check metadata. Keep the complete shared JNI function table, current forwarders, params overloads, and hand-bound skips. The authoritative metadata input has no in-tree producer; rename it fromGenerator.g.cstoJNIEnvEntries.csto distinguish it from generated output.Intentional tooling contract change: retire the legacy default mode and
--use-java-interopmode selection. Output is now always Java.Interop. Update the in-tree invocation and directly related docs. There are no shipped runtime behavior, public API, ownership, GC, or nullability changes, and no changes underexternal/Java.Interop.Independent follow-up to the discussion on #13092, not a prerequisite or stacked PR. Base:
c36449d35ab022bd78230c474ad63d254cd8d2e8(main). Validated commit:4593581d1ab37051d0e26ef8675c3e28b4968acb; tested source tree:a8ed4e32ce0a824fa52dccbc0df99854d08f3f16.Output equivalence
Before edits, build the generator in this worktree and save
--use-java-interopoutput. After edits, build and run without the flag.cmppasses for file output,-o=-, and the actual generatedsrc/Mono.Android/Android.Runtime/JNIEnv.g.cs. No generated output was hand-edited or included in this PR.Generation/comparison commands (baseline commands run before edits):
All commands passed.
JNIEnv.g.cs3e3d86192ef85b16540a17b8e0b8fb708854727c030521423698e3de80e98bec-o=-)9b9508c4b60fe515e21e306e36314294d5593b17142eaa2864118cdf239361d7LF newlines and stdout's additional trailing newline are preserved. Executable checks also pass for short/long output options,
--rootwith default output and with stdout, unchanged-file timestamps, and write failures returning 1 with the original exception diagnostic.Local validation
All product outputs and SDK/test binaries are built in this worktree; none are borrowed from a sibling. Host commands use
DOTNET_CLI_USE_MSBUILD_SERVER=0 MSBUILDDISABLENODEREUSE=1. The shared-host lease is released before publishing. Native builds use the verified session-only wrapper/Users/simon/.copilot/session-state/a7bac364-f7fc-4856-8a8d-8854f5b64b8f/files/ninja-j2, which executes the prepared absolute Ninja with-j2; logs confirm it was used. No global tools/build files were changed for concurrency.dotnet build build-tools/jnienv-gen/jnienv-gen.csproj -c Debug --disable-build-servers -m:1 -v minimal./dotnet-local.sh build build-tools/jnienv-gen/jnienv-gen.csproj -c Debug --disable-build-servers -m:1 -nr:false -v minimalMSBUILD_ARGS='-m:1 -nr:false' make prepare CONFIGURATION=DebugMSBUILD_ARGS='-m:1 -nr:false -p:NinjaPath=/Users/simon/.copilot/session-state/a7bac364-f7fc-4856-8a8d-8854f5b64b8f/files/ninja-j2' make all CONFIGURATION=Debug./dotnet-local.sh build src/Mono.Android/Mono.Android.csproj -c Debug -f net11.0 --disable-build-servers -m:1 -nr:false -v minimal -bl:/Users/simon/.copilot/session-state/a7bac364-f7fc-4856-8a8d-8854f5b64b8f/files/mono-android-debug-retry.binlogTotal Issues: 0./dotnet-local.sh build src/Mono.Android.Runtime/Mono.Android.Runtime.csproj -c Debug -f net11.0 --disable-build-servers -m:1 -nr:false./dotnet-local.sh build build-tools/scripts/Prepare.proj -t:BuildExtraApiLevels -c Debug --disable-build-servers -m:1 -nr:false -v minimal./dotnet-local.sh build build-tools/create-packs/Microsoft.Android.Sdk.proj -t:ConfigureLocalWorkload -c Debug --disable-build-servers -m:1 -nr:false -v minimal./dotnet-local.sh test external/Java.Interop/tests/generator-Tests/generator-Tests.csproj -c Debug --disable-build-servers -m:1 -nr:false -v minimal --logger 'trx;LogFileName=generator-tests.trx' --results-directory /Users/simon/.copilot/session-state/a7bac364-f7fc-4856-8a8d-8854f5b64b8f/files/test-resultsnet10.0)./dotnet-local.sh test external/Java.Interop/tests/generator-Tests/generator-Tests.csproj --no-build -c Debug --disable-build-servers -m:1 -nr:false -v minimal --logger 'trx;LogFileName=generator-tests-final.trx' --results-directory /Users/simon/.copilot/session-state/a7bac364-f7fc-4856-8a8d-8854f5b64b8f/files/test-resultspython3 /Users/simon/.copilot/session-state/a7bac364-f7fc-4856-8a8d-8854f5b64b8f/files/validate-generator.pygit diff --cached --checkInitial
make allfailed with 32 API37 binding errors: binlog replay showed the first compilation lacked the generatedANDROID_*defines. An unchanged explicit managed rebuild imported the generatedMono.Android.projitemsand passed. The nextmake allcompleted the solution but workload setup lacked API37.1 refs. The existingBuildExtraApiLevelsandConfigureLocalWorkloadtargets supplied the missing own refs; the final unchangedmake allpassed. No binding metadata, SDK pins, source files, or API gates were patched to resolve these provisioning/first-build failures. Logs, binlogs, TRX files and baseline/output artifacts are preserved locally.Device tests are not run: the complete generated JNI output is byte-identical, this changes only repository build tooling, and no device lease was requested or used.
Pull Request
title and
description
should follow the
commit-messages.mdworkflow documentation, and in particular should include:No issue is closed; #13092 is related context only.