From 9d6876301752d142b982d8a38fe5f35738f175f6 Mon Sep 17 00:00:00 2001 From: Radek Doulik Date: Thu, 4 Feb 2021 17:52:54 +0100 Subject: [PATCH] Remove fallback code in GetJavaToManagedType Context: https://github.com/xamarin/xamarin-android/issues/5515 All the java to managed type names lookup is now handled by typemap, so we should not need this fallback anymore. This results in another nice apk size decrease. apk size difference in BuildReleaseArm64False/net6 test: Summary: - 21,877 Assemblies -3.03% (of 721,731) - 123,392 Uncompressed assemblies -8.24% (of 1,497,088) --- src/Mono.Android/Java.Interop/TypeManager.cs | 50 ++------------------ src/Mono.Android/Mono.Android.csproj | 6 ++- src/Mono.Android/Mono.Android.targets | 2 +- 3 files changed, 10 insertions(+), 48 deletions(-) diff --git a/src/Mono.Android/Java.Interop/TypeManager.cs b/src/Mono.Android/Java.Interop/TypeManager.cs index 2a8be4c2f81..cce37dde0ba 100644 --- a/src/Mono.Android/Java.Interop/TypeManager.cs +++ b/src/Mono.Android/Java.Interop/TypeManager.cs @@ -218,29 +218,9 @@ static Exception CreateJavaLocationException () if (type != null) return type; - if (!JNIEnv.IsRunningOnDesktop) { - // Miss message is logged in the native runtime - if (JNIEnv.LogTypemapMissStackTrace) - JNIEnv.LogTypemapTrace (new System.Diagnostics.StackTrace (true)); - return null; - } + if (!JNIEnv.IsRunningOnDesktop && JNIEnv.LogTypemapMissStackTrace) + JNIEnv.LogTypemapTrace (new System.Diagnostics.StackTrace (true)); - __TypeRegistrations.RegisterPackages (); - - type = null; - int ls = class_name.LastIndexOf ('/'); - var package = ls >= 0 ? class_name.Substring (0, ls) : ""; - if (packageLookup.TryGetValue (package, out var mappers)) { - foreach (Converter c in mappers) { - type = c (class_name); - if (type == null) - continue; - return type; - } - } - if ((type = Type.GetType (JavaNativeTypeManager.ToCliType (class_name))) != null) { - return type; - } return null; } @@ -353,36 +333,14 @@ public static void RegisterType (string java_class, Type t) } } - static Dictionary>> packageLookup = new Dictionary>> (); - public static void RegisterPackage (string package, Converter lookup) { - lock (packageLookup) { - if (!packageLookup.TryGetValue (package, out var lookups)) - packageLookup.Add (package, lookups = new List> ()); - lookups.Add (lookup); - } + throw new NotImplementedException (); } public static void RegisterPackages (string[] packages, Converter[] lookups) { - if (packages == null) - throw new ArgumentNullException ("packages"); - if (lookups == null) - throw new ArgumentNullException ("lookups"); - if (packages.Length != lookups.Length) - throw new ArgumentException ("`packages` and `lookups` arrays must have same number of elements."); - - lock (packageLookup) { - for (int i = 0; i < packages.Length; ++i) { - string package = packages [i]; - var lookup = lookups [i]; - - if (!packageLookup.TryGetValue (package, out var _lookups)) - packageLookup.Add (package, _lookups = new List> ()); - _lookups.Add (lookup); - } - } + throw new NotImplementedException (); } [Register ("mono/android/TypeManager", DoNotGenerateAcw = true)] diff --git a/src/Mono.Android/Mono.Android.csproj b/src/Mono.Android/Mono.Android.csproj index 21378536fec..e3faf6cc7ea 100644 --- a/src/Mono.Android/Mono.Android.csproj +++ b/src/Mono.Android/Mono.Android.csproj @@ -120,7 +120,11 @@ - + + + + + diff --git a/src/Mono.Android/Mono.Android.targets b/src/Mono.Android/Mono.Android.targets index 98364ae33dd..c2668253eb4 100644 --- a/src/Mono.Android/Mono.Android.targets +++ b/src/Mono.Android/Mono.Android.targets @@ -167,7 +167,7 @@ IgnoreStandardErrorWarningFormat="True" /> - +