Skip to content

Commit de49d96

Browse files
Check for ContainsGenericParameters
03-13 17:12:03.271 14568 14588 E NUnit : : System.NotSupportedException : 'Java.InteropTests.GenericHolder`1[T]' contains a generic type definition. This is not supported. 03-13 17:12:03.274 14568 14588 E NUnit : at Java.Interop.JniRuntime.JniTypeManager.GetTypeSignature(Type ) 03-13 17:12:03.274 14568 14588 E NUnit : at Android.Runtime.JNIEnv.GetJniName(Type ) 03-13 17:12:03.274 14568 14588 E NUnit : at Java.Interop.TypeManager.RegisterType(String , Type ) 03-13 17:12:03.274 14568 14588 E NUnit : at Android.Runtime.JNIEnvInit.RegisterJniNatives(IntPtr , Int32 , IntPtr , IntPtr , Int32 ) 03-13 17:12:03.274 14568 14588 E NUnit : at Java.Interop.JniEnvironment.Object.AllocObject(JniObjectReference ) 03-13 17:12:03.274 14568 14588 E NUnit : at Java.Interop.JniType.AllocObject() 03-13 17:12:03.274 14568 14588 E NUnit : at Java.Interop.JniPeerMembers.JniInstanceMethods.StartCreateInstance(String , Type , JniArgumentValue* ) 03-13 17:12:03.274 14568 14588 E NUnit : at Java.Lang.Object..ctor() 03-13 17:12:03.274 14568 14588 E NUnit : at Java.InteropTests.GenericHolder`1[[System.Int32, System.Private.CoreLib, Version=10.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]]..ctor() 03-13 17:12:03.274 14568 14588 E NUnit : at Java.InteropTests.JnienvTest.NewClosedGenericTypeWorks() 03-13 17:12:03.274 14568 14588 E NUnit : at System.Reflection.MethodBaseInvoker.InterpretedInvoke_Method(Object obj, IntPtr* args) 03-13 17:12:03.274 14568 14588 E NUnit : at System.Reflection.MethodBaseInvoker.InvokeWithNoArgs(Object , BindingFlags )
1 parent 790f79f commit de49d96

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/Mono.Android/Android.Runtime/JNIEnv.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -477,7 +477,10 @@ public static string GetJniName (Type type)
477477
if (type == null)
478478
throw new ArgumentNullException ("type");
479479

480-
var sig = JNIEnvInit.androidRuntime?.TypeManager.GetTypeSignature (type) ?? default;
480+
JniTypeSignature sig = default;
481+
if (!type.ContainsGenericParameters)
482+
sig = JNIEnvInit.androidRuntime?.TypeManager.GetTypeSignature (type) ?? default;
483+
481484
return sig == null
482485
? JavaNativeTypeManager.ToJniName (type)
483486
: sig.Name;

0 commit comments

Comments
 (0)