Review request 8153912: StackFrame::getFileName and StackFrame::getLineNumber not needed
Ralph Goers
ralph.goers at dslextreme.com
Mon Mar 13 19:06:07 UTC 2017
> On Mar 13, 2017, at 12:04 PM, Daniel Fuchs <daniel.fuchs at oracle.com> wrote:
>
> Hi Ralph,
>
> I see one issue in your benchmark:
>
> StackWalker walker = StackWalker.getInstance(StackWalker.Option.RETAIN_CLASS_REFERENCE);
>
> will return a new StackWalker every time it's called.
> I'd suggest to create the StackWalker only once and put it in
> a private (or package) static.
> This will eliminate the creation cost of StackWalker from the
> benchmark.
OK - I will do that when I fix the other bug. But if you can suggest some other way to bail out of the loop after I have found the correct StackFrame that would help as well.
Ralph
>
> On 13/03/2017 18:52, Ralph Goers wrote:
>> The “search” that uses StackWalker probably walks it to the end because
>> I had to use test() to determine the StackFrame to return. If you can
>> provide a better algorithm to use I’d be happy to retest it. If I=0 is
>> the current StackFrame, then that is what we do. Please take a look at
>> the stackwalkerSearch method
>> at https://github.com/rgoers/stackwalker-vs-Reflection_getCallerClass/blob/master/java9/src/main/java/org/github/arnaudroger/StackWalkerGetCallerClass.java.
>
> I'm curious as to why using reduce() as opposed to findFirst().
> Won't reduce() continue to walk the stack even when the searched
> frame is found?
>
> best regards,
>
> -- daniel
>
>
>
>
>
More information about the core-libs-dev
mailing list