Question

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.

Was it helpful?

Solution

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();

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top