To support dynamic types and method dispatch, my programming language introduces a type called dynamic
. When calling a method on a callee whose type is dynamic
, the compiler first pushes the callee and all arguments on the stack, and then generates an invokedynamic
instruction instead of a normal invoke*
instruction. The instruction points to a special bootstrap method in a class called DynamicLinker
, but only static types are available when it is called.
My Problem: How do I get the runtime type of the arguments that were passed to the invokedynamic
instruction?
The "dynamic" part of invokedynamic
does not mean that a method arguments can have dynamic types. It rather means that the behavior of invoke
instruction can be customized. The exact types of invokedynamic
arguments are known at compile time.