[r8-obfuscation] Enable R8 JNI name obfuscation for NativeAOT - #12634
Draft
simonrozsival wants to merge 4 commits into
Draft
[r8-obfuscation] Enable R8 JNI name obfuscation for NativeAOT#12634simonrozsival wants to merge 4 commits into
simonrozsival wants to merge 4 commits into
Conversation
simonrozsival
force-pushed
the
simonrozsival-nativeaot-r8-jni-integration
branch
7 times, most recently
from
September 2, 2026 06:31
a7bff4c to
a8fff0b
Compare
Member
Author
|
/azp run |
|
Azure Pipelines will not run the associated pipelines, because the pull request was updated after the run command was issued. Review the pull request again and issue a new run command. |
Member
Author
|
/azp run |
|
Azure Pipelines will not run the associated pipelines, because the pull request was updated after the run command was issued. Review the pull request again and issue a new run command. |
Member
Author
|
/azp run |
|
Azure Pipelines will not run the associated pipelines, because the pull request was updated after the run command was issued. Review the pull request again and issue a new run command. |
Member
Author
|
/azp run |
|
Azure Pipelines will not run the associated pipelines, because the pull request was updated after the run command was issued. Review the pull request again and issue a new run command. |
simonrozsival
force-pushed
the
simonrozsival-nativeaot-r8-jni-integration
branch
2 times, most recently
from
September 2, 2026 10:21
4c591ed to
80dbc97
Compare
simonrozsival
force-pushed
the
simonrozsival-nativeaot-r8-jni-integration
branch
from
September 2, 2026 11:23
80dbc97 to
2099dc9
Compare
simonrozsival
force-pushed
the
simonrozsival-nativeaot-r8-jni-integration
branch
from
September 2, 2026 12:02
2099dc9 to
07eaa87
Compare
simonrozsival
force-pushed
the
simonrozsival-nativeaot-r8-jni-integration
branch
from
September 2, 2026 13:21
07eaa87 to
7c2485f
Compare
simonrozsival
force-pushed
the
simonrozsival-nativeaot-r8-jni-integration
branch
from
September 2, 2026 15:05
cbb6df2 to
f547135
Compare
simonrozsival
force-pushed
the
simonrozsival-nativeaot-r8-jni-integration
branch
from
September 2, 2026 15:29
f547135 to
ec9422a
Compare
simonrozsival
force-pushed
the
simonrozsival-nativeaot-r8-jni-integration
branch
from
September 2, 2026 17:55
ec9422a to
c544a34
Compare
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
NativeAOT correctly removes an unreferenced managed peer from the final R8 reachability set. Keep the test peer live through MainActivity and assert its exact reachability provenance before checking the final mapping. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
The generated ACW keep file is intentionally excluded from final R8, so NativeAOT correctly removed the unreferenced library peer. Reference it from the app and assert its reachability provenance before validating the public mapping. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
simonrozsival
force-pushed
the
simonrozsival-nativeaot-r8-jni-integration
branch
from
September 2, 2026 21:42
c544a34 to
1912f90
Compare
Member
|
Why is this rewriting necessary? Can't we tell R8 not to rename things we need? There must be an escape hatch for reflection. What we're doing is reflection. Bugs in rewritten assemblies pretty much always land on runtime team's plate to troubleshoot. dotnet/maui#37782 (comment) was the most recent one and that one was extra annoying because people who knew about the rewriting (they edited the rewriter files in the past) were on the thread and did not say there was a rewrite. I'm not a big fan of these approaches. |
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.
Related to #12535
Depends on #12632
Layer 6 of 6 and the top of the replacement stack for draft PR #12575. Extends the shared two-pass R8 JNI name-obfuscation pipeline to NativeAOT, including incremental pre-ILC assembly rewriting, conservative JNI class/member reachability, seed-compatible final keep rules, and prebuilt runtime JNI startup keeps.
Testing:
Xamarin.Android.Build.Tasks.csprojbuilds successfully.Xamarin.Android.Build.Tests.csprojbuilds successfully.TypeMapAssemblyGeneratorTests: 121/121 passed, including owner-specific JNI method-name FieldRVA coverage.NETSDK1147: To build this project, the following workloads must be installed: android; no unrelated workload was installed.