[runtime] Use mono_error_set_for_class_failure in more places
authorAleksey Kliger <aleksey@xamarin.com>
Wed, 28 Sep 2016 22:25:33 +0000 (18:25 -0400)
committerAleksey Kliger <aleksey@xamarin.com>
Wed, 28 Sep 2016 22:25:33 +0000 (18:25 -0400)
Also assert if we see anothing other than MONO_EXCEPTION_TYPE_LOAD or
MONO_EXCEPTION_INVALID_PROGRAM in a class failure.

mono/metadata/class.c
mono/mini/mini-runtime.c
mono/mini/mini.c

index d58d0f927d052206c5ce4272ff46a91facd64c0d..e1fc5acb86b5ff998a7b098a507f737ff248e88b 100644 (file)
@@ -1390,40 +1390,17 @@ mono_error_set_for_class_failure (MonoError *oerror, MonoClass *klass)
                mono_error_set_type_load_class (oerror, klass, "Error Loading class");
                return;
        }
-       case MONO_EXCEPTION_MISSING_METHOD: {
-               char *class_name = (char *)exception_data;
-               char *member_name = class_name + strlen (class_name) + 1;
-
-               mono_error_set_method_load (oerror, klass, member_name, "Error Loading Method");
-               return;
-       }
-       case MONO_EXCEPTION_MISSING_FIELD: {
-               char *class_name = (char *)exception_data;
-               char *member_name = class_name + strlen (class_name) + 1;
-
-               mono_error_set_field_load (oerror, klass, member_name, "Error Loading Field");
-               return;
-       }
-       case MONO_EXCEPTION_FILE_NOT_FOUND: {
-               char *msg_format = (char *)exception_data;
-               char *assembly_name = msg_format + strlen (msg_format) + 1;
-               char *msg = g_strdup_printf (msg_format, assembly_name);
-
-               mono_error_set_assembly_load (oerror, assembly_name, msg);
-               return;
-       }
-       case MONO_EXCEPTION_BAD_IMAGE: {
-               mono_error_set_bad_image (oerror, NULL, (const char *)exception_data);
-               return;
-       }
        case MONO_EXCEPTION_INVALID_PROGRAM: {
                mono_error_set_invalid_program (oerror, (const char *)exception_data);
                return;
        }
-       default: {
+       case MONO_EXCEPTION_MISSING_METHOD:
+       case MONO_EXCEPTION_MISSING_FIELD:
+       case MONO_EXCEPTION_FILE_NOT_FOUND:
+       case MONO_EXCEPTION_BAD_IMAGE:
+       default:
                g_assert_not_reached ();
        }
-       }
 }
 
 
index addb26bd446c5ad029797d2014b9ee49db71d602..231b44d65ecda7a9d32996d8283a86df082d2682 100644 (file)
@@ -2405,10 +2405,9 @@ mono_jit_runtime_invoke (MonoMethod *method, void *obj, void **params, MonoObjec
                         */
                        mono_class_setup_vtable (method->klass);
                        if (mono_class_has_failure (method->klass)) {
-                               MonoException *fail_exc = mono_class_get_exception_for_failure (method->klass);
+                               mono_error_set_for_class_failure (error, method->klass);
                                if (exc)
-                                       *exc = (MonoObject*)fail_exc;
-                               mono_error_set_exception_instance (error, fail_exc);
+                                       *exc = (MonoObject*)mono_class_get_exception_for_failure (method->klass);
                                return NULL;
                        }
                }
index 0dd4af7a71ede59872342fd943775750d3a50d52..ac92addeac2ad6de6f3fe5228a5bf6833bddf549 100644 (file)
@@ -4397,9 +4397,8 @@ mono_jit_compile_method_inner (MonoMethod *method, MonoDomain *target_domain, in
 
        vtable = mono_class_vtable (target_domain, method->klass);
        if (!vtable) {
-               ex = mono_class_get_exception_for_failure (method->klass);
-               g_assert (ex);
-               mono_error_set_exception_instance (error, ex);
+               g_assert (mono_class_has_failure (method->klass));
+               mono_error_set_for_class_failure (error, method->klass);
                return NULL;
        }