예제 #1
0
        internal static void readObject(Exception x, ObjectInputStream s)
        {
#if !FIRST_PASS
            ObjectInputStream.GetField fields = s.readFields();
            initThrowable(x, fields.get("detailMessage", null), fields.get("cause", null));
            StackTraceElement[] stackTrace = (StackTraceElement[])fields.get("stackTrace", null);
            Throwable.instancehelper_setStackTrace(x, stackTrace == null ? new StackTraceElement[0] : stackTrace);
#endif
        }
예제 #2
0
        internal static void readObject(Exception x, ObjectInputStream s)
        {
#if !FIRST_PASS
            lock (x)
            {
                // when you serialize a .NET exception it gets replaced by a com.sun.xml.internal.ws.developer.ServerSideException,
                // so we know that Exception is always a Throwable
                Throwable _this = (Throwable)x;

                // this the equivalent of s.defaultReadObject();
                ObjectInputStream.GetField fields = s.readFields();
                object          detailMessage     = fields.get("detailMessage", null);
                object          cause             = fields.get("cause", null);
                ConstructorInfo ctor = typeof(Throwable).GetConstructor(BindingFlags.NonPublic | BindingFlags.Instance, null, new Type[] { typeof(string), typeof(Exception), typeof(bool), typeof(bool) }, null);
                if (cause == _this)
                {
                    ctor.Invoke(_this, new object[] { detailMessage, null, false, false });
                    _this.cause = _this;
                }
                else
                {
                    ctor.Invoke(_this, new object[] { detailMessage, cause, false, false });
                }
                _this.stackTrace           = (StackTraceElement[])fields.get("stackTrace", null);
                _this.suppressedExceptions = (java.util.List)fields.get("suppressedExceptions", null);

                // this is where the rest of the Throwable.readObject() code starts
                if (_this.suppressedExceptions != null)
                {
                    java.util.List suppressed = null;
                    if (_this.suppressedExceptions.isEmpty())
                    {
                        suppressed = Throwable.SUPPRESSED_SENTINEL;
                    }
                    else
                    {
                        suppressed = new java.util.ArrayList(1);
                        for (int i = 0; i < _this.suppressedExceptions.size(); i++)
                        {
                            Exception entry = (Exception)_this.suppressedExceptions.get(i);
                            if (entry == null)
                            {
                                throw new java.lang.NullPointerException("Cannot suppress a null exception.");
                            }
                            if (entry == _this)
                            {
                                throw new java.lang.IllegalArgumentException("Self-suppression not permitted");
                            }
                            suppressed.add(entry);
                        }
                    }
                    _this.suppressedExceptions = suppressed;
                }

                if (_this.stackTrace != null)
                {
                    if (_this.stackTrace.Length == 0)
                    {
                        _this.stackTrace = new StackTraceElement[0];
                    }
                    else if (_this.stackTrace.Length == 1 &&
                             java.lang.ThrowableHelper.SentinelHolder.STACK_TRACE_ELEMENT_SENTINEL.equals(_this.stackTrace[0]))
                    {
                        _this.stackTrace = null;
                    }
                    else
                    {
                        foreach (StackTraceElement elem in _this.stackTrace)
                        {
                            if (elem == null)
                            {
                                throw new java.lang.NullPointerException("null StackTraceElement in serial stream. ");
                            }
                        }
                    }
                }
                else
                {
                    _this.stackTrace = new StackTraceElement[0];
                }
            }
#endif
        }