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

Kasper Nielsen kasperni at gmail.com
Tue Jul 2 09:09:11 UTC 2019


Hi,

Are there any security reasons for why StackWalker.getCallerClass()
cannot be made as performant as Reflection.getCallerClass()?
StackWalker.getCallerClass() is at least 100 times slower then
Reflection.getCallerClass() (~1000 ns/op vs ~10 ns/op).

I'm trying to retrofit some existing APIs where I cannot take a Lookup
object to do some access control checks.
But the performance of StackWalker.getCallerClass() is making it impossible.

Best
 Kasper


More information about the core-libs-dev mailing list