Nick Williams wrote: > What if we also added a getStackFrames() method to Throwable? That would > meet my needs but it would also satisfy what I'm observing is a desire > to have a new API for this (StackFrame) instead of adding it to > StackTraceElement. I'm very open to how it's implemented, as long as it > satisfies my use case. :-) > > The stack trace of a Throwable can be "filled in" on demand when > getStackTrace() is called the first time, so that the overhead isn't > incurred when creating and throwing the exception. Presumably, we would > need to do something similar with getStackFrames(), especially since > calling it would be less common. > > Thoughts on this?
Yes that is reasonable, but I'd add a static method to StackFrame instead. Something like StackFrame[] capture(Throwable). Regards, Jeroen