Author: zoltan
Date: 2006-06-08 10:49:54 -0400 (Thu, 08 Jun 2006)
New Revision: 61573

Modified:
   trunk/mono/mono/metadata/ChangeLog
   trunk/mono/mono/metadata/class.c
   trunk/mono/mono/metadata/icall.c
   trunk/mono/mono/metadata/loader.c
Log:
2006-06-08  Zoltan Varga  <[EMAIL PROTECTED]>

        * icall.c (mono_class_get_throw): Fix a warning.
        (ves_icall_System_Reflection_Assembly_GetTypes): Allways throw 
        ReflectionTypeLoadException if needed. Fixes #78606.

        * class.c (mono_class_setup_vtable_general): Handle loader errors a bit 
better.
        (mono_class_init): Ditto.

        * loader.c (mono_loader_set_error_assembly_load): Display a separate 
warning for
        ref_only exceptions.
        (mono_loader_clear_error): Make this work even if there is no error.


Modified: trunk/mono/mono/metadata/ChangeLog
===================================================================
--- trunk/mono/mono/metadata/ChangeLog  2006-06-08 14:48:28 UTC (rev 61572)
+++ trunk/mono/mono/metadata/ChangeLog  2006-06-08 14:49:54 UTC (rev 61573)
@@ -1,3 +1,16 @@
+2006-06-08  Zoltan Varga  <[EMAIL PROTECTED]>
+
+       * icall.c (mono_class_get_throw): Fix a warning.
+       (ves_icall_System_Reflection_Assembly_GetTypes): Allways throw 
+       ReflectionTypeLoadException if needed. Fixes #78606.
+
+       * class.c (mono_class_setup_vtable_general): Handle loader errors a bit 
better.
+       (mono_class_init): Ditto.
+
+       * loader.c (mono_loader_set_error_assembly_load): Display a separate 
warning for
+       ref_only exceptions.
+       (mono_loader_clear_error): Make this work even if there is no error.
+
 2006-06-08  Jonathan Chambers  <[EMAIL PROTECTED]>
 
        * object-internals.h marshal.c marshal.h icall.c: Implement method 

Modified: trunk/mono/mono/metadata/class.c
===================================================================
--- trunk/mono/mono/metadata/class.c    2006-06-08 14:48:28 UTC (rev 61572)
+++ trunk/mono/mono/metadata/class.c    2006-06-08 14:49:54 UTC (rev 61573)
@@ -2075,10 +2075,21 @@
                                int j;
                                for (j = 0; j < k->method.count; ++j) {
                                        MonoMethod *m1 = k->methods [j];
+                                       MonoMethodSignature *cmsig, *m1sig;
+
                                        if (!(m1->flags & 
METHOD_ATTRIBUTE_VIRTUAL))
                                                continue;
+
+                                       cmsig = mono_method_signature (cm);
+                                       m1sig = mono_method_signature (m1);
+
+                                       if (!cmsig || !m1sig) {
+                                               mono_class_set_failure (class, 
MONO_EXCEPTION_TYPE_LOAD, NULL);
+                                               return;
+                                       }
+
                                        if (!strcmp(cm->name, m1->name) && 
-                                           mono_metadata_signature_equal 
(mono_method_signature (cm), mono_method_signature (m1))) {
+                                           mono_metadata_signature_equal 
(cmsig, m1sig)) {
 
                                                /* CAS - 
SecurityAction.InheritanceDemand */
                                                if (security_enabled && 
(m1->flags & METHOD_ATTRIBUTE_HAS_SECURITY)) {
@@ -2439,7 +2450,12 @@
        }
        else {
                mono_class_setup_vtable (class);
-       
+
+               if (class->exception_type || mono_loader_get_last_error ()){
+                       class_init_ok = FALSE;
+                       goto leave;
+               }
+
                class->ghcimpl = 1;
                if (class->parent) { 
                        MonoMethod *cmethod = class->vtable [ghc_slot];

Modified: trunk/mono/mono/metadata/icall.c
===================================================================
--- trunk/mono/mono/metadata/icall.c    2006-06-08 14:48:28 UTC (rev 61572)
+++ trunk/mono/mono/metadata/icall.c    2006-06-08 14:49:54 UTC (rev 61573)
@@ -100,7 +100,7 @@
        MonoException *ex;
        
        if (class != NULL){
-               if (class->exception_type != NULL){
+               if (class->exception_type) {
                        MonoException *exc = 
mono_class_get_exception_for_failure (class);
                        g_assert (exc);
                        mono_raise_exception (exc);
@@ -4532,6 +4532,8 @@
                visibility = attrs & TYPE_ATTRIBUTE_VISIBILITY_MASK;
                if (!exportedOnly || (visibility == TYPE_ATTRIBUTE_PUBLIC || 
visibility == TYPE_ATTRIBUTE_NESTED_PUBLIC)) {
                        klass = mono_class_get_throw (image, (i + 1) | 
MONO_TOKEN_TYPE_DEF);
+                       if (mono_loader_get_last_error ())
+                               mono_loader_clear_error ();
                        mono_array_setref (res, count, mono_type_get_object 
(domain, &klass->byval_arg));
                        count++;
                }
@@ -4547,7 +4549,8 @@
        MonoImage *image = NULL;
        MonoTableInfo *table = NULL;
        MonoDomain *domain;
-       int i;
+       GList *list = NULL;
+       int i, len;
 
        MONO_ARCH_SAVE_REGS;
 
@@ -4632,42 +4635,41 @@
                }
        }
 
-       if (mono_is_security_manager_active ()) {
-               /* the ReflectionTypeLoadException must have all the types 
(Types property), 
-                * NULL replacing types which throws an exception. The 
LoaderException must
-                * contains all exceptions for NULL items.
-                */
+       /* the ReflectionTypeLoadException must have all the types (Types 
property), 
+        * NULL replacing types which throws an exception. The LoaderException 
must
+        * contain all exceptions for NULL items.
+        */
 
-               guint32 len = mono_array_length (res);
-               GList *list = NULL;
+       len = mono_array_length (res);
 
-               for (i = 0; i < len; i++) {
-                       MonoReflectionType *t = mono_array_get (res, gpointer, 
i);
-                       MonoClass *klass = mono_type_get_class (t->type);
-                       if ((klass != NULL) && klass->exception_type) {
-                               /* keep the class in the list */
-                               list = g_list_append (list, klass);
-                               /* and replace Type with NULL */
-                               mono_array_setref (res, i, NULL);
-                       }
+       for (i = 0; i < len; i++) {
+               MonoReflectionType *t = mono_array_get (res, gpointer, i);
+               MonoClass *klass = mono_type_get_class (t->type);
+               if ((klass != NULL) && klass->exception_type) {
+                       /* keep the class in the list */
+                       list = g_list_append (list, klass);
+                       /* and replace Type with NULL */
+                       mono_array_setref (res, i, NULL);
                }
+       }
 
-               if (list) {
-                       GList *tmp = NULL;
-                       MonoException *exc = NULL;
-                       int length = g_list_length (list);
+       if (list) {
+               GList *tmp = NULL;
+               MonoException *exc = NULL;
+               int length = g_list_length (list);
 
-                       MonoArray *exl = mono_array_new (domain, 
mono_defaults.exception_class, length);
-                       for (i = 0, tmp = list; i < length; i++, tmp = 
tmp->next) {
-                               MonoException *exc = 
mono_class_get_exception_for_failure (tmp->data);
-                               mono_array_setref (exl, i, exc);
-                       }
-                       g_list_free (list);
-                       list = NULL;
+               mono_loader_clear_error ();
 
-                       exc = mono_get_exception_reflection_type_load (res, 
exl);
-                       mono_raise_exception (exc);
+               MonoArray *exl = mono_array_new (domain, 
mono_defaults.exception_class, length);
+               for (i = 0, tmp = list; i < length; i++, tmp = tmp->next) {
+                       MonoException *exc = 
mono_class_get_exception_for_failure (tmp->data);
+                       mono_array_setref (exl, i, exc);
                }
+               g_list_free (list);
+               list = NULL;
+
+               exc = mono_get_exception_reflection_type_load (res, exl);
+               mono_raise_exception (exc);
        }
                
        return res;

Modified: trunk/mono/mono/metadata/loader.c
===================================================================
--- trunk/mono/mono/metadata/loader.c   2006-06-08 14:48:28 UTC (rev 61572)
+++ trunk/mono/mono/metadata/loader.c   2006-06-08 14:49:54 UTC (rev 61573)
@@ -107,7 +107,10 @@
         * can't deal with load errors, and this message is more helpful than an
         * assert.
         */
-       g_warning ("Could not load file or assembly '%s' or one of its 
dependencies.", assembly_name);
+       if (ref_only)
+               g_warning ("Cannot resolve dependency to assembly '%s' because 
it has not been preloaded. When using the ReflectionOnly APIs, dependent 
assemblies must be pre-loaded or loaded on demand through the 
ReflectionOnlyAssemblyResolve event.", assembly_name);
+       else
+               g_warning ("Could not load file or assembly '%s' or one of its 
dependencies.", assembly_name);
 
        set_loader_error (error);
 }
@@ -208,11 +211,13 @@
 {
        MonoLoaderError *ex = (MonoLoaderError*)TlsGetValue 
(loader_error_thread_id);
 
+       if (ex) {
         g_free (ex->class_name);
         g_free (ex->assembly_name);
-       g_free (ex);
+               g_free (ex);
        
-       TlsSetValue (loader_error_thread_id, NULL);
+               TlsSetValue (loader_error_thread_id, NULL);
+       }
 }
 
 /**

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to