[typemap] Preserve supported Unicode JCW names - #12607
Conversation
There was a problem hiding this comment.
Copilot review overview
🟢 Approval recommended
Review tier: Lite
Findings: 1
New issues introduced by this change (1)
| Severity | Finding |
|---|---|
src/Microsoft.Android.Sdk.TrimmableTypeMap/JavaNameValidator.cs — 💡 suggestion — When a package/JNI name contains an empty segment (e.g. consecutive separators),… |
What changed in this PR
This PR extends the trimmable typemap/JCW pipeline to preserve supported BMP Unicode Java identifiers end-to-end (typemap keys, JCW source paths/declarations, ACW mappings, manifest component names, DEX, and runtime/JNI activation), while rejecting unsupported Unicode forms early via XA4258.
Changes:
- Tighten Java/JNI name validation to accept a constrained set of stable BMP identifiers and reject combining/format/supplementary code points with XA4258.
- Add generator + integration + device/runtime coverage to prove Unicode identifiers survive generation/compilation/activation across llvm-ir/CoreCLR/NativeAOT matrices.
- Update XA4258 wording and documentation to reflect the broader “invalid or unsupported” identifier class.
| File | Description |
|---|---|
| tests/MSBuildDeviceIntegration/Tests/InstallAndRunTests.cs | Adds device activation test for an Activity with a Unicode Java identifier. |
| tests/Mono.Android-Tests/Mono.Android-Tests/Java.Interop/ConstructorActivationTests.cs | Adds Java-side constructor/peer-registration test for a Unicode-registered type. |
| tests/Microsoft.Android.Sdk.TrimmableTypeMap.Tests/Generator/TypeMapModelBuilderTests.cs | Verifies typemap model preserves Unicode code points in map keys/JNI names. |
| tests/Microsoft.Android.Sdk.TrimmableTypeMap.Tests/Generator/TrimmableTypeMapGeneratorTests.cs | Expands XA4258 validation coverage for unsupported Unicode/identifier shapes and updates expected message text. |
| tests/Microsoft.Android.Sdk.TrimmableTypeMap.Tests/Generator/ManifestGeneratorTests.cs | Ensures manifest component names preserve Unicode code points. |
| tests/Microsoft.Android.Sdk.TrimmableTypeMap.Tests/Generator/JcwJavaSourceGeneratorTests.cs | Extends JNI name validation tests for decomposed/supplementary forms and validates a Unicode-good case. |
| tests/Microsoft.Android.Sdk.TrimmableTypeMap.Tests/Generator/JavaNameValidatorTests.cs | Adds focused unit tests for valid BMP Unicode identifiers and rejected unsupported cases. |
| tests/Microsoft.Android.Sdk.TrimmableTypeMap.Tests/Generator/AcwMapWriterTests.cs | Verifies ACW map writing preserves Unicode identifiers. |
| tests/Microsoft.Android.Sdk.TrimmableTypeMap.IntegrationTests/JavaSourceSemanticParityTests.cs | Adds semantic parity compilation path assertions for Unicode-generated Java artifacts. |
| tests/Microsoft.Android.Sdk.TrimmableTypeMap.IntegrationTests/JavaSourceParityFixture/JavaSourceParityTypes.cs | Adds a fixture Activity registered under a Unicode Java name. |
| src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/TrimmableTypeMapBuildTests.cs | Adds build-time assertions that Unicode names survive intermediate outputs/manifest/acw-map and documents DEX limitations for supplementary code points. |
| src/Xamarin.Android.Build.Tasks/Properties/Resources.resx | Updates XA4258 resource text to “invalid or unsupported”. |
| src/Xamarin.Android.Build.Tasks/Properties/Resources.Designer.cs | Regenerates designer text for the updated XA4258 resource. |
| src/Microsoft.Android.Sdk.TrimmableTypeMap/JavaNameValidator.cs | Implements restricted Unicode identifier support/validation logic for stable toolchain behavior. |
| src/Microsoft.Android.Sdk.TrimmableTypeMap/Generator/JniSignatureHelper.cs | Routes JNI-name validation through the centralized JavaNameValidator checks and updates exception text. |
| src/Microsoft.Android.Sdk.TrimmableTypeMap/Generator/JcwJavaSourceGenerator.cs | Updates documentation for what JNI-name validation now enforces. |
| Documentation/docs-mobile/messages/xa4258.md | Updates XA4258 docs to explain unsupported Unicode categories and toolchain constraints. |
| Documentation/docs-mobile/messages/index.md | Updates XA4258 index entry to match new wording. |
Files not reviewed (1)
- src/Xamarin.Android.Build.Tasks/Properties/Resources.Designer.cs: Generated file
Suppressed comments (1)
src/Microsoft.Android.Sdk.TrimmableTypeMap/JavaNameValidator.cs:98
- 💡 suggestion — Similar to package validation,
TryGetInvalidJniNameSegmentcan report an empty invalidSegment for malformed JNI names (leading/trailing/consecutive/). That produces error text likeidentifier ''. Substituting a placeholder makes XA4258/ArgumentException messages clearer.
var segments = jniName.Split ('/');
for (int i = 0; i < segments.Length - 1; i++) {
if (IsInvalidIdentifier (segments [i], isTypeName: false)) {
invalidSegment = segments [i];
return true;
}
0430b67 to
765d233
Compare
1736423 to
2c0c9b0
Compare
765d233 to
8936f2a
Compare
2c0c9b0 to
3a02aac
Compare
8936f2a to
9d75936
Compare
3a02aac to
dbcfed4
Compare
9d75936 to
7854663
Compare
dbcfed4 to
6918557
Compare
7854663 to
8b98f5f
Compare
Allow BMP letter identifiers to flow unchanged through trimmable JCW generation and diagnose name categories that Android tooling cannot carry consistently. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Classify BMP identifiers from OpenJDK 21 Unicode 15 data, require NFC names, and distinguish portable type starts from Android package and manifest constraints. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Resolve manifest placeholders before validation and alias rewriting, decode DEX and classfile modified UTF-8 exactly, and record the supplementary class-loader limitation. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Resolve manifest packages and placeholders consistently before deduplication, and validate DEX and modified UTF-8 inputs without lossy or unbounded decoding. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
6918557 to
ab9d010
Compare
8b98f5f to
3ea14be
Compare
Keep the llvm-ir case limited to identifiers that javac rejects, while the trimmable cases cover names rejected by the frozen validation policy. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Resolve overlapping typemap generator, diagnostics, and test changes while preserving both Unicode validation and the latest export/custom-view behavior. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
|
/review |
|
✅ Android PR Reviewer completed successfully!
|
There was a problem hiding this comment.
⚠️ Needs Changes
Findings: 1 ❌ error · 0
The Unicode identifier handling is comprehensive and well covered across source generation, typemap, manifest, DEX, and JNI activation paths. One compatibility issue remains: the new manifest validation treats an activity alias’s own name as a Java type name, rejecting aliases Android accepts. The alias target should remain validated, while the alias identifier itself should not use type-name rules.
All 44 CI checks completed successfully.
Generated by Android PR Reviewer for #12607 · gpt56 · 516.8 AIC · ⌖ 9.16 AIC · ⊞ 25.7K
Comment /review to run again
Validate activity-alias targetActivity as a Java type, but leave the alias name to Android's component-name handling. Cover non-type alias names, placeholder expansion, target rewriting and rooting, invalid targets, and manifests without scanned peers. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Summary
Fixes part of #12561.
Validation