[runtime] Mark mono_exception_from_token_two_strings external only
authorAleksey Kliger <aleksey@xamarin.com>
Thu, 2 Jun 2016 19:29:12 +0000 (15:29 -0400)
committerAleksey Kliger <aleksey@xamarin.com>
Thu, 2 Jun 2016 19:56:02 +0000 (15:56 -0400)
Runtime should use mono_exception_from_token_two_strings_checked

mono/metadata/exception-internals.h
mono/metadata/exception.c
mono/metadata/exception.h
mono/mini/jit-icalls.c

index a606e79b57ddc5834b7127b6d95e3262741d52da..4a9ad505798ee867cfab121d1afcf84069b6d44a 100644 (file)
@@ -20,4 +20,9 @@ mono_exception_from_name_two_strings_checked (MonoImage *image, const char *name
                                              const char *name, MonoString *a1, MonoString *a2,
                                              MonoError *error);
 
+MonoException *
+mono_exception_from_token_two_strings_checked (MonoImage *image, uint32_t token,
+                                              MonoString *a1, MonoString *a2,
+                                              MonoError *error);
+
 #endif
index 76f70a3dcfc7e0a0a0c9994186aad2998b18a35e..2aff26dfd53788fe5080ef51e97cbaf0b9975045 100644 (file)
@@ -245,16 +245,31 @@ mono_exception_from_token_two_strings (MonoImage *image, guint32 token,
                                                                           MonoString *a1, MonoString *a2)
 {
        MonoError error;
-       MonoClass *klass;
        MonoException *ret;
+       ret = mono_exception_from_token_two_strings_checked (image, token, a1, a2, &error);
+       mono_error_cleanup (&error);
+       return ret;
+}
 
-       klass = mono_class_get_checked (image, token, &error);
-       mono_error_assert_ok (&error); /* FIXME handle the error. */
+/**
+ * mono_exception_from_token_two_strings_checked:
+ *
+ *   Same as mono_exception_from_name_two_strings, but lookup the exception class using
+ * IMAGE and TOKEN.
+ */
+MonoException *
+mono_exception_from_token_two_strings_checked (MonoImage *image, guint32 token,
+                                              MonoString *a1, MonoString *a2,
+                                              MonoError *error)
+{
+       MonoClass *klass;
 
-       ret = create_exception_two_strings (klass, a1, a2, &error);
-       mono_error_raise_exception (&error); /* FIXME don't raise here */
+       mono_error_init (error);
 
-       return ret;
+       klass = mono_class_get_checked (image, token, error);
+       mono_error_assert_ok (error); /* FIXME handle the error. */
+
+       return create_exception_two_strings (klass, a1, a2, error);
 }
 
 /**
index 261bd92c6c9cc701b05226e378696e742ff58e3a..3de5ae7ff57681981cf95a766105308ab2cacc79 100644 (file)
@@ -23,6 +23,7 @@ MONO_API MonoException *
 mono_exception_from_name_msg          (MonoImage *image, const char *name_space,
                                        const char *name, const char *msg);
 
+MONO_RT_EXTERNAL_ONLY
 MONO_API MonoException *
 mono_exception_from_token_two_strings (MonoImage *image, uint32_t token,
                                                   MonoString *a1, MonoString *a2);
index 39abeb285497461e407cb5f3f1bfb3dd0fa96d7b..1735b3cc979f4fb9388e866b40d3695282076d08 100644 (file)
@@ -19,6 +19,7 @@
 
 #include "jit-icalls.h"
 #include <mono/utils/mono-error-internals.h>
+#include <mono/metadata/exception-internals.h>
 #include <mono/metadata/threads-types.h>
 #include <mono/metadata/reflection-internals.h>
 
@@ -1189,13 +1190,21 @@ mono_create_corlib_exception_0 (guint32 token)
 MonoException *
 mono_create_corlib_exception_1 (guint32 token, MonoString *arg)
 {
-       return mono_exception_from_token_two_strings (mono_defaults.corlib, token, arg, NULL);
+       MonoError error;
+       MonoException *ret = mono_exception_from_token_two_strings_checked (
+               mono_defaults.corlib, token, arg, NULL, &error);
+       mono_error_set_pending_exception (&error);
+       return ret;
 }
 
 MonoException *
 mono_create_corlib_exception_2 (guint32 token, MonoString *arg1, MonoString *arg2)
 {
-       return mono_exception_from_token_two_strings (mono_defaults.corlib, token, arg1, arg2);
+       MonoError error;
+       MonoException *ret = mono_exception_from_token_two_strings_checked (
+               mono_defaults.corlib, token, arg1, arg2, &error);
+       mono_error_set_pending_exception (&error);
+       return ret;
 }
 
 MonoObject*