Java: Getting the generic type of a lambda
问题 First, I should say that I am able to get the generic type of instances or anonymous inner classes. Here is the code example, look for the catch block : public static interface MyInterface<E extends Throwable>{ void call() throws E; } public static <E extends Throwable> void method(MyInterface<E> lambda) throws E { try { lambda.call(); } catch(Throwable ex) { // Pseudo code Class<?> T = ((ParameterizedType)ex.getClass().getGenericInterfaces()[0]).getActualTypeArguments()[0]; if ( T.isInstance