From f93939c030f2bf8e7b9b2d79579b632b1184255f Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 10 Jun 2026 02:53:03 +0000 Subject: [PATCH 1/9] Bump external/Java.Interop from `b881d21` to `d7dbad5` Bumps [external/Java.Interop](https://github.com/dotnet/java-interop) from `b881d21` to `d7dbad5`. - [Commits](https://github.com/dotnet/java-interop/compare/b881d21f51cbac6e175de1b2f6c254fe3846aa1d...d7dbad5e30a8f03743a508a95c4e9159fe1f6607) --- updated-dependencies: - dependency-name: external/Java.Interop dependency-version: d7dbad5e30a8f03743a508a95c4e9159fe1f6607 dependency-type: direct:production ... Signed-off-by: dependabot[bot] --- external/Java.Interop | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/external/Java.Interop b/external/Java.Interop index b881d21f51c..d7dbad5e30a 160000 --- a/external/Java.Interop +++ b/external/Java.Interop @@ -1 +1 @@ -Subproject commit b881d21f51cbac6e175de1b2f6c254fe3846aa1d +Subproject commit d7dbad5e30a8f03743a508a95c4e9159fe1f6607 From 28ca65e6a7cd69c3decc5da2212f57ef50828ea8 Mon Sep 17 00:00:00 2001 From: Simon Rozsival Date: Wed, 10 Jun 2026 19:33:58 +0200 Subject: [PATCH 2/9] Adapt Android runtime to Java.Interop reflection managers Use the new ReflectionJniTypeManager and ReflectionJniValueManager bases introduced by the Java.Interop submodule update, while preserving Android's legacy peer activation path for value managers. Also keep Java.Interop built-in native registrations out of the trimmable typemap XA4251 path and remove the stale GenericMarshaler source include from Android Java.Interop tests. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .../Scanner/JavaPeerScanner.cs | 13 +- .../Android.Runtime/AndroidRuntime.cs | 32 +++- .../AndroidReflectionJniValueManager.cs | 178 ++++++++++++++++++ .../JavaMarshalValueManager.cs | 2 +- .../ManagedTypeManager.cs | 17 +- .../SimpleValueManager.cs | 2 +- .../TrimmableTypeMapTypeManager.cs | 24 ++- src/Mono.Android/Mono.Android.csproj | 1 + .../Java.Interop-Tests.NET.csproj | 4 - 9 files changed, 257 insertions(+), 16 deletions(-) create mode 100644 src/Mono.Android/Microsoft.Android.Runtime/AndroidReflectionJniValueManager.cs diff --git a/src/Microsoft.Android.Sdk.TrimmableTypeMap/Scanner/JavaPeerScanner.cs b/src/Microsoft.Android.Sdk.TrimmableTypeMap/Scanner/JavaPeerScanner.cs index 08b7b6c66bc..40415f71031 100644 --- a/src/Microsoft.Android.Sdk.TrimmableTypeMap/Scanner/JavaPeerScanner.cs +++ b/src/Microsoft.Android.Sdk.TrimmableTypeMap/Scanner/JavaPeerScanner.cs @@ -208,6 +208,8 @@ void ScanAssembly (AssemblyIndex index, Dictionary<(string ManagedName, string A continue; } + var fullName = MetadataTypeNameResolver.GetFullName (typeDef, index.Reader); + // [JniAddNativeMethodRegistrationAttribute] is not supported by the trimmable typemap // by design (see XA4251). Detect the attribute *before* any per-type filters below // (array type, no JNI name, etc.) so the diagnostic fires uniformly regardless of @@ -217,8 +219,9 @@ void ScanAssembly (AssemblyIndex index, Dictionary<(string ManagedName, string A // the assembly doesn't even reference the attribute type — the per-assembly // flag was computed cheaply in AssemblyIndex.Build. if (index.MayUseJniAddNativeMethodRegistrationAttribute && + !IsBuiltInJniAddNativeMethodRegistrationType (fullName, index) && HasJniAddNativeMethodRegistrationAttribute (typeDef, index)) { - logger?.LogJniAddNativeMethodRegistrationAttributeError (MetadataTypeNameResolver.GetFullName (typeDef, index.Reader)); + logger?.LogJniAddNativeMethodRegistrationAttributeError (fullName); } // Determine the JNI name and whether this is a known Java peer. @@ -261,8 +264,6 @@ void ScanAssembly (AssemblyIndex index, Dictionary<(string ManagedName, string A } } - var fullName = MetadataTypeNameResolver.GetFullName (typeDef, index.Reader); - var isInterface = (typeDef.Attributes & TypeAttributes.Interface) != 0; var isAbstract = (typeDef.Attributes & TypeAttributes.Abstract) != 0; var isGenericDefinition = typeDef.GetGenericParameters ().Count > 0; @@ -418,6 +419,12 @@ 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); + } + /// /// For each virtual override method on that wasn't already /// collected (no direct [Register]), walks up the base type hierarchy to find a diff --git a/src/Mono.Android/Android.Runtime/AndroidRuntime.cs b/src/Mono.Android/Android.Runtime/AndroidRuntime.cs index 918b8377b54..ffd82013df8 100644 --- a/src/Mono.Android/Android.Runtime/AndroidRuntime.cs +++ b/src/Mono.Android/Android.Runtime/AndroidRuntime.cs @@ -310,12 +310,16 @@ public override void DeleteWeakGlobalReference (ref JniObjectReference value) } } - class AndroidTypeManager : JniRuntime.JniTypeManager { + // Temporarily reflection-based until follow-up work removes AOT/trimming suppressions. + [UnconditionalSuppressMessage ("AOT", "IL3050", Justification = "Temporary suppression for Java.Interop reflection manager base.")] + [UnconditionalSuppressMessage ("Trimming", "IL2026", Justification = "Temporary suppression for Java.Interop reflection manager base.")] + 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) { @@ -332,13 +336,25 @@ protected override IEnumerable GetTypesForSimpleReference (string jniSimpl yield return t; } + [UnconditionalSuppressMessage ("Trimming", "IL2073", Justification = "Temporary suppression until legacy typemap entries carry DAM annotations.")] + [return: DynamicallyAccessedMembers (MethodsConstructors)] + protected override Type? GetTypeForSimpleReference (string jniSimpleReference) + { + var type = base.GetTypeForSimpleReference (jniSimpleReference); + if (type != null) { + return type; + } + + return Java.Interop.TypeManager.GetJavaToManagedType (jniSimpleReference); + } + protected override string? GetSimpleReference (Type type) { string? j = JNIEnv.TypemapManagedToJava (type); if (j != null) { return GetReplacementTypeCore (j) ?? j; } - return null; + return base.GetSimpleReference (type); } protected override IEnumerable GetSimpleReferences (Type type) @@ -347,9 +363,12 @@ protected override IEnumerable GetSimpleReferences (Type type) j = GetReplacementTypeCore (j) ?? j; if (j != null) { - return new[]{j}; + yield return j; + yield break; + } + foreach (var r in base.GetSimpleReferences (type)) { + yield return r; } - return Array.Empty (); } protected override IReadOnlyList? GetStaticMethodFallbackTypesCore (string jniSimpleReference) @@ -623,7 +642,10 @@ static void SplitMethodLine ( } } - class AndroidValueManager : JniRuntime.JniValueManager { + // Temporarily reflection-based until follow-up work removes AOT/trimming suppressions. + [UnconditionalSuppressMessage ("AOT", "IL3050", Justification = "Temporary suppression for Java.Interop reflection manager base.")] + [UnconditionalSuppressMessage ("Trimming", "IL2026", Justification = "Temporary suppression for Java.Interop reflection manager base.")] + class AndroidValueManager : JniRuntime.ReflectionJniValueManager { Dictionary instances = new Dictionary (); diff --git a/src/Mono.Android/Microsoft.Android.Runtime/AndroidReflectionJniValueManager.cs b/src/Mono.Android/Microsoft.Android.Runtime/AndroidReflectionJniValueManager.cs new file mode 100644 index 00000000000..8dc57cfa6fa --- /dev/null +++ b/src/Mono.Android/Microsoft.Android.Runtime/AndroidReflectionJniValueManager.cs @@ -0,0 +1,178 @@ +using System; +using System.Diagnostics.CodeAnalysis; +using System.Globalization; +using System.Reflection; +using System.Runtime.CompilerServices; +using Java.Interop; + +namespace Microsoft.Android.Runtime; + +// Temporarily reflection-based until follow-up work removes AOT/trimming suppressions. +[UnconditionalSuppressMessage ("AOT", "IL3050", Justification = "Temporary suppression for Java.Interop reflection manager base.")] +[UnconditionalSuppressMessage ("Trimming", "IL2026", Justification = "Temporary suppression for Java.Interop reflection manager base.")] +abstract class AndroidReflectionJniValueManager : JniRuntime.ReflectionJniValueManager +{ + const DynamicallyAccessedMemberTypes Constructors = DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.NonPublicConstructors; + + public override IJavaPeerable? CreatePeer ( + ref JniObjectReference reference, + JniObjectReferenceOptions transfer, + [DynamicallyAccessedMembers (Constructors)] + Type? targetType) + { + EnsureNotDisposed (); + + if (!reference.IsValid) { + return null; + } + + targetType = targetType ?? typeof (global::Java.Interop.JavaObject); + targetType = GetPeerType (targetType); + + if (!typeof (IJavaPeerable).IsAssignableFrom (targetType)) { + throw new ArgumentException ($"targetType `{targetType.AssemblyQualifiedName}` must implement IJavaPeerable!", nameof (targetType)); + } + + var targetSig = Runtime.TypeManager.GetTypeSignature (targetType); + if (!targetSig.IsValid || targetSig.SimpleReference == null) { + throw new ArgumentException ($"Could not determine Java type corresponding to `{targetType.AssemblyQualifiedName}`.", nameof (targetType)); + } + + var refClass = JniEnvironment.Types.GetObjectClass (reference); + JniObjectReference targetClass; + try { + targetClass = JniEnvironment.Types.FindClass (targetSig.SimpleReference); + } catch (Exception e) { + JniObjectReference.Dispose (ref refClass); + throw new ArgumentException ($"Could not find Java class `{targetSig.SimpleReference}`.", + nameof (targetType), + e); + } + + if (!JniEnvironment.Types.IsAssignableFrom (refClass, targetClass)) { + JniObjectReference.Dispose (ref refClass); + JniObjectReference.Dispose (ref targetClass); + return null; + } + + JniObjectReference.Dispose (ref targetClass); + + var peer = CreatePeerInstance (ref refClass, targetType, ref reference, transfer); + if (peer == null) { + throw new NotSupportedException (string.Format (CultureInfo.InvariantCulture, "Could not find an appropriate constructable wrapper type for Java type '{0}', targetType='{1}'.", + JniEnvironment.Types.GetJniTypeNameFromInstance (reference), targetType)); + } + peer.SetJniManagedPeerState (peer.JniManagedPeerState | JniManagedPeerStates.Replaceable); + return peer; + } + + [return: DynamicallyAccessedMembers (Constructors)] + static Type GetPeerType ([DynamicallyAccessedMembers (Constructors)] Type type) + { + if (type == typeof (object)) { + return typeof (global::Java.Interop.JavaObject); + } + if (type == typeof (IJavaPeerable)) { + return typeof (global::Java.Interop.JavaObject); + } + if (type == typeof (Exception)) { + return typeof (JavaException); + } + return type; + } + + IJavaPeerable? CreatePeerInstance ( + ref JniObjectReference klass, + [DynamicallyAccessedMembers (Constructors)] + Type targetType, + ref JniObjectReference reference, + JniObjectReferenceOptions transfer) + { + var jniTypeName = JniEnvironment.Types.GetJniTypeNameFromClass (klass); + + while (jniTypeName != null) { + JniTypeSignature sig; + if (!JniTypeSignature.TryParse (jniTypeName, out sig)) { + return null; + } + + Type? type = GetTypeAssignableTo (sig, targetType); + if (type != null) { + var peer = TryCreatePeerInstance (ref reference, transfer, type); + + if (peer != null) { + JniObjectReference.Dispose (ref klass); + return peer; + } + } + + var super = JniEnvironment.Types.GetSuperclass (klass); + jniTypeName = super.IsValid + ? JniEnvironment.Types.GetJniTypeNameFromClass (super) + : null; + + JniObjectReference.Dispose (ref klass, JniObjectReferenceOptions.CopyAndDispose); + klass = super; + } + JniObjectReference.Dispose (ref klass, JniObjectReferenceOptions.CopyAndDispose); + + return TryCreatePeerInstance (ref reference, transfer, targetType); + + [return: DynamicallyAccessedMembers (Constructors)] + Type? GetTypeAssignableTo (JniTypeSignature sig, Type targetType) + { + foreach (var t in Runtime.TypeManager.GetReflectionConstructibleTypes (sig)) { + if (targetType.IsAssignableFrom (t.Type)) { + return t.Type; + } + } + return null; + } + } + + IJavaPeerable? TryCreatePeerInstance ( + ref JniObjectReference reference, + JniObjectReferenceOptions options, + [DynamicallyAccessedMembers (Constructors)] + Type type) + { + type = Runtime.TypeManager.GetInvokerType (type) ?? type; + + var self = (IJavaPeerable) RuntimeHelpers.GetUninitializedObject (type); + self.SetJniManagedPeerState (JniManagedPeerStates.Replaceable | JniManagedPeerStates.Activatable); + + var constructed = false; + try { + constructed = TryConstructPeer (self, ref reference, options, type); + } finally { + if (!constructed) { + GC.SuppressFinalize (self); + self = null; + } + } + return self; + } + + static readonly Type ByRefJniObjectReference = typeof (JniObjectReference).MakeByRefType (); + static readonly Type[] JIConstructorSignature = new Type [] { ByRefJniObjectReference, typeof (JniObjectReferenceOptions) }; + + protected virtual bool TryConstructPeer ( + IJavaPeerable self, + ref JniObjectReference reference, + JniObjectReferenceOptions options, + [DynamicallyAccessedMembers (Constructors)] + Type type) + { + var c = type.GetConstructor (BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance, null, JIConstructorSignature, null); + if (c != null) { + var args = new object[] { + reference, + options, + }; + c.Invoke (self, args); + reference = (JniObjectReference) args [0]; + return true; + } + return false; + } +} diff --git a/src/Mono.Android/Microsoft.Android.Runtime/JavaMarshalValueManager.cs b/src/Mono.Android/Microsoft.Android.Runtime/JavaMarshalValueManager.cs index 458ad77202a..cfc32a7900a 100644 --- a/src/Mono.Android/Microsoft.Android.Runtime/JavaMarshalValueManager.cs +++ b/src/Mono.Android/Microsoft.Android.Runtime/JavaMarshalValueManager.cs @@ -18,7 +18,7 @@ namespace Microsoft.Android.Runtime; -class JavaMarshalValueManager : JniRuntime.JniValueManager +class JavaMarshalValueManager : AndroidReflectionJniValueManager { const DynamicallyAccessedMemberTypes Constructors = DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.NonPublicConstructors; diff --git a/src/Mono.Android/Microsoft.Android.Runtime/ManagedTypeManager.cs b/src/Mono.Android/Microsoft.Android.Runtime/ManagedTypeManager.cs index 454bab0e1bb..9f170d59f58 100644 --- a/src/Mono.Android/Microsoft.Android.Runtime/ManagedTypeManager.cs +++ b/src/Mono.Android/Microsoft.Android.Runtime/ManagedTypeManager.cs @@ -7,11 +7,15 @@ namespace Microsoft.Android.Runtime; -class ManagedTypeManager : JniRuntime.JniTypeManager { +// Temporarily reflection-based until follow-up work removes AOT/trimming suppressions. +[UnconditionalSuppressMessage ("AOT", "IL3050", Justification = "Temporary suppression for Java.Interop reflection manager base.")] +[UnconditionalSuppressMessage ("Trimming", "IL2026", Justification = "Temporary suppression for Java.Interop reflection manager base.")] +class ManagedTypeManager : JniRuntime.ReflectionJniTypeManager { const DynamicallyAccessedMemberTypes Constructors = DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.NonPublicConstructors; internal const DynamicallyAccessedMemberTypes Methods = DynamicallyAccessedMemberTypes.PublicMethods | DynamicallyAccessedMemberTypes.NonPublicMethods; internal const DynamicallyAccessedMemberTypes MethodsAndPrivateNested = Methods | DynamicallyAccessedMemberTypes.NonPublicNestedTypes; + internal const DynamicallyAccessedMemberTypes MethodsConstructors = MethodsAndPrivateNested | Constructors; public ManagedTypeManager () { @@ -141,6 +145,17 @@ protected override IEnumerable GetTypesForSimpleReference (string jniSimpl } } + [return: DynamicallyAccessedMembers (MethodsConstructors)] + protected override Type? GetTypeForSimpleReference (string jniSimpleReference) + { + var type = base.GetTypeForSimpleReference (jniSimpleReference); + if (type != null) { + return type; + } + + return ManagedTypeMapping.TryGetType (jniSimpleReference, out var target) ? target : null; + } + protected override IEnumerable GetSimpleReferences (Type type) { foreach (var r in base.GetSimpleReferences (type)) { diff --git a/src/Mono.Android/Microsoft.Android.Runtime/SimpleValueManager.cs b/src/Mono.Android/Microsoft.Android.Runtime/SimpleValueManager.cs index bcccf6d6fd1..0546f43d378 100644 --- a/src/Mono.Android/Microsoft.Android.Runtime/SimpleValueManager.cs +++ b/src/Mono.Android/Microsoft.Android.Runtime/SimpleValueManager.cs @@ -16,7 +16,7 @@ namespace Microsoft.Android.Runtime; -class SimpleValueManager : JniRuntime.JniValueManager +class SimpleValueManager : AndroidReflectionJniValueManager { const DynamicallyAccessedMemberTypes Constructors = DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.NonPublicConstructors; diff --git a/src/Mono.Android/Microsoft.Android.Runtime/TrimmableTypeMapTypeManager.cs b/src/Mono.Android/Microsoft.Android.Runtime/TrimmableTypeMapTypeManager.cs index dea8cb2dcb8..27fc13fce43 100644 --- a/src/Mono.Android/Microsoft.Android.Runtime/TrimmableTypeMapTypeManager.cs +++ b/src/Mono.Android/Microsoft.Android.Runtime/TrimmableTypeMapTypeManager.cs @@ -14,9 +14,16 @@ namespace Microsoft.Android.Runtime; /// Type manager for the trimmable typemap path. Delegates type lookups /// to . /// -class TrimmableTypeMapTypeManager : JniRuntime.JniTypeManager +// Temporarily reflection-based until follow-up work removes AOT/trimming suppressions. +[UnconditionalSuppressMessage ("AOT", "IL3050", Justification = "Temporary suppression for Java.Interop reflection manager base.")] +[UnconditionalSuppressMessage ("Trimming", "IL2026", Justification = "Temporary suppression for Java.Interop reflection manager base.")] +class TrimmableTypeMapTypeManager : JniRuntime.ReflectionJniTypeManager { const string NoSimpleReference = "\0"; + 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; readonly ConcurrentDictionary _simpleReferenceCache = new (); protected override IEnumerable GetTypesForSimpleReference (string jniSimpleReference) @@ -32,6 +39,21 @@ protected override IEnumerable GetTypesForSimpleReference (string jniSimpl } } + [UnconditionalSuppressMessage ("Trimming", "IL2063", Justification = "Temporary suppression until trimmable typemap type entries carry DAM annotations.")] + [return: DynamicallyAccessedMembers (MethodsConstructors)] + protected override Type? GetTypeForSimpleReference (string jniSimpleReference) + { + var type = base.GetTypeForSimpleReference (jniSimpleReference); + if (type != null) { + return type; + } + + if (TrimmableTypeMap.Instance.TryGetTargetTypes (jniSimpleReference, out var types)) { + return types [0]; + } + return null; + } + protected override string? GetSimpleReference (Type type) { var simpleReference = _simpleReferenceCache.GetOrAdd (type, GetSimpleReferenceUncached); diff --git a/src/Mono.Android/Mono.Android.csproj b/src/Mono.Android/Mono.Android.csproj index 611ef7edf07..66e62f3e884 100644 --- a/src/Mono.Android/Mono.Android.csproj +++ b/src/Mono.Android/Mono.Android.csproj @@ -363,6 +363,7 @@ + diff --git a/tests/Mono.Android-Tests/Java.Interop-Tests/Java.Interop-Tests.NET.csproj b/tests/Mono.Android-Tests/Java.Interop-Tests/Java.Interop-Tests.NET.csproj index 5696ee844b8..45502ef4694 100644 --- a/tests/Mono.Android-Tests/Java.Interop-Tests/Java.Interop-Tests.NET.csproj +++ b/tests/Mono.Android-Tests/Java.Interop-Tests/Java.Interop-Tests.NET.csproj @@ -51,10 +51,6 @@ - - - Java.Interop.GenericMarshaler\JniPeerInstanceMethodsExtensions.cs - From b65b3d46aab6aea2b4b29eb5e789cdfddd77639f Mon Sep 17 00:00:00 2001 From: Simon Rozsival Date: Thu, 11 Jun 2026 09:59:44 +0200 Subject: [PATCH 3/9] Fix Java.Interop bump CI regressions Keep reflection-manager analyzer suppressions local to Mono.Android build compilation so NativeAOT app warning tests still observe the expected warnings. Isolate post-trim trimmable typemap Java output per inner build to avoid concurrent linked-java cleanup races, and update the MonoVM APK size baseline for the Java.Interop bump. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .../Android.Runtime/AndroidRuntime.cs | 7 ------ .../AndroidReflectionJniValueManager.cs | 3 --- .../ManagedTypeManager.cs | 3 --- .../TrimmableTypeMapTypeManager.cs | 4 ---- src/Mono.Android/Mono.Android.csproj | 2 +- ...soft.Android.Sdk.TypeMap.Trimmable.targets | 6 +++-- ...ildReleaseArm64SimpleDotNet.MonoVM.apkdesc | 24 +++++++++---------- 7 files changed, 17 insertions(+), 32 deletions(-) diff --git a/src/Mono.Android/Android.Runtime/AndroidRuntime.cs b/src/Mono.Android/Android.Runtime/AndroidRuntime.cs index ffd82013df8..54578ed64c2 100644 --- a/src/Mono.Android/Android.Runtime/AndroidRuntime.cs +++ b/src/Mono.Android/Android.Runtime/AndroidRuntime.cs @@ -310,9 +310,6 @@ public override void DeleteWeakGlobalReference (ref JniObjectReference value) } } - // Temporarily reflection-based until follow-up work removes AOT/trimming suppressions. - [UnconditionalSuppressMessage ("AOT", "IL3050", Justification = "Temporary suppression for Java.Interop reflection manager base.")] - [UnconditionalSuppressMessage ("Trimming", "IL2026", Justification = "Temporary suppression for Java.Interop reflection manager base.")] class AndroidTypeManager : JniRuntime.ReflectionJniTypeManager { bool jniAddNativeMethodRegistrationAttributePresent; @@ -336,7 +333,6 @@ protected override IEnumerable GetTypesForSimpleReference (string jniSimpl yield return t; } - [UnconditionalSuppressMessage ("Trimming", "IL2073", Justification = "Temporary suppression until legacy typemap entries carry DAM annotations.")] [return: DynamicallyAccessedMembers (MethodsConstructors)] protected override Type? GetTypeForSimpleReference (string jniSimpleReference) { @@ -642,9 +638,6 @@ static void SplitMethodLine ( } } - // Temporarily reflection-based until follow-up work removes AOT/trimming suppressions. - [UnconditionalSuppressMessage ("AOT", "IL3050", Justification = "Temporary suppression for Java.Interop reflection manager base.")] - [UnconditionalSuppressMessage ("Trimming", "IL2026", Justification = "Temporary suppression for Java.Interop reflection manager base.")] class AndroidValueManager : JniRuntime.ReflectionJniValueManager { Dictionary instances = new Dictionary (); diff --git a/src/Mono.Android/Microsoft.Android.Runtime/AndroidReflectionJniValueManager.cs b/src/Mono.Android/Microsoft.Android.Runtime/AndroidReflectionJniValueManager.cs index 8dc57cfa6fa..739478fe041 100644 --- a/src/Mono.Android/Microsoft.Android.Runtime/AndroidReflectionJniValueManager.cs +++ b/src/Mono.Android/Microsoft.Android.Runtime/AndroidReflectionJniValueManager.cs @@ -7,9 +7,6 @@ namespace Microsoft.Android.Runtime; -// Temporarily reflection-based until follow-up work removes AOT/trimming suppressions. -[UnconditionalSuppressMessage ("AOT", "IL3050", Justification = "Temporary suppression for Java.Interop reflection manager base.")] -[UnconditionalSuppressMessage ("Trimming", "IL2026", Justification = "Temporary suppression for Java.Interop reflection manager base.")] abstract class AndroidReflectionJniValueManager : JniRuntime.ReflectionJniValueManager { const DynamicallyAccessedMemberTypes Constructors = DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.NonPublicConstructors; diff --git a/src/Mono.Android/Microsoft.Android.Runtime/ManagedTypeManager.cs b/src/Mono.Android/Microsoft.Android.Runtime/ManagedTypeManager.cs index 9f170d59f58..c50cff5299d 100644 --- a/src/Mono.Android/Microsoft.Android.Runtime/ManagedTypeManager.cs +++ b/src/Mono.Android/Microsoft.Android.Runtime/ManagedTypeManager.cs @@ -7,9 +7,6 @@ namespace Microsoft.Android.Runtime; -// Temporarily reflection-based until follow-up work removes AOT/trimming suppressions. -[UnconditionalSuppressMessage ("AOT", "IL3050", Justification = "Temporary suppression for Java.Interop reflection manager base.")] -[UnconditionalSuppressMessage ("Trimming", "IL2026", Justification = "Temporary suppression for Java.Interop reflection manager base.")] class ManagedTypeManager : JniRuntime.ReflectionJniTypeManager { const DynamicallyAccessedMemberTypes Constructors = DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.NonPublicConstructors; diff --git a/src/Mono.Android/Microsoft.Android.Runtime/TrimmableTypeMapTypeManager.cs b/src/Mono.Android/Microsoft.Android.Runtime/TrimmableTypeMapTypeManager.cs index 27fc13fce43..e5acdac22bc 100644 --- a/src/Mono.Android/Microsoft.Android.Runtime/TrimmableTypeMapTypeManager.cs +++ b/src/Mono.Android/Microsoft.Android.Runtime/TrimmableTypeMapTypeManager.cs @@ -14,9 +14,6 @@ namespace Microsoft.Android.Runtime; /// Type manager for the trimmable typemap path. Delegates type lookups /// to . /// -// Temporarily reflection-based until follow-up work removes AOT/trimming suppressions. -[UnconditionalSuppressMessage ("AOT", "IL3050", Justification = "Temporary suppression for Java.Interop reflection manager base.")] -[UnconditionalSuppressMessage ("Trimming", "IL2026", Justification = "Temporary suppression for Java.Interop reflection manager base.")] class TrimmableTypeMapTypeManager : JniRuntime.ReflectionJniTypeManager { const string NoSimpleReference = "\0"; @@ -39,7 +36,6 @@ protected override IEnumerable GetTypesForSimpleReference (string jniSimpl } } - [UnconditionalSuppressMessage ("Trimming", "IL2063", Justification = "Temporary suppression until trimmable typemap type entries carry DAM annotations.")] [return: DynamicallyAccessedMembers (MethodsConstructors)] protected override Type? GetTypeForSimpleReference (string jniSimpleReference) { diff --git a/src/Mono.Android/Mono.Android.csproj b/src/Mono.Android/Mono.Android.csproj index 66e62f3e884..18a56a00c3c 100644 --- a/src/Mono.Android/Mono.Android.csproj +++ b/src/Mono.Android/Mono.Android.csproj @@ -10,7 +10,7 @@ Android true ..\..\product.snk - 0618;0809;0108;0114;0465;8609;8610;8614;8617;8613;8764;8765;8766;8767;RS0041 + 0618;0809;0108;0114;0465;8609;8610;8614;8617;8613;8764;8765;8766;8767;RS0041;IL2026;IL2063;IL2073;IL3050 $(WarningsAsErrors);CS2002 true $(DefineConstants);JAVA_INTEROP diff --git a/src/Xamarin.Android.Build.Tasks/Microsoft.Android.Sdk/targets/Microsoft.Android.Sdk.TypeMap.Trimmable.targets b/src/Xamarin.Android.Build.Tasks/Microsoft.Android.Sdk/targets/Microsoft.Android.Sdk.TypeMap.Trimmable.targets index e98c23cf5e6..2811ab5f6da 100644 --- a/src/Xamarin.Android.Build.Tasks/Microsoft.Android.Sdk/targets/Microsoft.Android.Sdk.TypeMap.Trimmable.targets +++ b/src/Xamarin.Android.Build.Tasks/Microsoft.Android.Sdk/targets/Microsoft.Android.Sdk.TypeMap.Trimmable.targets @@ -24,10 +24,12 @@ <_TypeMapOutputDirectory>$(_TypeMapBaseOutputDir)typemap/ <_TypeMapJavaOutputDirectory>$(_TypeMapBaseOutputDir)typemap/java <_TypeMapAssembliesListFile>$(_TypeMapOutputDirectory)typemap-assemblies.txt - <_PostTrimTypeMapJavaOutputDirectory>$(_TypeMapBaseOutputDir)typemap/linked-java + <_PostTrimTypeMapJavaBaseOutputDir Condition=" '$(_OuterIntermediateOutputPath)' != '' ">$(IntermediateOutputPath) + <_PostTrimTypeMapJavaBaseOutputDir Condition=" '$(_PostTrimTypeMapJavaBaseOutputDir)' == '' ">$(_TypeMapBaseOutputDir) + <_PostTrimTypeMapJavaOutputDirectory>$(_PostTrimTypeMapJavaBaseOutputDir)typemap/linked-java <_TypeMapJavaStubsSourceDirectory Condition=" '$(_TypeMapJavaStubsSourceDirectory)' == '' and '$(_AndroidRuntime)' == 'CoreCLR' and '$(PublishTrimmed)' == 'true' ">$(_PostTrimTypeMapJavaOutputDirectory) <_TypeMapJavaStubsSourceDirectory Condition=" '$(_TypeMapJavaStubsSourceDirectory)' == '' ">$(_TypeMapJavaOutputDirectory) - <_PostTrimTrimmableTypeMapJavaStamp>$(_TypeMapBaseOutputDir)stamp/_GeneratePostTrimTrimmableTypeMapJavaSources.stamp + <_PostTrimTrimmableTypeMapJavaStamp>$(_PostTrimTypeMapJavaBaseOutputDir)stamp/_GeneratePostTrimTrimmableTypeMapJavaSources.stamp <_TrimmableJavaSourceStamp Condition=" '$(_TrimmableJavaSourceStamp)' == '' and '$(_AndroidRuntime)' == 'CoreCLR' and '$(PublishTrimmed)' == 'true' ">$(_PostTrimTrimmableTypeMapJavaStamp) <_TrimmableJavaSourceStamp Condition=" '$(_TrimmableJavaSourceStamp)' == '' ">$(_TypeMapOutputDirectory)$(_TypeMapAssemblyName).dll