From 9c6331cd5d79088161cd62ddd013d81a43a4c461 Mon Sep 17 00:00:00 2001 From: Rodrigo Kumpera Date: Mon, 16 Nov 2015 00:22:56 -0500 Subject: [PATCH] [runtime] Switch probing usage of mono_class_from_name to mono_class_try_load_from_name. Those are call sites that can handle missing types correctly. --- mono/metadata/console-unix.c | 2 +- mono/metadata/debug-helpers.c | 2 +- mono/mini/aot-compiler.c | 14 ++++++++------ 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/mono/metadata/console-unix.c b/mono/metadata/console-unix.c index 5a4d518c230..f2105335356 100644 --- a/mono/metadata/console-unix.c +++ b/mono/metadata/console-unix.c @@ -231,7 +231,7 @@ do_console_cancel_event (void) if (!domain->domain) return; - klass = mono_class_from_name (mono_defaults.corlib, "System", "Console"); + klass = mono_class_try_load_from_name (mono_defaults.corlib, "System", "Console"); if (klass == NULL) return; diff --git a/mono/metadata/debug-helpers.c b/mono/metadata/debug-helpers.c index 86c3965365f..df32fb052af 100644 --- a/mono/metadata/debug-helpers.c +++ b/mono/metadata/debug-helpers.c @@ -538,7 +538,7 @@ mono_method_desc_search_in_image (MonoMethodDesc *desc, MonoImage *image) } if (desc->name_space && desc->klass) { - klass = mono_class_from_name (image, desc->name_space, desc->klass); + klass = mono_class_try_load_from_name (image, desc->name_space, desc->klass); if (!klass) return NULL; return mono_method_desc_search_in_class (desc, klass); diff --git a/mono/mini/aot-compiler.c b/mono/mini/aot-compiler.c index 80aec7e2163..5d0cd89cfeb 100644 --- a/mono/mini/aot-compiler.c +++ b/mono/mini/aot-compiler.c @@ -4557,10 +4557,10 @@ add_generic_instances (MonoAotCompile *acfg) insts [ninsts ++] = &mono_defaults.boolean_class->byval_arg; /* Add GenericComparer instances for primitive types for Enum.ToString () */ - klass = mono_class_from_name (acfg->image, "System.Collections.Generic", "GenericComparer`1"); + klass = mono_class_try_load_from_name (acfg->image, "System.Collections.Generic", "GenericComparer`1"); if (klass) add_instances_of (acfg, klass, insts, ninsts, TRUE); - klass = mono_class_from_name (acfg->image, "System.Collections.Generic", "GenericEqualityComparer`1"); + klass = mono_class_try_load_from_name (acfg->image, "System.Collections.Generic", "GenericEqualityComparer`1"); if (klass) add_instances_of (acfg, klass, insts, ninsts, TRUE); @@ -4597,13 +4597,15 @@ add_generic_instances (MonoAotCompile *acfg) /* Add instances of the array generic interfaces for primitive types */ /* This will add instances of the InternalArray_ helper methods in Array too */ - klass = mono_class_from_name (acfg->image, "System.Collections.Generic", "ICollection`1"); + klass = mono_class_try_load_from_name (acfg->image, "System.Collections.Generic", "ICollection`1"); if (klass) add_instances_of (acfg, klass, insts, ninsts, TRUE); - klass = mono_class_from_name (acfg->image, "System.Collections.Generic", "IList`1"); + + klass = mono_class_try_load_from_name (acfg->image, "System.Collections.Generic", "IList`1"); if (klass) add_instances_of (acfg, klass, insts, ninsts, TRUE); - klass = mono_class_from_name (acfg->image, "System.Collections.Generic", "IEnumerable`1"); + + klass = mono_class_try_load_from_name (acfg->image, "System.Collections.Generic", "IEnumerable`1"); if (klass) add_instances_of (acfg, klass, insts, ninsts, TRUE); @@ -4654,7 +4656,7 @@ add_generic_instances (MonoAotCompile *acfg) MonoGenericContext ctx; MonoType *args [16]; MonoMethod *m; - MonoClass *volatile_klass = mono_class_from_name (mono_defaults.corlib, "System.Threading", "Volatile"); + MonoClass *volatile_klass = mono_class_try_load_from_name (mono_defaults.corlib, "System.Threading", "Volatile"); gpointer iter = NULL; if (volatile_klass) { -- 2.11.4.GIT