Hi Kasper, did you store the StackWalker instance in a static final field ?
Rémi ----- Mail original ----- > De: "Kasper Nielsen" <kaspe...@gmail.com> > À: "core-libs-dev" <core-libs-dev@openjdk.java.net> > Envoyé: Mardi 2 Juillet 2019 11:09:11 > Objet: Slow performance of StackWalker.getCallerClass() vs > Reflection.getCallerClass() > 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