DRAFT PROPOSAL Pot Pourri - Augmented Stack Traces, ServiceProvider annotation and processor, Enhanced For Loop utility class
Charles Oliver Nutter
charles.nutter at sun.com
Sat Mar 1 21:17:41 PST 2008
Bruce Chapman & Barbara Carey wrote:
> DRAFT PROPOSAL Pot Pourri - Augmented Stack Traces, ServiceProvider
> annotation and
>
> processor, Enhanced For Loop utility class
>
> Bruce Colin Chapman
> cadenza at paradise.net.nz
>
> I propose three independant additions to the JDK APIs.
>
> o Augmented Stack traces
> o ServiceProvider Annotation and Processor
> o Enhanced For loop Utility Class
>
> Augmented Stack Trace
> =====================
> I propose a mechanism to add contextual information (a short String) to
> an Exception's
>
> stack trace at the StackTraceElement corresponding to where the
> mechanism is invoked from.
>
> This will be particularly useful when traversing composite pattern data
> structures as each
>
> Node can catch any exceptions, augment them with its identity in some
> form, and rethrow the
>
> exception. Any stack trace will then include the path to the node that
> was being processed
>
> when the exception was thrown.
I wonder if a general mechanism for decorating the stack could be part
of this? My understanding of exception handling performance is such that
handling the exception is actually the more expensive part; so I would
expect that handling and re-handling to augment the exception at various
levels would add more overhead. One thing I've often wanted is a way to
decorate the stack with additional information *ahead of time* so that
when/if an exception is raised that information can automatically be
attached. In my case, it's for JRuby, where we have a "virtual" Ruby
stack trace alongside the Java stack trace. It's not useful for us to
dump out the entire Java stack trace, since it includes information
about Java frames unrelated to the user's code. And we can't just filter
the Ruby frames, because JRuby is mixed-mode and some of those frames
will be interpreted calls (and therefore be identical to one another). A
way to attach information to the current frame
(Thread.current.augmentFrame(Object)) and register a backtrace handler
(Thread.current.attachBacktraceCallback(...)) would provide a way to
attach useful arbitrary data to the call frame for many uses.
Thoughts?
- Charlie
More information about the challenge-discuss
mailing list