[Build] Fix JNI remapping counts lost on incremental builds#11378
Draft
simonrozsival wants to merge 3 commits into
Draft
[Build] Fix JNI remapping counts lost on incremental builds#11378simonrozsival wants to merge 3 commits into
simonrozsival wants to merge 3 commits into
Conversation
GenerateJniRemappingNativeCode registers JNI remapping counts (type and method replacement counts) as an in-memory MSBuild task object. On incremental builds where the remap target is skipped (outputs up to date) but _GeneratePackageManagerJava re-runs (e.g. due to assembly changes), GenerateNativeApplicationConfigSources finds no registered task object and writes zero counts into environment.ll. This silently disables JNI method remapping at runtime (jniRemappingInUse = false). Fix by persisting the counts to a file (jni_remapping_info.txt) alongside the generated jni_remap.ll sources. GenerateNativeApplicationConfigSources falls back to reading this file when the task object is not available. The info file is also added to both the remap targets' Outputs and the _GeneratePackageManagerJava target's Inputs, ensuring proper incremental build invalidation. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Verifies that building a project with JNI remapping produces a jni_remapping_info.txt file with the correct type and method replacement counts, and that these counts match the values in the generated environment.ll. Without the fix in the previous commit, this file would not be created and the test would fail at the file existence assertion. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…sed fallback The remap targets are very fast (small XML parse + LL file write) and already use CopyIfStreamChanged, so always running them has negligible cost. This ensures the registered task object is always available for GenerateNativeApplicationConfigSources, eliminating the incremental build bug without any new files or fallback logic. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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.
Summary
Fix an incremental build bug where JNI method remapping gets silently disabled.
Problem
GenerateJniRemappingNativeCoderegisters remapping counts as an in-memory MSBuild task object. On incremental builds where the remap target is skipped (itsInputs/Outputsare satisfied) but_GeneratePackageManagerJavare-runs,GenerateNativeApplicationConfigSourcesfinds no registered task object and writes zero counts intoenvironment.ll. This setsjniRemappingInUse = falseat runtime, causingNoSuchMethodErrorfor any remapped methods.Fix
Remove
Inputs/Outputsfrom both_GenerateEmptyAndroidRemapNativeCodeand_GenerateAndroidRemapNativeCodetargets so they always run. The task is very fast (small XML parse + LL file write) and already usesCopyIfStreamChangedto avoid unnecessary downstream rebuilds, so the cost is negligible. This ensures the registered task object is always available.