Review request 8153912: StackFrame::getFileName and StackFrame::getLineNumber not needed
Daniel Fuchs
daniel.fuchs at oracle.com
Wed May 11 16:35:14 UTC 2016
Hi Ralph,
On 11/05/16 18:14, Ralph Goers wrote:
> You are correct that most of the time it would be faster to start from frame 0. However, the problem we have with walking the stack from frame 0 is that it is possible to have a situation like
>
> Foo::method1—>Logger.log—>BarAppender.append—>Foo::method2 (or even method1 again)—>Logger.log
The appender would call Logger.log? Is that a common situation?
That sounds strange to me.
I was kind of assuming that you could walk the stack until
finding an instance of Logger (which would allow you to skip
all the appender's infrastructure), then continue walking until
you find something which is no longer a Logger.
I'm not sure I understand your other comment about getCallerClass().
That just walks 2 frames (skipping reflection frame).
You can do the same with StackWalker, that should enable you
to get the calling frame easily.
best regards,
-- daniel
More information about the core-libs-dev
mailing list