Skip to content

[typemap] Preserve supported Unicode JCW names - #12607

Open
simonrozsival wants to merge 4 commits into
simonrozsival-constructor-signature-diagnosticsfrom
simonrozsival-unicode-jcw-identifiers
Open

[typemap] Preserve supported Unicode JCW names#12607
simonrozsival wants to merge 4 commits into
simonrozsival-constructor-signature-diagnosticsfrom
simonrozsival-unicode-jcw-identifiers

Conversation

@simonrozsival

Copy link
Copy Markdown
Member

Summary

  • preserve supported BMP Unicode Java identifiers across trimmable JCW source paths, declarations, manifest names, ACW mappings, typemap keys, DEX, and JNI activation
  • reject combining/format characters, supplementary code points, malformed segments, and reserved identifiers early with XA4258 before trimmable outputs are written
  • add semantic javac/classfile, three-runtime host, and three-runtime device activation coverage

Fixes part of #12561.

Validation

  • 887 trimmable typemap unit tests
  • generated Java semantic parity + javac tests
  • 12-case llvm-ir/CoreCLR/NativeAOT host matrix
  • llvm-ir CoreCLR, trimmable CoreCLR, and trimmable NativeAOT device activation matrix
  • legacy JCW identifier and package-name diagnostic tests
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>
Copilot AI lite review requested due to automatic review settings August 31, 2026 20:13

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟢 Approval recommended

Review tier: Lite
Findings: 1 Low severity

New issues introduced by this change (1)
Severity Finding
Low severity 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, TryGetInvalidJniNameSegment can report an empty invalidSegment for malformed JNI names (leading/trailing/consecutive /). That produces error text like identifier ''. 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;
			}
Comment on lines 80 to 84
foreach (var segment in packageName.Split (separator)) {
if (JavaKeywords.Contains (segment)) {
if (IsInvalidIdentifier (segment, isTypeName: false)) {
invalidSegment = segment;
return true;
}
simonrozsival and others added 3 commits August 31, 2026 23:51
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants