Пример #1
0
        private static Exception MapTypeInitializeException(TypeInitializationException t, Type handler)
        {
#if FIRST_PASS
            return(null);
#else
            bool      wrapped = false;
            Exception r       = MapException <Exception>(t.InnerException, true, false);
            if (!(r is java.lang.Error))
            {
                // Forwarding "r" as cause only doesn't make it available in the debugger details
                // of current versions of VS, so at least provide a text representation instead.
                // Not wrapping at all might be the even better approach, but it was introduced for
                // some reason I guess.
                r       = new java.lang.ExceptionInInitializerError(r.ToString());
                wrapped = true;
            }
            string type = t.TypeName;
            if (failedTypes.ContainsKey(type))
            {
                r       = new java.lang.NoClassDefFoundError("Could not initialize class " + type);
                wrapped = true;
            }
            if (handler != null && !handler.IsInstanceOfType(r))
            {
                return(null);
            }
            failedTypes[type] = type;
            if (wrapped)
            {
                // transplant the stack trace
                ((Throwable)r).setStackTrace(new ExceptionInfoHelper(t, true).get_StackTrace(t));
            }
            return(r);
#endif
        }
Пример #2
0
        private static Exception MapTypeInitializeException(TypeInitializationException t, Type handler)
        {
#if FIRST_PASS
            return(null);
#else
            bool      wrapped = false;
            Exception r       = MapException <Exception>(t.InnerException, true, false);
            if (!(r is java.lang.Error))
            {
                r       = new java.lang.ExceptionInInitializerError(r);
                wrapped = true;
            }
            string type = t.TypeName;
            if (failedTypes.ContainsKey(type))
            {
                r       = new java.lang.NoClassDefFoundError("Could not initialize class " + type);
                wrapped = true;
            }
            if (handler != null && !handler.IsInstanceOfType(r))
            {
                return(null);
            }
            failedTypes[type] = type;
            if (wrapped)
            {
                // transplant the stack trace
                ((Throwable)r).setStackTrace(new ExceptionInfoHelper(t, true).get_StackTrace(t));
            }
            return(r);
#endif
        }