Repository navigation
[release/11.0.1xx] [Microsoft.Android.Sdk.TrimmableTypeMap] Honor component JNI names - #13306
Merged
jonathanpeppers merged 1 commit intoOct 29, 2026
Conversation
Backport 097fd4f from #13147 to release/11.0.1xx. Explicit component names must be used after Register and before CRC64 fallback when resolving JNI object descriptors. This prevents generated constructor and exported signatures from referencing nonexistent hashed classes, which caused javac cannot-find-symbol errors. Preserve dollars in generated top-level wrapper identifiers while keeping actual nested Java types dotted in source references and deferred Application/Instrumentation registration. Keep release-specific native-constructor emission and Unicode tests when resolving conflicts. Explicitly select the trimmable typemap in the new build regression because CoreCLR still defaults to the legacy typemap on this branch. Preserve all 48 component-name build cases. Fixes: #13143 Context: #13147 Co-authored-by: Copilot App <[email protected]>
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Valid generated component names such as example.components.Outer$for still trigger XA4258 because validation splits them at $, affecting constructor/export signatures and deferred Application/Instrumentation registration.
1 open issue
What changed in this PR
Backports explicit component JNI-name handling to release/11.0.1xx, aligning trimmable typemap signatures with generated Java wrappers to address #13143.
Changes:
- Resolve component names after
[Register]and before the CRC64 fallback. - Preserve
$in generated top-level wrapper references and deferred registration while retaining dotted references for nested Java types. - Add 48 build regression cases across six component attributes, two runtimes, app/library placement, and simple/dollar-containing names, explicitly selecting the trimmable typemap.
| File | Description |
|---|---|
src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/TrimmableTypeMapBuildTests.cs |
Adds component-name build tests with Java-source and packaged-DEX assertions. |
src/Microsoft.Android.Sdk.TrimmableTypeMap/TrimmableTypeMapGenerator.cs |
Preserves generated wrapper names in deferred registration. |
src/Microsoft.Android.Sdk.TrimmableTypeMap/Scanner/JavaPeerScanner.cs |
Uses explicit component names when resolving JNI descriptors. |
src/Microsoft.Android.Sdk.TrimmableTypeMap/Scanner/JavaPeerInfo.cs |
Clarifies the descriptor’s role in source generation. |
src/Microsoft.Android.Sdk.TrimmableTypeMap/Generator/JniSignatureHelper.cs |
Adds generated-wrapper-aware name conversion. |
src/Microsoft.Android.Sdk.TrimmableTypeMap/Generator/JcwJavaSourceGenerator.cs |
Passes generated wrapper names through Java source formatting while preserving release-branch constructor behavior. |
Review effort: Balanced
Comment on lines
+241
to
+243
| // Generated wrappers are top-level classes, even when their identifiers contain '$'. | ||
| if (generatedPeerNames?.Contains (jniName) == true) { | ||
| return JniNameToJavaBinaryName (jniName); |
jonathanpeppers
approved these changes
Oct 29, 2026
simonrozsival
added a commit
that referenced
this pull request
Nov 4, 2026
Context: #13147 Context: #13306 (comment) An explicit component name such as `example.components.Outer$for` is a valid top-level Java identifier, but constructor and export signatures referencing it fail with XA4258. Application and Instrumentation wrappers with these names also fail deferred-registration validation, even without a signature referencing them. The source generator preserves '$' in generated wrapper names after #13147, but validation still splits every source reference at '$' and rejects the resulting keyword `for`. Pass the generated-peer name set through source-type and JNI descriptor validation so validation uses the same top-level-versus-nested distinction as source generation. Continue checking package segments and the complete generated identifier, and retain nested-identifier validation for external Java types. Add 58 focused regression cases covering generated and external references, invalid identifiers, deferred registration, and default-package throws clauses. Extend the existing application-build matrix with `Outer$for`, retaining its generated-source and packaged-DEX assertions for all six component attributes, both runtimes, and same- and cross-assembly references. Local validation passes: `make prepare`, `make leeroy`, 105 trimmable-typemap task tests, all 72 component-signature application-build cases, and six existing invalid-name diagnostic application-build cases. No device execution is performed. Co-authored-by: Copilot App <[email protected]>
simonrozsival
added a commit
that referenced
this pull request
Nov 5, 2026
) Context: #13147 Context: #13306 (comment) An explicit component name such as `example.components.Outer$for` is a valid top-level Java identifier, but constructor and export signatures referencing it fail with XA4258. Application and Instrumentation wrappers with these names also fail deferred-registration validation, even without a signature referencing them. The source generator preserves `$` in generated wrapper names after #13147, but validation still splits every source reference at `$` and rejects the resulting keyword `for`. Pass the generated-peer name set through source-type and JNI descriptor validation so validation uses the same top-level-versus-nested distinction as source generation. Continue checking package segments and the complete generated identifier, and retain nested-identifier validation for external Java types. Add 58 focused regression cases covering generated and external references, invalid identifiers, deferred registration, and default-package throws clauses. Extend the existing application-build matrix with `Outer$for`, retaining its generated-source and packaged-DEX assertions for all six component attributes, both runtimes, and same- and cross-assembly references.
3 tasks done
jonathanpeppers
pushed a commit
that referenced
this pull request
Nov 10, 2026
…a identifiers (#13405) Context: #13147 Context: #13306 (comment) An explicit component name such as `example.components.Outer$for` is a valid top-level Java identifier, but constructor and export signatures referencing it fail with XA4258. Application and Instrumentation wrappers with these names also fail deferred-registration validation, even without a signature referencing them. The source generator preserves `$` in generated wrapper names after #13147, but validation still splits every source reference at `$` and rejects the resulting keyword `for`. Pass the generated-peer name set through source-type and JNI descriptor validation so validation uses the same top-level-versus-nested distinction as source generation. Continue checking package segments and the complete generated identifier, and retain nested-identifier validation for external Java types. Add 58 focused regression cases covering generated and external references, invalid identifiers, deferred registration, and default-package throws clauses. Extend the existing application-build matrix with `Outer$for`, retaining its generated-source and packaged-DEX assertions for all six component attributes, both runtimes, and same- and cross-assembly references. (cherry picked from commit 536fa66) ### [TrimmableTypeMap] Adapt backport tests to release xUnit layout Keep all 58 upstream regression cases in the release branch typemap test assembly, reuse its logger and internal access, and update legacy deferred-registration expectations for generated top-level identifiers. Co-authored-by: Copilot App <[email protected]>
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.

Manual backport of #13147 (097fd4f) to
release/11.0.1xx.Fixes: #13143
An explicit component name, such as
[Service(Name = "example.media.ControlsService")], names its Java wrapper correctly but previously resolved to a CRC64 name in constructor and exported signatures. This makes generated Java reference a nonexistent class and fail withcannot find symbol. Resolve explicit component names after[Register]and before the CRC64 fallback. Preserve$in generated top-level wrapper identifiers and deferred Application/Instrumentation registration, while retaining dotted source references for actual nested Java types such asBitmap.Config.Release adaptations
JcwJavaSourceGenerator.csconflict by preserving this branch's native-constructor declaration behavior, while passing the generated-peer name set through signature formatting. Add the explicitSystem.Linqimport required by this branch.TrimmableTypeMapBuildTests.csconflict by keeping the release branch's existing Unicode tests and inserting only the component-name regressions, without bringing in unrelated main-branch tests.AndroidTypeMapImplementation=trimmablein the new application fixture because CoreCLR still defaults to the legacy typemap on this branch. Product defaults are unchanged. Retain all 48 original build cases and their generated-source and packaged-DEX assertions; no synthetic PEReader tests are added.Validation on this release backport
Commands below omit only TRX-output options and local log redirection.
make prepare— passed.make leeroy— passed, including the solution build, extra API levels, and local workload configuration../dotnet-local.sh test tests/Microsoft.Android.Sdk.TrimmableTypeMap.Tests/bin/Debug/net11.0/Microsoft.Android.Sdk.TrimmableTypeMap.Tests.dll -v minimal— passed: 1,016 tests, 0 failures, 0 skips../dotnet-local.sh test bin/TestDebug/net11.0/Microsoft.Android.Build.Tasks.Tests.dll -v minimal --filter 'FullyQualifiedName~TypeMap'— passed: 18 tests, 0 failures, 0 skips../dotnet-local.sh test src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/Xamarin.Android.Build.Tests.csproj -v minimal --filter 'FullyQualifiedName~Build_ComponentNameIsUsedInSignatures'— passed: all 48 cases, 0 failures, 0 skips. The TRX contains exactly the expected 48 unique combinations, including 8 passing cases for each component attribute../dotnet-local.sh test bin/TestDebug/net10.0/Xamarin.Android.Build.Tests.dll -v minimal --filter 'FullyQualifiedName~Build_JavaTypeOnlyIdentifierStarts|FullyQualifiedName~Build_SupplementaryJavaIdentifier|FullyQualifiedName~Build_InvalidOrUnsupportedUnicodeIdentifiers'— passed: 9 existing release-specific cases, 0 failures, 0 skips.The initial matrix invocation (
./dotnet-local.sh test bin/TestDebug/net10.0/Xamarin.Android.Build.Tests.dll -v minimal --filter 'FullyQualifiedName~Build_ComponentNameIsUsedInSignatures') was stopped after revealing that CoreCLR selected the release branch's legacy typemap. The final 48-case run above passed after explicitly selectingtrimmablein the fixture.These are local host-side tests and real application builds against the freshly built release-branch SDK. No device execution was performed.
Pull Request
title and
description
should follow the
commit-messages.mdworkflow documentation, and in particular should include: