[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: Query on stacktrace management logic
From: |
David Holmes |
Subject: |
RE: Query on stacktrace management logic |
Date: |
Fri, 27 Feb 2004 16:03:17 +1000 |
I wrote:
> Rather than the much simpler:
>
> private StackTraceElement[] stackTrace;
>
> public Throwable fillInStackTrace() {
> stackTrace = VMThrowable.fillInStackTrace(this).getStackTrace(this);
> return this;
> }
>
> public StackTraceElement[] getStackTrace() {
> return stackTrace;
> }
>
> ...
> What did I miss?
Well the first thing I missed is that fillInStacktrace can return null so
the above should be:
public Throwable fillInStackTrace() {
VMThrowable vmt = VMThrowable.fillInStackTrace(this);
if (vmt != null)
stackTrace = vmt.getStackTrace(this);
else // could check if already zero length array
stacktrace = new StackTraceElement[0];
return this;
}
I thought it might have to do with making defensive copies but as far as I
can see the original code doesn't achieve that either.
David Holmes