diff --git a/external/Java.Interop b/external/Java.Interop index 8b85462e5f3..07c73009571 160000 --- a/external/Java.Interop +++ b/external/Java.Interop @@ -1 +1 @@ -Subproject commit 8b85462e5f304d9aa2d91c02966d7dc9751516c7 +Subproject commit 07c73009571d3b5d36ae79d0d4d69a02062dd6e8 diff --git a/src/Mono.Android/Java.Interop/TypeManager.cs b/src/Mono.Android/Java.Interop/TypeManager.cs index 3b900017db2..9d71981804f 100644 --- a/src/Mono.Android/Java.Interop/TypeManager.cs +++ b/src/Mono.Android/Java.Interop/TypeManager.cs @@ -286,16 +286,20 @@ internal static IJavaPeerable CreateInstance (IntPtr handle, JniHandleOwnership JNIEnv.DeleteLocalRef (class_ptr); + if (targetType != null && + (type == null || + !targetType.IsAssignableFrom (type))) { + type = targetType; + } + if (type == null) { + class_name = JNIEnv.GetClassNameFromInstance (handle); JNIEnv.DeleteRef (handle, transfer); throw new NotSupportedException ( - FormattableString.Invariant ($"Internal error finding wrapper class for '{JNIEnv.GetClassNameFromInstance (handle)}'. (Where is the Java.Lang.Object wrapper?!)"), + FormattableString.Invariant ($"Internal error finding wrapper class for '{class_name}'. (Where is the Java.Lang.Object wrapper?!)"), CreateJavaLocationException ()); } - if (targetType != null && !targetType.IsAssignableFrom (type)) - type = targetType; - if (type.IsInterface || type.IsAbstract) { var invokerType = JavaObjectExtensions.GetInvokerType (type); if (invokerType == null) diff --git a/src/Xamarin.Android.Build.Tasks/Tasks/GenerateCompressedAssembliesNativeSourceFiles.cs b/src/Xamarin.Android.Build.Tasks/Tasks/GenerateCompressedAssembliesNativeSourceFiles.cs index 48f849596e0..441299c527d 100644 --- a/src/Xamarin.Android.Build.Tasks/Tasks/GenerateCompressedAssembliesNativeSourceFiles.cs +++ b/src/Xamarin.Android.Build.Tasks/Tasks/GenerateCompressedAssembliesNativeSourceFiles.cs @@ -74,7 +74,7 @@ void GenerateCompressedAssemblySources () void Generate (IDictionary dict) { - var composer = new CompressedAssembliesNativeAssemblyGenerator (dict); + var composer = new CompressedAssembliesNativeAssemblyGenerator (Log, dict); LLVMIR.LlvmIrModule compressedAssemblies = composer.Construct (); foreach (string abi in SupportedAbis) { diff --git a/src/Xamarin.Android.Build.Tasks/Tasks/GenerateJavaStubs.cs b/src/Xamarin.Android.Build.Tasks/Tasks/GenerateJavaStubs.cs index 80f1f25b279..6a0444e872b 100644 --- a/src/Xamarin.Android.Build.Tasks/Tasks/GenerateJavaStubs.cs +++ b/src/Xamarin.Android.Build.Tasks/Tasks/GenerateJavaStubs.cs @@ -570,7 +570,7 @@ void SaveResource (string resource, string filename, string destDir, Func types, TypeDefinitionCache cache) { - var tmg = new TypeMapGenerator ((string message) => Log.LogDebugMessage (message), SupportedAbis); + var tmg = new TypeMapGenerator (Log, SupportedAbis); if (!tmg.Generate (Debug, SkipJniAddNativeMethodRegistrationAttributeScan, types, cache, TypemapOutputDirectory, GenerateNativeAssembly, out ApplicationConfigTaskState appConfState)) { throw new XamarinAndroidException (4308, Properties.Resources.XA4308); } diff --git a/src/Xamarin.Android.Build.Tasks/Tasks/GenerateJniRemappingNativeCode.cs b/src/Xamarin.Android.Build.Tasks/Tasks/GenerateJniRemappingNativeCode.cs index b89ce87d26d..53d73a27826 100644 --- a/src/Xamarin.Android.Build.Tasks/Tasks/GenerateJniRemappingNativeCode.cs +++ b/src/Xamarin.Android.Build.Tasks/Tasks/GenerateJniRemappingNativeCode.cs @@ -54,7 +54,7 @@ public override bool RunTask () void GenerateEmpty () { - Generate (new JniRemappingAssemblyGenerator (), typeReplacementsCount: 0); + Generate (new JniRemappingAssemblyGenerator (Log), typeReplacementsCount: 0); } void Generate () @@ -74,7 +74,7 @@ void Generate () } } - Generate (new JniRemappingAssemblyGenerator (typeReplacements, methodReplacements), typeReplacements.Count); + Generate (new JniRemappingAssemblyGenerator (Log, typeReplacements, methodReplacements), typeReplacements.Count); } void Generate (JniRemappingAssemblyGenerator jniRemappingComposer, int typeReplacementsCount) diff --git a/src/Xamarin.Android.Build.Tasks/Tasks/GeneratePackageManagerJava.cs b/src/Xamarin.Android.Build.Tasks/Tasks/GeneratePackageManagerJava.cs index 7c50f680dfa..101f70f84c6 100644 --- a/src/Xamarin.Android.Build.Tasks/Tasks/GeneratePackageManagerJava.cs +++ b/src/Xamarin.Android.Build.Tasks/Tasks/GeneratePackageManagerJava.cs @@ -386,13 +386,13 @@ void AddEnvironment () if (enableMarshalMethods) { marshalMethodsAsmGen = new MarshalMethodsNativeAssemblyGenerator ( + Log, assemblyCount, uniqueAssemblyNames, - marshalMethodsState?.MarshalMethods, - Log + marshalMethodsState?.MarshalMethods ); } else { - marshalMethodsAsmGen = new MarshalMethodsNativeAssemblyGenerator (assemblyCount, uniqueAssemblyNames); + marshalMethodsAsmGen = new MarshalMethodsNativeAssemblyGenerator (Log, assemblyCount, uniqueAssemblyNames); } LLVMIR.LlvmIrModule marshalMethodsModule = marshalMethodsAsmGen.Construct (); diff --git a/src/Xamarin.Android.Build.Tasks/Tasks/JavaCompileToolTask.cs b/src/Xamarin.Android.Build.Tasks/Tasks/JavaCompileToolTask.cs index a3c1a73f6c3..1b61dd1397f 100644 --- a/src/Xamarin.Android.Build.Tasks/Tasks/JavaCompileToolTask.cs +++ b/src/Xamarin.Android.Build.Tasks/Tasks/JavaCompileToolTask.cs @@ -90,6 +90,10 @@ private void GenerateResponseFile () file.Replace (@"\", @"\\").Normalize (NormalizationForm.FormC))); } } + Log.LogDebugMessage ($"javac response file contents: {TemporarySourceListFile}"); + foreach (var line in File.ReadLines (TemporarySourceListFile)) { + Log.LogDebugMessage ($" {line}"); + } } } } diff --git a/src/Xamarin.Android.Build.Tasks/Tasks/R8.cs b/src/Xamarin.Android.Build.Tasks/Tasks/R8.cs index 81d65a2c218..d9cafeb4e3d 100644 --- a/src/Xamarin.Android.Build.Tasks/Tasks/R8.cs +++ b/src/Xamarin.Android.Build.Tasks/Tasks/R8.cs @@ -1,3 +1,4 @@ +using System; using Microsoft.Build.Framework; using Microsoft.Build.Utilities; using System.Collections.Generic; @@ -82,16 +83,15 @@ protected override CommandLineBuilder GetCommandLineBuilder () if (EnableShrinking) { if (!string.IsNullOrEmpty (AcwMapFile)) { - var acwLines = File.ReadAllLines (AcwMapFile); + var acwMap = MonoAndroidHelper.LoadMapFile (BuildEngine4, Path.GetFullPath (AcwMapFile), StringComparer.OrdinalIgnoreCase); + var javaTypes = new List (acwMap.Values.Count); + foreach (var v in acwMap.Values) { + javaTypes.Add (v); + } + javaTypes.Sort (StringComparer.Ordinal); using (var appcfg = File.CreateText (ProguardGeneratedApplicationConfiguration)) { - for (int i = 0; i + 2 < acwLines.Length; i += 3) { - try { - var line = acwLines [i + 2]; - var java = line.Substring (line.IndexOf (';') + 1); - appcfg.WriteLine ("-keep class " + java + " { *; }"); - } catch { - // skip invalid lines - } + foreach (var java in javaTypes) { + appcfg.WriteLine ($"-keep class {java} {{ *; }}"); } } } diff --git a/src/Xamarin.Android.Build.Tasks/Utilities/ApplicationConfigNativeAssemblyGenerator.cs b/src/Xamarin.Android.Build.Tasks/Utilities/ApplicationConfigNativeAssemblyGenerator.cs index 2dcbac7b0e4..c4bdfc45eb0 100644 --- a/src/Xamarin.Android.Build.Tasks/Utilities/ApplicationConfigNativeAssemblyGenerator.cs +++ b/src/Xamarin.Android.Build.Tasks/Utilities/ApplicationConfigNativeAssemblyGenerator.cs @@ -6,6 +6,7 @@ using Java.Interop.Tools.TypeNameMappings; using Microsoft.Build.Framework; using Microsoft.Build.Utilities; +using Microsoft.Android.Build.Tasks; using Xamarin.Android.Tasks.LLVMIR; namespace Xamarin.Android.Tasks @@ -135,7 +136,6 @@ sealed class XamarinAndroidBundledAssembly SortedDictionary ? environmentVariables; SortedDictionary ? systemProperties; - TaskLoggingHelper log; StructureInstance? application_config; List>? dsoCache; List>? xamarinAndroidBundledAssemblies; @@ -172,6 +172,7 @@ sealed class XamarinAndroidBundledAssembly public bool MarshalMethodsEnabled { get; set; } public ApplicationConfigNativeAssemblyGenerator (IDictionary environmentVariables, IDictionary systemProperties, TaskLoggingHelper log) + : base (log) { if (environmentVariables != null) { this.environmentVariables = new SortedDictionary (environmentVariables, StringComparer.Ordinal); @@ -180,8 +181,6 @@ public ApplicationConfigNativeAssemblyGenerator (IDictionary env if (systemProperties != null) { this.systemProperties = new SortedDictionary (systemProperties, StringComparer.Ordinal); } - - this.log = log; } protected override void Construct (LlvmIrModule module) @@ -322,7 +321,7 @@ List> InitDSOCache () continue; } - dsos.Add ((name, $"dsoName{dsos.Count.ToString (CultureInfo.InvariantCulture)}", ELFHelper.IsEmptyAOTLibrary (log, item.ItemSpec))); + dsos.Add ((name, $"dsoName{dsos.Count.ToString (CultureInfo.InvariantCulture)}", ELFHelper.IsEmptyAOTLibrary (Log, item.ItemSpec))); } var dsoCache = new List> (); diff --git a/src/Xamarin.Android.Build.Tasks/Utilities/CompressedAssembliesNativeAssemblyGenerator.cs b/src/Xamarin.Android.Build.Tasks/Utilities/CompressedAssembliesNativeAssemblyGenerator.cs index e0b3740a453..6cb7f251f8a 100644 --- a/src/Xamarin.Android.Build.Tasks/Utilities/CompressedAssembliesNativeAssemblyGenerator.cs +++ b/src/Xamarin.Android.Build.Tasks/Utilities/CompressedAssembliesNativeAssemblyGenerator.cs @@ -1,6 +1,8 @@ using System; using System.Collections.Generic; +using Microsoft.Build.Utilities; + using Xamarin.Android.Tasks.LLVMIR; namespace Xamarin.Android.Tasks @@ -66,7 +68,8 @@ sealed class CompressedAssemblies StructureInfo compressedAssemblyDescriptorStructureInfo; StructureInfo compressedAssembliesStructureInfo; - public CompressedAssembliesNativeAssemblyGenerator (IDictionary assemblies) + public CompressedAssembliesNativeAssemblyGenerator (TaskLoggingHelper log, IDictionary assemblies) + : base (log) { this.assemblies = assemblies; } diff --git a/src/Xamarin.Android.Build.Tasks/Utilities/JniRemappingAssemblyGenerator.cs b/src/Xamarin.Android.Build.Tasks/Utilities/JniRemappingAssemblyGenerator.cs index 93ab1cd7b31..dd6d0924fff 100644 --- a/src/Xamarin.Android.Build.Tasks/Utilities/JniRemappingAssemblyGenerator.cs +++ b/src/Xamarin.Android.Build.Tasks/Utilities/JniRemappingAssemblyGenerator.cs @@ -2,6 +2,8 @@ using System.Collections.Generic; using System.Text; +using Microsoft.Build.Utilities; + using Xamarin.Android.Tasks.LLVMIR; namespace Xamarin.Android.Tasks @@ -190,10 +192,12 @@ sealed class JniRemappingTypeReplacementEntry public int ReplacementMethodIndexEntryCount { get; private set; } = 0; - public JniRemappingAssemblyGenerator () + public JniRemappingAssemblyGenerator (TaskLoggingHelper log) + : base (log) {} - public JniRemappingAssemblyGenerator (List typeReplacements, List methodReplacements) + public JniRemappingAssemblyGenerator (TaskLoggingHelper log, List typeReplacements, List methodReplacements) + : base (log) { this.typeReplacementsInput = typeReplacements ?? throw new ArgumentNullException (nameof (typeReplacements)); this.methodReplacementsInput = methodReplacements ?? throw new ArgumentNullException (nameof (methodReplacements)); diff --git a/src/Xamarin.Android.Build.Tasks/Utilities/LlvmIrGenerator/LlvmIrComposer.cs b/src/Xamarin.Android.Build.Tasks/Utilities/LlvmIrGenerator/LlvmIrComposer.cs index 8db94269f32..b250bf24085 100644 --- a/src/Xamarin.Android.Build.Tasks/Utilities/LlvmIrGenerator/LlvmIrComposer.cs +++ b/src/Xamarin.Android.Build.Tasks/Utilities/LlvmIrGenerator/LlvmIrComposer.cs @@ -3,6 +3,8 @@ using System.IO.Hashing; using System.Text; +using Microsoft.Build.Utilities; + using Xamarin.Android.Tools; namespace Xamarin.Android.Tasks.LLVMIR @@ -11,6 +13,13 @@ abstract class LlvmIrComposer { bool constructed; + protected readonly TaskLoggingHelper Log; + + protected LlvmIrComposer (TaskLoggingHelper log) + { + this.Log = log ?? throw new ArgumentNullException (nameof (log)); + } + protected abstract void Construct (LlvmIrModule module); public LlvmIrModule Construct () diff --git a/src/Xamarin.Android.Build.Tasks/Utilities/MarshalMethodsNativeAssemblyGenerator.cs b/src/Xamarin.Android.Build.Tasks/Utilities/MarshalMethodsNativeAssemblyGenerator.cs index f87cf118971..c30df45bb8e 100644 --- a/src/Xamarin.Android.Build.Tasks/Utilities/MarshalMethodsNativeAssemblyGenerator.cs +++ b/src/Xamarin.Android.Build.Tasks/Utilities/MarshalMethodsNativeAssemblyGenerator.cs @@ -228,7 +228,6 @@ public MarshalMethodAssemblyIndexValuePlaceholder (MarshalMethodInfo mmi, Assemb ICollection uniqueAssemblyNames; int numberOfAssembliesInApk; IDictionary> marshalMethods; - TaskLoggingHelper logger; StructureInfo marshalMethodsManagedClassStructureInfo; StructureInfo marshalMethodNameStructureInfo; @@ -243,7 +242,8 @@ public MarshalMethodAssemblyIndexValuePlaceholder (MarshalMethodInfo mmi, Assemb /// /// Constructor to be used ONLY when marshal methods are DISABLED /// - public MarshalMethodsNativeAssemblyGenerator (int numberOfAssembliesInApk, ICollection uniqueAssemblyNames) + public MarshalMethodsNativeAssemblyGenerator (TaskLoggingHelper log, int numberOfAssembliesInApk, ICollection uniqueAssemblyNames) + : base (log) { this.numberOfAssembliesInApk = numberOfAssembliesInApk; this.uniqueAssemblyNames = uniqueAssemblyNames ?? throw new ArgumentNullException (nameof (uniqueAssemblyNames)); @@ -254,12 +254,12 @@ public MarshalMethodsNativeAssemblyGenerator (int numberOfAssembliesInApk, IColl /// /// Constructor to be used ONLY when marshal methods are ENABLED /// - public MarshalMethodsNativeAssemblyGenerator (int numberOfAssembliesInApk, ICollection uniqueAssemblyNames, IDictionary> marshalMethods, TaskLoggingHelper logger) + public MarshalMethodsNativeAssemblyGenerator (TaskLoggingHelper log, int numberOfAssembliesInApk, ICollection uniqueAssemblyNames, IDictionary> marshalMethods) + : base (log) { this.numberOfAssembliesInApk = numberOfAssembliesInApk; this.uniqueAssemblyNames = uniqueAssemblyNames ?? throw new ArgumentNullException (nameof (uniqueAssemblyNames)); this.marshalMethods = marshalMethods; - this.logger = logger ?? throw new ArgumentNullException (nameof (logger)); generateEmptyCode = false; defaultCallMarker = LlvmIrCallMarker.Tail; @@ -334,7 +334,7 @@ void Init () foreach (MarshalMethodInfo method in allMethods) { if (seenNativeSymbols.Contains (method.NativeSymbolName)) { - logger.LogDebugMessage ($"Removed MM duplicate '{method.NativeSymbolName}' (implemented: {method.Method.ImplementedMethod.FullName}; registered: {method.Method.RegisteredMethod.FullName}"); + Log.LogDebugMessage ($"Removed MM duplicate '{method.NativeSymbolName}' (implemented: {method.Method.ImplementedMethod.FullName}; registered: {method.Method.RegisteredMethod.FullName}"); continue; } diff --git a/src/Xamarin.Android.Build.Tasks/Utilities/NativeTypeMappingData.cs b/src/Xamarin.Android.Build.Tasks/Utilities/NativeTypeMappingData.cs index be2d4ad71dc..dfc6782c539 100644 --- a/src/Xamarin.Android.Build.Tasks/Utilities/NativeTypeMappingData.cs +++ b/src/Xamarin.Android.Build.Tasks/Utilities/NativeTypeMappingData.cs @@ -2,6 +2,9 @@ using System.Collections.Generic; using System.Linq; +using Microsoft.Build.Utilities; +using Microsoft.Android.Build.Tasks; + namespace Xamarin.Android.Tasks { class NativeTypeMappingData @@ -12,7 +15,7 @@ class NativeTypeMappingData public uint MapModuleCount { get; } public uint JavaTypeCount { get; } - public NativeTypeMappingData (TypeMapGenerator.ModuleReleaseData[] modules) + public NativeTypeMappingData (TaskLoggingHelper log, TypeMapGenerator.ModuleReleaseData[] modules) { Modules = modules ?? throw new ArgumentNullException (nameof (modules)); @@ -21,15 +24,37 @@ public NativeTypeMappingData (TypeMapGenerator.ModuleReleaseData[] modules) var tempJavaTypes = new Dictionary (StringComparer.Ordinal); var moduleComparer = new TypeMapGenerator.ModuleUUIDArrayComparer (); + TypeMapGenerator.ModuleReleaseData? monoAndroid = null; foreach (TypeMapGenerator.ModuleReleaseData data in modules) { + if (data.AssemblyName == "Mono.Android") { + monoAndroid = data; + break; + } + } + + if (monoAndroid != null) { + ProcessModule (monoAndroid); + } + + foreach (TypeMapGenerator.ModuleReleaseData data in modules) { + if (data.AssemblyName == "Mono.Android") { + continue; + } + ProcessModule (data); + }; + + void ProcessModule (TypeMapGenerator.ModuleReleaseData data) + { int moduleIndex = Array.BinarySearch (modules, data, moduleComparer); if (moduleIndex < 0) throw new InvalidOperationException ($"Unable to map module with MVID {data.Mvid} to array index"); foreach (TypeMapGenerator.TypeMapReleaseEntry entry in data.Types) { entry.ModuleIndex = moduleIndex; - if (tempJavaTypes.ContainsKey (entry.JavaName)) + if (tempJavaTypes.ContainsKey (entry.JavaName)) { + log.LogDebugMessage ($"Skipping typemap entry for `{entry.ManagedTypeName}, {data.AssemblyName}`; `{entry.JavaName}` is already mapped."); continue; + } tempJavaTypes.Add (entry.JavaName, entry); } } diff --git a/src/Xamarin.Android.Build.Tasks/Utilities/TypeMapGenerator.cs b/src/Xamarin.Android.Build.Tasks/Utilities/TypeMapGenerator.cs index 3730176e751..b54208a7d29 100644 --- a/src/Xamarin.Android.Build.Tasks/Utilities/TypeMapGenerator.cs +++ b/src/Xamarin.Android.Build.Tasks/Utilities/TypeMapGenerator.cs @@ -5,6 +5,8 @@ using System.Linq; using System.Text; +using Microsoft.Build.Utilities; + using Java.Interop.Tools.Cecil; using Mono.Cecil; using Microsoft.Android.Build.Tasks; @@ -133,7 +135,7 @@ public void AddKnownAssembly (TypeDefinition td) public string GetAssemblyName (TypeDefinition td) => td.Module.Assembly.FullName; } - Action logger; + TaskLoggingHelper log; Encoding outputEncoding; byte[] moduleMagicString; byte[] typemapIndexMagicString; @@ -141,9 +143,9 @@ public void AddKnownAssembly (TypeDefinition td) public IList GeneratedBinaryTypeMaps { get; } = new List (); - public TypeMapGenerator (Action logger, string[] supportedAbis) + public TypeMapGenerator (TaskLoggingHelper log, string[] supportedAbis) { - this.logger = logger ?? throw new ArgumentNullException (nameof (logger)); + this.log = log ?? throw new ArgumentNullException (nameof (log)); if (supportedAbis == null) throw new ArgumentNullException (nameof (supportedAbis)); this.supportedAbis = supportedAbis; @@ -257,7 +259,7 @@ bool GenerateDebugFiles (bool skipJniAddNativeMethodRegistrationAttributeScan, L } GeneratedBinaryTypeMaps.Add (typeMapIndexPath); - var composer = new TypeMappingDebugNativeAssemblyGenerator (new ModuleDebugData ()); + var composer = new TypeMappingDebugNativeAssemblyGenerator (log, new ModuleDebugData ()); GenerateNativeAssembly (composer, composer.Construct (), outputDirectory); return true; @@ -289,7 +291,7 @@ bool GenerateDebugNativeAssembly (bool skipJniAddNativeMethodRegistrationAttribu PrepareDebugMaps (data); - var composer = new TypeMappingDebugNativeAssemblyGenerator (data); + var composer = new TypeMappingDebugNativeAssemblyGenerator (log, data); GenerateNativeAssembly (composer, composer.Construct (), outputDirectory); return true; @@ -443,7 +445,7 @@ void ProcessReleaseType (ReleaseGenerationState state, TypeDefinition td, Androi // This is disabled because it costs a lot of time (around 150ms per standard XF Integration app // build) and has no value for the end user. The message is left here because it may be useful to us // in our devloop at some point. - //logger ($"Warning: duplicate Java type name '{entry.JavaName}' in assembly '{moduleData.AssemblyName}' (new token: {entry.Token})."); + //log.LogDebugMessage ($"Warning: duplicate Java type name '{entry.JavaName}' in assembly '{moduleData.AssemblyName}' (new token: {entry.Token})."); moduleData.DuplicateTypes.Add (entry); } else { moduleData.TypesScratch.Add (entry.JavaName, entry); @@ -482,7 +484,7 @@ bool GenerateRelease (bool skipJniAddNativeMethodRegistrationAttributeScan, List module.Types = module.TypesScratch.Values.ToArray (); } - var composer = new TypeMappingReleaseNativeAssemblyGenerator (new NativeTypeMappingData (modules)); + var composer = new TypeMappingReleaseNativeAssemblyGenerator (log, new NativeTypeMappingData (log, modules)); GenerateNativeAssembly (arch, composer, composer.Construct (), outputDirectory); } diff --git a/src/Xamarin.Android.Build.Tasks/Utilities/TypeMappingAssemblyGenerator.cs b/src/Xamarin.Android.Build.Tasks/Utilities/TypeMappingAssemblyGenerator.cs index e7e8d08a6a2..3427e49775e 100644 --- a/src/Xamarin.Android.Build.Tasks/Utilities/TypeMappingAssemblyGenerator.cs +++ b/src/Xamarin.Android.Build.Tasks/Utilities/TypeMappingAssemblyGenerator.cs @@ -1,7 +1,15 @@ +using System; using Xamarin.Android.Tasks.LLVMIR; +using Microsoft.Build.Utilities; + namespace Xamarin.Android.Tasks { abstract class TypeMappingAssemblyGenerator : LlvmIrComposer - {} + { + protected TypeMappingAssemblyGenerator (TaskLoggingHelper log) + : base (log) + { + } + } } diff --git a/src/Xamarin.Android.Build.Tasks/Utilities/TypeMappingDebugNativeAssemblyGenerator.cs b/src/Xamarin.Android.Build.Tasks/Utilities/TypeMappingDebugNativeAssemblyGenerator.cs index 2d9e3388475..3d047b206dc 100644 --- a/src/Xamarin.Android.Build.Tasks/Utilities/TypeMappingDebugNativeAssemblyGenerator.cs +++ b/src/Xamarin.Android.Build.Tasks/Utilities/TypeMappingDebugNativeAssemblyGenerator.cs @@ -1,6 +1,8 @@ using System; using System.Collections.Generic; +using Microsoft.Build.Utilities; + using Xamarin.Android.Tasks.LLVMIR; namespace Xamarin.Android.Tasks @@ -116,7 +118,8 @@ sealed class TypeMap List> managedToJavaMap; StructureInstance type_map; - public TypeMappingDebugNativeAssemblyGenerator (TypeMapGenerator.ModuleDebugData data) + public TypeMappingDebugNativeAssemblyGenerator (TaskLoggingHelper log, TypeMapGenerator.ModuleDebugData data) + : base (log) { this.data = data; diff --git a/src/Xamarin.Android.Build.Tasks/Utilities/TypeMappingReleaseNativeAssemblyGenerator.cs b/src/Xamarin.Android.Build.Tasks/Utilities/TypeMappingReleaseNativeAssemblyGenerator.cs index a6e4fd465df..ad1fe2dbf4b 100644 --- a/src/Xamarin.Android.Build.Tasks/Utilities/TypeMappingReleaseNativeAssemblyGenerator.cs +++ b/src/Xamarin.Android.Build.Tasks/Utilities/TypeMappingReleaseNativeAssemblyGenerator.cs @@ -4,6 +4,8 @@ using System.IO.Hashing; using System.Text; +using Microsoft.Build.Utilities; + using Xamarin.Android.Tasks.LLVMIR; namespace Xamarin.Android.Tasks @@ -176,7 +178,8 @@ sealed class ConstructionState ulong moduleCounter = 0; - public TypeMappingReleaseNativeAssemblyGenerator (NativeTypeMappingData mappingData) + public TypeMappingReleaseNativeAssemblyGenerator (TaskLoggingHelper log, NativeTypeMappingData mappingData) + : base (log) { this.mappingData = mappingData ?? throw new ArgumentNullException (nameof (mappingData)); javaNameHash32Comparer = new JavaNameHash32Comparer (); diff --git a/src/Xamarin.Android.Build.Tasks/Utilities/XAJavaTypeScanner.cs b/src/Xamarin.Android.Build.Tasks/Utilities/XAJavaTypeScanner.cs index 5f965ab46ff..4b82016eaa9 100644 --- a/src/Xamarin.Android.Build.Tasks/Utilities/XAJavaTypeScanner.cs +++ b/src/Xamarin.Android.Build.Tasks/Utilities/XAJavaTypeScanner.cs @@ -77,7 +77,7 @@ public List GetJavaTypes (ICollection inputAssemblies, XAAs void AddJavaType (TypeDefinition type, Dictionary types, AndroidTargetArch arch) { - if (type.IsSubclassOf ("Java.Lang.Object", cache) || type.IsSubclassOf ("Java.Lang.Throwable", cache) || (type.IsInterface && type.ImplementsInterface ("Java.Interop.IJavaPeerable", cache))) { + if (type.HasJavaPeer (cache)) { // For subclasses of e.g. Android.App.Activity. string typeName = type.GetPartialAssemblyQualifiedName (cache); if (!types.TryGetValue (typeName, out TypeData typeData)) {