From 2474423f5d497cbdce72b41aecb2177c9280a239 Mon Sep 17 00:00:00 2001 From: MASES Public Developers Team <94312179+masesdevelopers@users.noreply.github.com> Date: Sun, 28 Jul 2024 04:25:59 +0200 Subject: [PATCH] Fixed NullReferenceException (#490) --- src/net/JNetReflector/InternalExtensions.cs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/net/JNetReflector/InternalExtensions.cs b/src/net/JNetReflector/InternalExtensions.cs index 6ecdbbf5f1..cfce1c76fe 100644 --- a/src/net/JNetReflector/InternalExtensions.cs +++ b/src/net/JNetReflector/InternalExtensions.cs @@ -738,8 +738,8 @@ static void GetGenerics(this Java.Lang.Reflect.Type[] entries, IList gen static string GetBound(this Java.Lang.Reflect.Type bound, bool usedInGenerics, bool camel, string parentTypeName) { var bClass = bound.TypeName.JVMClass(); - if (bClass.IsClassToAvoid()) return string.Empty; - string result; + if (bClass != null && bClass.IsClassToAvoid()) return string.Empty; + string result = string.Empty; if (bClass != null && bClass.IsInterface()) { result = bClass.JVMInterfaceName(new List>(), usedInGenerics, true) + AllPackageClasses.WHERE_CLAUSE_NEW; // the new constraint means the type shall be a class implementing the interface @@ -750,7 +750,10 @@ static string GetBound(this Java.Lang.Reflect.Type bound, bool usedInGenerics, b var cName = bound.TypeName; cName = cName.Contains('<') ? cName.Substring(0, cName.IndexOf('<')) : cName; bClass = cName.JVMClass(); - result = bClass.ToFullQualifiedClassName(usedInGenerics, camel, parentTypeName); + if (bClass != null && !bClass.IsClassToAvoid()) + { + result = bClass.ToFullQualifiedClassName(usedInGenerics, camel, parentTypeName); + } } else if (bound.IsParameterizedTypeWithoutGenerics()) {