Thoughts on adding getElementClass() method to StackTraceElement?
Peter Levart
peter.levart at gmail.com
Mon Jun 17 06:12:11 UTC 2013
On 06/17/2013 08:06 AM, Jeroen Frijters wrote:
> 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).
New API could be entirely unrelated to Throwable, if there was support
for it in native code. Since there would have to be changes to the
native code anyway to support this, why not create a separate API?
Regards, Peter
>
> Regards,
> Jeroen
>
More information about the core-libs-dev
mailing list