In Java, Imagine these interfaces and classes:
public interface Iface<S, T> { ... }
public class Parent<A, B> implements Iface<B, A> { ... }
public class Sub extends Parent<String, Integer> { ... }
Is there a way to make a function that accepts an Iface and obtains which are the types of its generics. So for example, if you enter a Sub.class:
public void showTypes(Class<Iface<S, T>> ifaceClass) {
    // do something...
}
//showTypes(Sub.class) --> S = Integer.class, T = String.class
EDIT: About type erasure. If you have an ArrayList<?> you can't know which generic type it is. But this case is different. If I have a class that extends ArrayList<String> I can know its generic type (String.class). Please look at this snippet:
@SuppressWarnings("serial")
public class StringList extends ArrayList<String> {
    public static void main(String... args) {
        ParameterizedType superType = 
            (ParameterizedType) StringList.class.getGenericSuperclass();
        Type[] types = superType.getActualTypeArguments();
        Class<?> clss = (Class<?>) types[0];
        System.out.println(clss);
    }
}
 
     
     
    