src/share/classes/java/lang/Throwable.java
Print this page
@@ -956,22 +956,19 @@
// Ensure that the stackTrace field is initialized to a
// non-null value, if appropriate. As of JDK 7, a null stack
// trace field is a valid value indicating the stack trace
// should not be set.
getOurStackTrace();
- ObjectOutputStream.PutField fields = s.putFields();
- fields.put("detailMessage", detailMessage);
- fields.put("cause", cause);
- // Serialize a null stacktrace using the stack trace sentinel.
+ StackTraceElement[] oldStackTrace = stackTrace;
+ try {
if (stackTrace == null)
- fields.put("stackTrace", SentinelHolder.STACK_TRACE_SENTINEL);
- else
- fields.put("stackTrace", stackTrace);
- fields.put("suppressedExceptions", suppressedExceptions);
-
- s.writeFields();
+ stackTrace = SentinelHolder.STACK_TRACE_SENTINEL;
+ s.defaultWriteObject();
+ } finally {
+ stackTrace = oldStackTrace;
+ }
}
/**
* Appends the specified exception to the exceptions that were
* suppressed in order to deliver this exception. This method is