2002-07-21 Miguel de Icaza <miguel@ximian.com>
authorMiguel de Icaza <miguel@gnome.org>
Mon, 22 Jul 2002 03:31:25 +0000 (03:31 -0000)
committerMiguel de Icaza <miguel@gnome.org>
Mon, 22 Jul 2002 03:31:25 +0000 (03:31 -0000)
* appdomain.c (ves_icall_System_Reflection_Assembly_LoadFrom): Use
mono_get_exception_file_not_found now.

* exception.c (mono_exception_from_name_two_strings): New version
that will call a constructor with two string arguments.
(mono_get_exception_file_not_found): New helper routine, used to
report file-not-found errors.

2002-07-21  Miguel de Icaza  <miguel@ximian.com>

* exception.c (arch_handle_exception): Memory leak fix.

svn path=/trunk/mono/; revision=6001

mono/jit/ChangeLog
mono/jit/exception.c
mono/metadata/ChangeLog
mono/metadata/appdomain.c
mono/metadata/exception.c
mono/metadata/exception.h
mono/metadata/marshal.c

index 95b9961a0c02ad0b51e8ef8ac2882070f58799f7..ce96462da53955496e0ab9370e06c23a451f2153 100644 (file)
@@ -1,3 +1,7 @@
+2002-07-21  Miguel de Icaza  <miguel@ximian.com>
+
+       * exception.c (arch_handle_exception): Memory leak fix.
+
 2002-07-19  Dietmar Maurer  <dietmar@ximian.com>
 
        * jit.c (mono_analyze_stack): avoid recursive inlining
index 3168f793337230f6526bf1eeeed6e1ab753c1d58..1fa397d9a386b0ac28737ee6b0731d3f82200d66 100644 (file)
@@ -431,6 +431,7 @@ arch_handle_exception (struct sigcontext *ctx, gpointer obj, gboolean test_only)
                                g_free (fname);
                                g_free (source_location);
                                g_free (strace);
+                               g_free (tmpaddr);
 
                                ((MonoException*)obj)->stack_trace = mono_string_new (domain, tmp);
 
index c8fc861f148763b0fd9dde2b1d852dd6353a95e8..9873b3a3d9aa017bbfec911da626c15c9245e4ca 100644 (file)
@@ -1,3 +1,13 @@
+2002-07-21  Miguel de Icaza  <miguel@ximian.com>
+
+       * appdomain.c (ves_icall_System_Reflection_Assembly_LoadFrom): Use
+       mono_get_exception_file_not_found now.
+
+       * exception.c (mono_exception_from_name_two_strings): New version
+       that will call a constructor with two string arguments. 
+       (mono_get_exception_file_not_found): New helper routine, used to
+       report file-not-found errors.
+
 2002-07-20  Dick Porter  <dick@ximian.com>
 
        * process.h:
index d44c3d14f86e7537f2ff5098a65e720211a2230f..6ddee7167e6669805af9b9957a0f4021d62236b1 100644 (file)
@@ -321,8 +321,10 @@ ves_icall_System_Reflection_Assembly_LoadFrom (MonoString *fname)
        
        g_free (name);
 
-       if (!ass)
-               mono_raise_exception ((MonoException *)mono_exception_from_name (mono_defaults.corlib, "System.IO", "FileNotFoundException"));
+       if (!ass){
+               MonoException *exc = mono_get_exception_file_not_found (fname);
+               mono_raise_exception (exc);
+       }
 
        return mono_assembly_get_object (domain, ass);
 }
index 3ed2b9952e80e5341f1778d8bbda090054d7262e..d9675a5a44f504fc5a9313d8629878234a807131 100644 (file)
@@ -2,17 +2,29 @@
  * exception.c: Exception handling
  *
  * Authors:
- *     Paolo Molaro (lupus@ximian.com)
- *     Dietmar Maurer (dietmar@ximian.com)
- *     Dick Porter (dick@ximian.com)
+ *     Paolo Molaro    (lupus@ximian.com)
+ *     Dietmar Maurer  (dietmar@ximian.com)
+ *     Dick Porter     (dick@ximian.com)
+ *      Miguel de Icaza (miguel@ximian.com)
  *
