If you have an arbitrary Lookup object (generated from invokedynamic bootstrap), is it possible to get an instance from the class performing the lookup?
There is a Method “lookupClass” available for Lookup objects, but that only returns a Class object.
Lets say I have a Class Car for example, which generates a Lookup object.
How can i get an instance of that class?
Thanks.
Found a solution 🙂
If you have a lookup object caller, then you can get the instance of the class performing the lookup with the following line:
Class.forName(caller.lookupClass().getCanonicalName()).newInstance();