fast way to infer caller
Kasper Nielsen
kasperni at gmail.com
Thu Apr 7 17:27:52 UTC 2022
>
> nope, see my previous mail to Ceki, the VM is cheating here if it can
> inline the call to MethodHandles.lookup()
>
Does how the VM cheats really matter? The fact is that the code in the JDK
can
get the calling class and implement something like MethodHandles.lookup() so
it takes ~3 ns. If you implemented something like a lookup class as a normal
user your best bet would be StackWalker.GetCallingClass() and you would end
up with something that is at least 2 magnitudes slower. That is probably not
an issue for most use cases. But for some, it might be a bit of a steep
cost.
/Kasper
More information about the core-libs-dev
mailing list