- * (C) 2001 Ximian, Inc.
+ * (C) 2001, 2002 Ximian, Inc.
  */
 
 #include <mono/metadata/exception.h>
 #include <mono/metadata/class.h>
 #include <mono/metadata/appdomain.h>
+#include <string.h>
 
+/**
+ * mono_exception_from_name:
+ * @image: the Mono image where to look for the class
+ * @name_space: the namespace for the class
+ * @name: class name
+ *
+ * Creates an exception of the given namespace/name class.
+ *
+ * Returns: the initialized exception instance.
+ */
 MonoException *
 mono_exception_from_name (MonoImage *image, const char *name_space,
                          const char *name)
@@ -31,6 +43,54 @@ mono_exception_from_name (MonoImage *image, const char *name_space,
        return (MonoException *)o;
 }
 
+/**
+ * mono_exception_from_name_two_strings:
+ * @image: the Mono image where to look for the class
+ * @name_space: the namespace for the class
+ * @name: class name
+ * @a1: first string argument to pass
+ * @a2: second string argument to pass
+ *
+ * Creates an exception from a constructor that takes two string
+ * arguments.
+ *
+ * Returns: the initialized exception instance.
+ */
+static MonoException *
+mono_exception_from_name_two_strings (MonoImage *image, const char *name_space,
+                                     const char *name, MonoString *a1, MonoString *a2)
+{
+       MonoDomain *domain = mono_domain_get ();
+       MonoClass *klass;
+       MonoMethod *method = NULL;
+       MonoObject *o;
+       int i;
+       gpointer args [2];
+       
+       klass = mono_class_from_name (image, name_space, name);
+       o = mono_object_new (domain, klass);
+
+       for (i = 0; i < klass->method.count; ++i) {
+               MonoMethodSignature *sig;
+               
+               if (strcmp (".ctor", klass->methods [i]->name))
+                       continue;
+               sig = klass->methods [i]->signature;
+               if (sig->param_count != 2)
+                       continue;
+
+               if (sig->params [0]->type != MONO_TYPE_STRING ||
+                   sig->params [1]->type != MONO_TYPE_STRING)
+                       continue;
+               method = klass->methods [i];
+       }
+
+       args [0] = a1;
+       args [1] = a2;
+       mono_runtime_invoke (method, o, args, NULL);
+       return (MonoException *) o;
+}
+
 MonoException *
 mono_get_exception_divide_by_zero ()
 {
@@ -198,4 +258,10 @@ mono_get_exception_io (const guchar *msg)
        return(ex);
 }
 
+MonoException *
+mono_get_exception_file_not_found (MonoString *fname)
+{
+       return mono_exception_from_name_two_strings (
+               mono_defaults.corlib, "System.IO", "FileNotFoundException", fname, fname);
+}
 
index 81bbc2206ae2ca9219bedc0cfafb546d20afda1e..5836ec1d86688558c8dc6726505031b475d01ab7 100644 (file)
@@ -62,6 +62,9 @@ MonoException *
 mono_get_exception_argument_out_of_range (const guchar *arg);
 
 MonoException *
-mono_get_exception_io                  (const guchar *msg);
+mono_get_exception_io                    (const guchar *msg);
+
+MonoException *
+mono_get_exception_file_not_found        (MonoString *fname);
 
 #endif /* _MONO_METADATA_EXCEPTION_H_ */
index 8c93c8da69233e011e1d5b499029f9bfea10194f..f013784dd69ee7c7dbfd7e6dc19a28a1a15a84eb 100644 (file)
@@ -17,6 +17,7 @@
 #include "metadata/appdomain.h"
 #include "mono/metadata/debug-helpers.h"
 #include "mono/metadata/threadpool.h"
+#include <string.h>
 
 //#define DEBUG_RUNTIME_CODE