Slow performance of StackWalker.getCallerClass() vs Reflection.getCallerClass()

Mandy Chung mandy.chung at
Wed Jul 3 20:04:53 UTC 2019

On 7/2/19 6:57 PM, Ralph Goers wrote:
> Thanks Mandy,
> It seems I commented on the thread mentioned in the issue you linked 
> to. Unfortunately, it doesn’t look like any work has been done on the 
> the last 18 months.

I did start to explore some options and never have time to spend on this 
as I have been working on other higher priority projects.

> Yes, LogRecord doesn’t get the StackTraceElement. We only get it for 
> the one stack entry we are interested in and we only do that because 
> Log4j is still compatible with Java 7 and creating our own class would 
> be too disruptive. Still, the cost seems to be in locating the correct 
> frame, not creating the StackTraceElement.

Do you have data/information where you find the overhead comes from?  if 
you avoid using StackTraceElement, that'd help understanding it.


More information about the core-libs-dev mailing list