I know that in Java we don't have paramaterized types at run-time, because of the erasure. But is it possible to get those erased parameters at run-time? Let me provide some example:
public class MyClass<T>{ };
public static void foo(MyClass<?> p){
//do staff
}
public void main(String[] args){
MyClass<Integer> i = new MyClass<Integer>();
foo(i);
}
Now, we passed i
to foo
as an argument. Is it possible to enquire within the foo
's body what type parameter i
was instantiated with? Maybe some reflection facility keeps that information at runtime?