Skip to content
Closed
Show file tree
Hide file tree
Changes from 72 commits
Commits
Show all changes
169 commits
Select commit Hold shift + click to select a range
6bae3ac
[TrimmableTypeMap] Remove post-trim generation pass
simonrozsival Jun 8, 2026
579ea8a
Bump external/Java.Interop from `b881d21` to `d7dbad5`
dependabot[bot] Jun 10, 2026
f79c0cc
Implement Android JavaMarshal value manager split
simonrozsival Jun 9, 2026
676dca4
Use pure trimmable typemap value manager
simonrozsival Jun 9, 2026
01dfd04
Use pure trimmable typemap type manager
simonrozsival Jun 9, 2026
b77c841
Propagate trimmable typemap DAM annotations
simonrozsival Jun 9, 2026
0554d57
Prefer Requires annotations for reflection managers
simonrozsival Jun 9, 2026
7d81397
Remove manager suppression attributes
simonrozsival Jun 9, 2026
1fe2ef5
Remove invoker lookup suppression attributes
simonrozsival Jun 9, 2026
7228982
Use feature guards for runtime manager selection
simonrozsival Jun 9, 2026
326f0fd
Inline CoreCLR JavaMarshal peer delegation
simonrozsival Jun 9, 2026
6a8ec68
Throw unreachable from trimmable native registration
simonrozsival Jun 9, 2026
7d3d1e3
Remove SimpleValueManager
simonrozsival Jun 10, 2026
725d433
Simplify changes to the ManagedTypeManager
simonrozsival Jun 10, 2026
caaea85
Remove the option to use ManagedTypeManager
simonrozsival Jun 10, 2026
b489d1f
Cleanup value managers
simonrozsival Jun 10, 2026
f1ce2a2
Refine trimmable typemap runtime paths
simonrozsival Jun 10, 2026
0a1072a
Reuse Java.Interop value marshalers in trimmable runtime
simonrozsival Jun 11, 2026
78cb7d6
Support JavaObjectArray in trimmable value marshaling
simonrozsival Jun 11, 2026
169bc8f
Generalize trimmable primitive value marshaling
simonrozsival Jun 11, 2026
869f183
Apply trimmable test exclusions to new runner
simonrozsival Jun 11, 2026
93ddc73
Remove LayoutInflater test contamination
simonrozsival Jun 11, 2026
933a38d
Address trimmable review cleanup
simonrozsival Jun 11, 2026
65a2cf5
Flow excluded NUnit categories from MSBuild
simonrozsival Jun 11, 2026
6b4aedb
Extract trimmable primitive marshaler helpers
simonrozsival Jun 11, 2026
80997b8
Address trimmable review feedback
simonrozsival Jun 11, 2026
6071fd0
Support trimmable custom value marshalers
simonrozsival Jun 11, 2026
d45a519
Unwrap trimmable proxy throwables
simonrozsival Jun 11, 2026
4282882
Support trimmable type manager lookups
simonrozsival Jun 11, 2026
152845b
Use trimmable CrossReferenceBridge fixture
simonrozsival Jun 11, 2026
8105789
Use trimmable method binding fixtures
simonrozsival Jun 11, 2026
7a7ca23
Support trimmable marshaler expressions
simonrozsival Jun 11, 2026
fece7d7
Remove generated value marshaler registry
simonrozsival Jun 11, 2026
b134621
Address trimmable test review feedback
simonrozsival Jun 11, 2026
6e1a69a
Fix trimmable typemap CI failures
simonrozsival Jun 12, 2026
8447f63
Simplify generated proxy trim suppression
simonrozsival Jun 12, 2026
18f39bc
Address trimmable runtime review feedback
simonrozsival Jun 12, 2026
4e40404
Clean stale trimmable typemap Java sources
simonrozsival Jun 12, 2026
7496a32
Simplify trimmable marshaler integration
simonrozsival Jun 12, 2026
f2c59bd
Re-enable trimmable GC bridge coverage
simonrozsival Jun 12, 2026
298f262
Re-enable trimmable replacement method lookup test
simonrozsival Jun 12, 2026
7ab9659
Re-enable trimmable method binding coverage
simonrozsival Jun 12, 2026
12946a7
Remove JavaProxyThrowable Exception wrapper
simonrozsival Jun 12, 2026
1cae90b
Remove ManagedPeer workarounds from trimmable PR
simonrozsival Jun 12, 2026
a53fb70
Document built-in type signature mapping choice
simonrozsival Jun 12, 2026
25a0526
Split Java marshal value manager types
simonrozsival Jun 12, 2026
a5b39d1
Simplify trimmable object array marshaling
simonrozsival Jun 12, 2026
5dff3a8
Return object references from trimmable marshaling
simonrozsival Jun 12, 2026
f928f99
Clarify trimmable local reference ownership
simonrozsival Jun 12, 2026
66c29f3
Merge origin/main into dev/simonrozsival/java-interop-1441-android
simonrozsival Jun 17, 2026
f7b0fec
Fix AndroidRuntime merge follow-ups
simonrozsival Jun 17, 2026
39583fa
Update tests + cleanup
simonrozsival Jun 17, 2026
db14c80
Remove unnecessary code
simonrozsival Jun 17, 2026
4bbc8fa
Merge remote-tracking branch 'origin/main' into android-remove-second…
Copilot Jun 17, 2026
a23c1f2
Merge latest main, resolve conflicts (keep post-trim pass removal)
Copilot Jun 17, 2026
7412129
Fix more stuff
simonrozsival Jun 17, 2026
6a0b25f
Merge remote-tracking branch 'origin/main' into dev/simonrozsival/jav…
simonrozsival Jun 17, 2026
dcdfbae
Use Java.Interop from main
simonrozsival Jun 17, 2026
89e133e
Merge PR #11604 post-trim typemap cleanup
simonrozsival Jun 18, 2026
d95a356
Remove unnecessary MakeArrayType
simonrozsival Jun 18, 2026
2ba985f
Annotate JNINativeWrapper.CreateDelegate method
simonrozsival Jun 18, 2026
8ec4aee
Drop assertions which expect AOT and trimming warnings
simonrozsival Jun 18, 2026
200b6a4
Update apkdesc files
simonrozsival Jun 18, 2026
0aa8bad
Avoid more MakeArrayType
simonrozsival Jun 18, 2026
ebc9b9e
Suppress expected runtime manager trim warnings
simonrozsival Jun 18, 2026
46bb3ff
We removed AOT warning, do not assert that there will be a warning
simonrozsival Jun 18, 2026
1392c44
Address trimmable typemap review feedback
simonrozsival Jun 18, 2026
d4dd398
[TrimmableTypeMap] Support built-in reference arrays
simonrozsival Jun 18, 2026
b76c959
[TrimmableTypeMap] Prefer dynamic array creation on CoreCLR
simonrozsival Jun 19, 2026
94eeb39
Merge branch 'main' of github.com:dotnet/android into dev/simonrozsiv…
simonrozsival Jun 22, 2026
9b41a8f
[typemap] Fix trimmable typemap CI failures
simonrozsival Jun 22, 2026
2a12f82
[typemap] Include runtime version in root fingerprint
simonrozsival Jun 22, 2026
48a1e77
[typemap] Extract deterministic hash builder
simonrozsival Jun 22, 2026
46bf686
[typemap] Restore span-based MVID hashing
simonrozsival Jun 22, 2026
a9336e4
[typemap] Keep NativeAOT managed typemap default
simonrozsival Jun 22, 2026
c2522ea
[typemap] Restore managed NativeAOT runtime managers
simonrozsival Jun 22, 2026
1d45090
Revert "[typemap] Restore managed NativeAOT runtime managers"
simonrozsival Jun 22, 2026
a0d0fb7
Revert "[typemap] Keep NativeAOT managed typemap default"
simonrozsival Jun 22, 2026
f54ef34
[deps] Update android-tools for task hashing compatibility
simonrozsival Jun 22, 2026
b50a4c8
[runtime] Proxy opaque objects in trimmable value manager
simonrozsival Jun 22, 2026
0152cc1
Merge remote-tracking branch 'origin/main' into dev/simonrozsival/jav…
simonrozsival Jun 22, 2026
ef8cbb3
[deps] Update android-tools task hashing fix
simonrozsival Jun 22, 2026
78efb4f
[runtime] Override Java proxy object methods
simonrozsival Jun 23, 2026
705fc27
[runtime] Override Java proxy object methods
simonrozsival Jun 23, 2026
9d5110b
Remove DAM where they're causing more harm than good
simonrozsival Jun 23, 2026
c6bafae
Merge remote-tracking branch 'origin/main' into dev/simonrozsival/jav…
simonrozsival Jun 23, 2026
97eb32e
[runtime] Disable ManagedPeer for trimmable apps
simonrozsival Jun 23, 2026
158fa0c
Merge remote-tracking branch 'origin/dev/simonrozsival/java-interop-1…
simonrozsival Jun 23, 2026
828dbe9
Improve array handling
simonrozsival Jun 23, 2026
8a8cbde
Clean-up trimmable value manager
simonrozsival Jun 23, 2026
33de611
Add support for nullable primitive types without unwrapping Nullable
simonrozsival Jun 23, 2026
2d5fef1
Fix incrementality
simonrozsival Jun 24, 2026
6645710
Temporary bump to external/Java.Interop
simonrozsival Jun 24, 2026
840d342
Revert "Temporary bump to external/Java.Interop"
simonrozsival Jun 24, 2026
18f3b9d
Merge branch 'main' of github.com:dotnet/android into dev/simonrozsiv…
simonrozsival Jun 24, 2026
8fe902d
Temporary bump to external/Java.Interop
simonrozsival Jun 24, 2026
f8964c7
Temporary bump to external/Java.Interop
simonrozsival Jun 24, 2026
9d3217b
Reuse array handling code between the type and value managers
simonrozsival Jun 24, 2026
4f23922
Redo array type mapping for Native AOT
simonrozsival Jun 24, 2026
dcf1c96
Bump Java.Interop to 8d54473
simonrozsival Jun 24, 2026
9bd6825
Preserve trimmable array proxies for wrapper types
simonrozsival Jun 24, 2026
8d5969d
Fix array proxy association duplication
simonrozsival Jun 24, 2026
a05be93
Scope array proxy associations to rank maps
simonrozsival Jun 24, 2026
dd3155c
Use reverse typemap entries for peer proxy lookup
simonrozsival Jun 24, 2026
fc65df3
Use array types as array proxy trim targets
simonrozsival Jun 24, 2026
5c20adc
Revert "Use array types as array proxy trim targets"
simonrozsival Jun 24, 2026
ea922d4
Fix collections of generic types
simonrozsival Jun 24, 2026
87cea50
Fix trimmable collection wrapper reuse
simonrozsival Jun 25, 2026
e966fd5
Skip unresolvable trimmable typemap peers
simonrozsival Jun 25, 2026
54a0df4
Update package versions to avoid test failures
simonrozsival Jun 25, 2026
f1a1491
Simplify SmokeTestBuildWithSpecialCharacters test
simonrozsival Jun 25, 2026
62652db
Refactor ModelBuilder and SingleUniverseTypeMap to remove ManagedType…
simonrozsival Jun 25, 2026
7c75e61
Fix inherited generic base typemap refs
simonrozsival Jun 25, 2026
6d5ca25
Fix package version
simonrozsival Jun 25, 2026
4c0d418
Restore typemap proxy associations
simonrozsival Jun 25, 2026
003e118
Fix msbuild
simonrozsival Jun 25, 2026
48288f0
Update msbuild targets
simonrozsival Jun 25, 2026
45a7e62
Fix typo
simonrozsival Jun 25, 2026
68c438b
Avoid null dereference
simonrozsival Jun 25, 2026
807df5f
Fix trimmable value manager create semantics
simonrozsival Jun 25, 2026
c82b464
Fix trimmable manifest generation parity
simonrozsival Jun 25, 2026
ef8085f
Fix NativeAOT trimmable build integration
simonrozsival Jun 25, 2026
d13fde4
Revert accidental android tools submodule bump
simonrozsival Jun 25, 2026
a7ea92e
Preserve NativeAOT proguard keep rules
simonrozsival Jun 25, 2026
21e297b
Write NativeAOT keep rules to primary proguard config
simonrozsival Jun 25, 2026
d86671f
Stop R8 from generating NativeAOT app keep config
simonrozsival Jun 25, 2026
5c8463c
Disable NativeAOT DGML proguard filtering
simonrozsival Jun 25, 2026
24186b8
Accept NativeAOT R8 mapping output in DotNetBuild test
simonrozsival Jun 25, 2026
7ef0463
[typemap] Restore NativeAOT managed typemap default
simonrozsival Jun 25, 2026
71adeb2
Switch back to ManagedTypeManager as the default for NativeAOT
simonrozsival Jun 26, 2026
425542a
Default NativeAOT to trimmable typemaps
simonrozsival Jun 26, 2026
05d1451
[Tests] Skip NativeAOT tests that inspect illink's `linked/` output
simonrozsival Jun 26, 2026
fbcd702
[Tests] Fully skip BuildReleaseArm64 on NativeAOT
simonrozsival Jun 26, 2026
fe41750
[TrimmableTypeMap] Fix manifest content gaps on NativeAOT (B2)
simonrozsival Jun 26, 2026
4a1f51e
[TrimmableTypeMap] Complete activity manifest attribute mappings (B2)
simonrozsival Jun 26, 2026
7d44fd4
[TrimmableTypeMap] Produce android/AndroidManifest.xml for the legacy…
simonrozsival Jun 26, 2026
9bf113b
[TrimmableTypeMap] Resolve parentActivityName and fix persistableMode…
simonrozsival Jun 26, 2026
107ece2
Fix uses-sdk without specifying min version
simonrozsival Jun 26, 2026
5dd97b0
[build] Guard staging-dir globs when extraction is skipped
simonrozsival Jun 27, 2026
6a1555a
[Tests] Adjust NativeAOT cases for unsupported/different-trimmer beha…
simonrozsival Jun 27, 2026
49f3378
[TrimmableTypeMap] Honor AndroidApplicationJavaClass for the JCW base…
simonrozsival Jun 27, 2026
44c9a98
[Tests] Expect trimmable scrc64 JCW package names on NativeAOT (J2)
simonrozsival Jun 27, 2026
b7977de
[TrimmableTypeMap] Sort component manifest attributes alphabetically
simonrozsival Jun 27, 2026
494d0e6
[TrimmableTypeMap] Warn XA1010 for invalid manifest placeholders
simonrozsival Jun 27, 2026
c892216
[TrimmableTypeMap] Resolve placeholder package names in the manifest
simonrozsival Jun 27, 2026
ae860a4
[TrimmableTypeMap] Normalize manifest placeholder values like the leg…
simonrozsival Jun 27, 2026
570afc8
[TrimmableTypeMap] Don't touch typemap assemblies so incremental buil…
simonrozsival Jun 27, 2026
79a144c
[TrimmableTypeMap] Direct-dispatch interface-implementation proxy met…
simonrozsival Jun 27, 2026
552e290
[TrimmableTypeMap] Use non-generic JavaPeerProxy base for interface p…
simonrozsival Jun 27, 2026
3ea9d59
[TrimmableTypeMap] Run FixLegacyResourceDesigner before ILC on NativeAOT
simonrozsival Jun 27, 2026
40cf921
[Tests] Fix GenerateTrimmableTypeMapTests for string[] ManifestPlaceh…
simonrozsival Jun 27, 2026
97ba631
Remove more suppressions
simonrozsival Jun 27, 2026
99511eb
Fix null ref warning
simonrozsival Jun 27, 2026
cb09b6e
[TrimmableTypeMap] Merge library manifests for the legacy manifest me…
simonrozsival Jun 27, 2026
7611484
[Tests] ExportedErrorMessage: assert AMM0000 code, not exact line, on…
simonrozsival Jun 27, 2026
9a0d987
[TrimmableTypeMap] Don't direct-dispatch interface-implementation met…
simonrozsival Jun 27, 2026
b5d106f
Merge branch 'main' into dev/simonrozsival/java-interop-1441-android
simonrozsival Jun 27, 2026
5293815
[Tests] Ignore flaky BuildReleaseArm64
simonrozsival Jun 27, 2026
efae987
[TrimmableTypeMap] Fix DesignTimeBuildSignAndroidPackage on NativeAOT
simonrozsival Jun 27, 2026
9e74ff7
[TrimmableTypeMap] Keep user AndroidJavaSource Java under R8 shrinking
simonrozsival Jun 27, 2026
31bfd46
[Mono.Android] Fix IL2077 build break in JavaConvert.ArrayElementConv…
simonrozsival Jun 27, 2026
a6cd268
[TrimmableTypeMap] Don't stage shrunk assemblies into the shared runt…
simonrozsival Jun 28, 2026
140d9a8
[TrimmableTypeMap] Gate IDE-sign typemap target on _OuterIntermediate…
simonrozsival Jun 28, 2026
d6bf397
Suppress trimming warnings in CoreCLR branch
simonrozsival Jun 29, 2026
f36b5b7
Merge branch 'main' into dev/simonrozsival/java-interop-1441-android
simonrozsival Jun 29, 2026
f415d7e
Merge branch 'dev/simonrozsival/java-interop-1441-android' of github.…
simonrozsival Jun 29, 2026
9271b3c
Undo unnecessary change
simonrozsival Jun 29, 2026
98f6ad8
[submodule] Align xamarin-android-tools with main (bcce35f5)
simonrozsival Jun 29, 2026
0debcd7
Fix bad merge
simonrozsival Jun 29, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions Documentation/docs-mobile/messages/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -220,8 +220,6 @@ Either change the value in the AndroidManifest.xml to match the $(SupportedOSPla
+ [XA4250](xa4250.md): Manifest-referenced type '{type}' was not found in any scanned assembly. It may be a framework type.
+ [XA4252](xa4252.md): Insecure HTTP Maven repository URL '{url}' is not allowed. Use an HTTPS URL, or set AllowInsecureHttp="true" metadata on the item to override this check.
+ [XA4253](xa4253.md): Generated Java callable wrapper code changed: '{path}'
+ [XA4254](xa4254.md): Trimmable type map Java source input directory '{input}' and output directory '{output}' must be different.
+ [XA4255](xa4255.md): Generated trimmable type map Java source '{path}' was not found.
+ XA4300: Native library '{library}' will not be bundled because it has an unsupported ABI.
+ [XA4301](xa4301.md): Apk already contains the item `xxx`.
+ [XA4302](xa4302.md): Unhandled exception merging \`AndroidManifest.xml\`: {ex}
Expand Down
25 changes: 0 additions & 25 deletions Documentation/docs-mobile/messages/xa4254.md

This file was deleted.

27 changes: 0 additions & 27 deletions Documentation/docs-mobile/messages/xa4255.md

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ static NativeAotRuntimeOptions CreateJreVM (NativeAotRuntimeOptions builder)
builder.TypeManager ??= CreateDefaultTypeManager ();
#endif // NET

builder.ValueManager ??= new JavaMarshalValueManager ();
builder.ValueManager ??= Android.Runtime.JNIEnvInit.CreateValueManager ();
builder.ObjectReferenceManager ??= new Android.Runtime.AndroidObjectReferenceManager ();

if (builder.InvocationPointer != IntPtr.Zero || builder.EnvironmentPointer != IntPtr.Zero)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
<type fullname="Android.Runtime.RaiseThrowableEventArgs" />
<type fullname="Android.Runtime.RegisterAttribute" />
<type fullname="Android.Runtime.TypeManager" />
<type fullname="Microsoft.Android.Runtime.ManagedTypeMapping" preserve="all" />
<!--
<type fullname="Android.Runtime.XmlResourceParserReader" />
<type fullname="Android.Runtime.XmlPullParserReader" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.Collections.Generic;
using System.Security.Cryptography;
using System.Text;

Expand Down Expand Up @@ -29,25 +30,81 @@ public static Guid DeterministicMvid (string moduleName, ReadOnlySpan<byte> cont
public static byte [] ComputeContentFingerprint (TypeMapAssemblyData data)
{
using var sha = SHA256.Create ();
using var stream = new System.IO.MemoryStream ();
using var writer = new System.IO.BinaryWriter (stream, Encoding.UTF8);
foreach (var entry in data.Entries) {
writer.Write (entry.JniName);
writer.Write (entry.ProxyTypeReference);
writer.Write (entry.TargetTypeReference ?? "");
AddString (sha, entry.JniName);
AddString (sha, entry.ProxyTypeReference);
AddString (sha, entry.TargetTypeReference ?? "");
}
foreach (var proxy in data.ProxyTypes) {
writer.Write (proxy.TypeName);
writer.Write (proxy.TargetType.ManagedTypeName);
writer.Write (proxy.TargetType.AssemblyName);
writer.Write ((byte)(proxy.ActivationCtor?.Style ?? 0));
writer.Write ((byte)(proxy.InvokerActivationCtorStyle ?? 0));
AddString (sha, proxy.TypeName);
AddString (sha, proxy.TargetType.ManagedTypeName);
AddString (sha, proxy.TargetType.AssemblyName);
AddByte (sha, (byte)(proxy.ActivationCtor?.Style ?? 0));
AddByte (sha, (byte)(proxy.InvokerActivationCtorStyle ?? 0));
}
foreach (var assoc in data.Associations) {
writer.Write (assoc.SourceTypeReference);
writer.Write (assoc.AliasProxyTypeReference);
AddString (sha, assoc.SourceTypeReference);
AddString (sha, assoc.AliasProxyTypeReference);
}
writer.Flush ();
return sha.ComputeHash (stream.ToArray ());
return FinishHash (sha);
}

public static byte [] ComputeRootContentFingerprint (Version systemRuntimeVersion, IReadOnlyList<string> perAssemblyTypeMapNames, bool useSharedTypemapUniverse, int maxArrayRank)
{
using var sha = SHA256.Create ();
AddVersion (sha, systemRuntimeVersion);
AddByte (sha, useSharedTypemapUniverse ? (byte) 1 : (byte) 0);
AddInt32 (sha, maxArrayRank);
foreach (var name in perAssemblyTypeMapNames) {
AddString (sha, name);
}
return FinishHash (sha);
}

static void AddString (HashAlgorithm hash, string value)
{
var bytes = Encoding.UTF8.GetBytes (value);
AddInt32 (hash, bytes.Length);
AddBytes (hash, bytes);
}

static void AddVersion (HashAlgorithm hash, Version version)
{
AddInt32 (hash, version.Major);
AddInt32 (hash, version.Minor);
AddInt32 (hash, version.Build);
AddInt32 (hash, version.Revision);
}

static void AddInt32 (HashAlgorithm hash, int value)
{
byte [] bytes = [
(byte) value,
(byte) (value >> 8),
(byte) (value >> 16),
(byte) (value >> 24),
];
AddBytes (hash, bytes);
}

static void AddByte (HashAlgorithm hash, byte value)
{
AddBytes (hash, [value]);
}

static void AddBytes (HashAlgorithm hash, byte [] bytes)
{
if (bytes.Length != 0) {
hash.TransformBlock (bytes, 0, bytes.Length, null, 0);
}
}

static byte [] FinishHash (HashAlgorithm hash)
{
hash.TransformFinalBlock ([], 0, 0);
if (hash.Hash is not null) {
return hash.Hash;
}
throw new InvalidOperationException ("SHA256 did not produce a hash.");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System.Reflection.Metadata;
using System.Reflection.Metadata.Ecma335;
using System.Reflection.PortableExecutable;
using System.Security.Cryptography;

namespace Microsoft.Android.Sdk.TrimmableTypeMap;

Expand Down Expand Up @@ -106,12 +107,31 @@ public void WritePE (Stream stream)
new PEHeaderBuilder (imageCharacteristics: Characteristics.Dll),
new MetadataRootBuilder (Metadata),
ILBuilder,
mappedFieldData: _mappedFieldData.Count > 0 ? _mappedFieldData : null);
mappedFieldData: _mappedFieldData.Count > 0 ? _mappedFieldData : null,
deterministicIdProvider: CreateDeterministicContentId);
var peBlob = new BlobBuilder ();
peBuilder.Serialize (peBlob);
peBlob.WriteContentTo (stream);
}

static BlobContentId CreateDeterministicContentId (IEnumerable<Blob> blobs)
{
using var sha = SHA256.Create ();
foreach (var blob in blobs) {
var bytes = blob.GetBytes ();
if (bytes.Array is null) {
continue;
}
sha.TransformBlock (bytes.Array, bytes.Offset, bytes.Count, null, 0);
}
sha.TransformFinalBlock ([], 0, 0);
var hash = sha.Hash;
if (hash is null) {
throw new InvalidOperationException ("SHA256 did not produce a hash.");
}
return BlobContentId.FromHash (hash);
}

/// <summary>
/// Adds (or retrieves from cache) an assembly reference.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public void Generate (IReadOnlyList<string> perAssemblyTypeMapNames, bool useSha
moduleName ??= assemblyName + ".dll";

var pe = new PEAssemblyBuilder (_systemRuntimeVersion);
pe.EmitPreamble (assemblyName, moduleName);
pe.EmitPreamble (assemblyName, moduleName, MetadataHelper.ComputeRootContentFingerprint (_systemRuntimeVersion, perAssemblyTypeMapNames, useSharedTypemapUniverse, maxArrayRank));

EntityHandle anchorTypeHandle;
if (useSharedTypemapUniverse) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -210,13 +210,16 @@ void ScanAssembly (AssemblyIndex index, Dictionary<(string ManagedName, string A

var fullName = MetadataTypeNameResolver.GetFullName (typeDef, index.Reader);

// Temporarily allow [JniAddNativeMethodRegistrationAttribute] while we investigate
// which scenarios fail later in the trimmable typemap pipeline.
// if (index.MayUseJniAddNativeMethodRegistrationAttribute &&
// !IsBuiltInJniAddNativeMethodRegistrationType (fullName, index) &&
// HasJniAddNativeMethodRegistrationAttribute (typeDef, index)) {
// logger?.LogJniAddNativeMethodRegistrationAttributeError (fullName);
// }
// Framework/runtime assemblies contain internal [JniAddNativeMethodRegistration]
// users such as Java.Interop.JavaProxyObject and Java.Interop.ManagedPeer.
// The diagnostic is for user assemblies because the trimmable runtime either
// has generated replacements for framework registration or intentionally
// disables unsupported runtime paths.
if (!frameworkAssemblyNames.Contains (index.AssemblyName) &&
index.MayUseJniAddNativeMethodRegistrationAttribute &&
HasJniAddNativeMethodRegistrationAttribute (typeDef, index)) {
logger?.LogJniAddNativeMethodRegistrationAttributeError (fullName);
}

// Determine the JNI name and whether this is a known Java peer.
// Priority:
Expand Down Expand Up @@ -413,12 +416,6 @@ static bool HasJniAddNativeMethodRegistrationAttribute (TypeDefinition typeDef,
return false;
}

static bool IsBuiltInJniAddNativeMethodRegistrationType (string fullName, AssemblyIndex index)
{
return string.Equals (index.AssemblyName, "Java.Interop", StringComparison.Ordinal) &&
string.Equals (fullName, "Java.Interop.JavaProxyObject", StringComparison.Ordinal);
}

/// <summary>
/// For each virtual override method on <paramref name="typeDef"/> that wasn't already
/// collected (no direct [Register]), walks up the base type hierarchy to find a
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@ public TrimmableTypeMapResult Execute (
ManifestConfig? manifestConfig = null,
XDocument? manifestTemplate = null,
string? packageNamingPolicy = null,
int maxArrayRank = 0,
bool generateTypeMapAssemblies = true)
int maxArrayRank = 0)
{
_ = assemblies ?? throw new ArgumentNullException (nameof (assemblies));
_ = systemRuntimeVersion ?? throw new ArgumentNullException (nameof (systemRuntimeVersion));
Expand All @@ -55,9 +54,7 @@ public TrimmableTypeMapResult Execute (
PropagateDeferredRegistrationToBaseClasses (allPeers);
PropagateCannotRegisterToDescendants (allPeers);

var generatedAssemblies = generateTypeMapAssemblies
? GenerateTypeMapAssemblies (allPeers, systemRuntimeVersion, useSharedTypemapUniverse, maxArrayRank)
: [];
var generatedAssemblies = GenerateTypeMapAssemblies (allPeers, systemRuntimeVersion, useSharedTypemapUniverse, maxArrayRank);
var jcwPeers = allPeers.Where (ShouldGenerateJcw).ToList ();
logger.LogGeneratingJcwFilesInfo (jcwPeers.Count, allPeers.Count);
var generatedJavaSources = GenerateJcwJavaSources (jcwPeers);
Expand Down
32 changes: 16 additions & 16 deletions src/Mono.Android/Android.Runtime/AndroidRuntime.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ public override string GetCurrentManagedThreadStackTrace (int skipFrames, bool f
if (!reference.IsValid)
return null;
var peeked = JniEnvironment.Runtime.ValueManager.PeekPeer (reference);
if (peeked is JavaProxyThrowable proxyThrowable) {
JniObjectReference.Dispose (ref reference, options);
return proxyThrowable.InnerException;
}
var peekedExc = peeked as Exception;
if (peekedExc == null) {
var throwable = Java.Lang.Object.GetObject<Java.Lang.Throwable> (reference.Handle, JniHandleOwnership.DoNotTransfer);
Expand Down Expand Up @@ -310,14 +314,14 @@ public override void DeleteWeakGlobalReference (ref JniObjectReference value)
}
}

[UnconditionalSuppressMessage ("Trimming", "IL2026", Justification = "Temporary suppression for Java.Interop reflection manager base.")]
[RequiresDynamicCode ("This type manager is reflection-backed and is not compatible with Native AOT.")]
[RequiresUnreferencedCode ("This type manager is reflection-backed and is not trimming-compatible.")]
class AndroidTypeManager : JniRuntime.ReflectionJniTypeManager {
bool jniAddNativeMethodRegistrationAttributePresent;

const DynamicallyAccessedMemberTypes Constructors = DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.NonPublicConstructors;
const DynamicallyAccessedMemberTypes Methods = DynamicallyAccessedMemberTypes.PublicMethods | DynamicallyAccessedMemberTypes.NonPublicMethods;
const DynamicallyAccessedMemberTypes MethodsAndPrivateNested = Methods | DynamicallyAccessedMemberTypes.NonPublicNestedTypes;
const DynamicallyAccessedMemberTypes MethodsConstructors = MethodsAndPrivateNested | Constructors;

public AndroidTypeManager (bool jniAddNativeMethodRegistrationAttributePresent)
{
Expand All @@ -334,8 +338,7 @@ protected override IEnumerable<Type> GetTypesForSimpleReference (string jniSimpl
yield return t;
}

[UnconditionalSuppressMessage ("Trimming", "IL2073", Justification = "Temporary suppression until legacy typemap entries carry DAM annotations.")]
[return: DynamicallyAccessedMembers (MethodsConstructors)]
[return: DynamicallyAccessedMembers (Methods | Constructors | DynamicallyAccessedMemberTypes.NonPublicNestedTypes)]
protected override Type? GetTypeForSimpleReference (string jniSimpleReference)
{
var type = base.GetTypeForSimpleReference (jniSimpleReference);
Expand All @@ -352,7 +355,10 @@ protected override IEnumerable<Type> GetTypesForSimpleReference (string jniSimpl
if (j != null) {
return GetReplacementTypeCore (j) ?? j;
}
return base.GetSimpleReference (type);
// Intentionally don't call base.GetSimpleReference(type): Android's
// non-trimmable runtime uses the generated/registered typemap, not
// Java.Interop's JniTypeSignatureAttribute fallback.
return null;
}

protected override IEnumerable<string> GetSimpleReferences (Type type)
Expand All @@ -361,12 +367,10 @@ protected override IEnumerable<string> GetSimpleReferences (Type type)
j = GetReplacementTypeCore (j) ?? j;

if (j != null) {
yield return j;
yield break;
}
foreach (var r in base.GetSimpleReferences (type)) {
yield return r;
return [j];
}
// Keep this in sync with GetSimpleReference(): no base fallback.
return [];
}

protected override IReadOnlyList<string>? GetStaticMethodFallbackTypesCore (string jniSimpleReference)
Expand Down Expand Up @@ -402,8 +406,6 @@ protected override IEnumerable<string> GetSimpleReferences (Type type)
static MethodInfo? dynamic_callback_gen;

// See ExportAttribute.cs
[UnconditionalSuppressMessage ("Trimming", "IL2026", Justification = "Mono.Android.Export.dll is preserved when [Export] is used via [DynamicDependency].")]
[UnconditionalSuppressMessage ("Trimming", "IL2075", Justification = "Mono.Android.Export.dll is preserved when [Export] is used via [DynamicDependency].")]
static Delegate CreateDynamicCallback (MethodInfo method)
{
if (dynamic_callback_gen == null) {
Expand Down Expand Up @@ -505,9 +507,6 @@ public override void RegisterNativeMembers (
string? methods) =>
RegisterNativeMembers (nativeClass, type, methods.AsSpan ());

[UnconditionalSuppressMessage ("Trimming", "IL2057", Justification = "Type.GetType() can never statically know the string value parsed from parameter 'methods'.")]
[UnconditionalSuppressMessage ("Trimming", "IL2067", Justification = "Delegate.CreateDelegate() can never statically know the string value parsed from parameter 'methods'.")]
[UnconditionalSuppressMessage ("Trimming", "IL2072", Justification = "Delegate.CreateDelegate() can never statically know the string value parsed from parameter 'methods'.")]
public override void RegisterNativeMembers (
JniType nativeClass,
[DynamicallyAccessedMembers (MethodsAndPrivateNested)] Type type,
Expand Down Expand Up @@ -640,7 +639,8 @@ static void SplitMethodLine (
}
}

[UnconditionalSuppressMessage ("Trimming", "IL2026", Justification = "Temporary suppression for Java.Interop reflection manager base.")]
[RequiresDynamicCode ("This value manager is reflection-backed and is not compatible with Native AOT.")]
[RequiresUnreferencedCode ("This value manager is reflection-backed and is not trimming-compatible.")]
class AndroidValueManager : JniRuntime.ReflectionJniValueManager {

Dictionary<IntPtr, IdentityHashTargets> instances = new Dictionary<IntPtr, IdentityHashTargets> ();
Expand Down
Loading
Loading