I have spend whole day on this problem. My problem is how to make an MethodHandle.invokeExact invocation on an instance, whose class type is dynamically loaded at program ru
To make sense, you'll have to type the method ( otherwise the cast is pointless):
public void doSomething() { BaseTemplate obj = ... Class newType = Class('AddSample'); T t = newType.cast(obj);
Without the method typing, you can't tie the dynamic class to the type to be cast to.