Of course, information that the class is shared is supported.
In other words: when you decompile ArrayList.class, you will find hints that this class allows one common type parameter. In other words: class files contain meta information. And using reflection, you can check this meta information at runtime.
But if you have another class that uses some List<Integer> object, then you will not find information that "list uses Integer" in the compiled class - unless you use some specific templates, as indicated here .
Thus, the answer is mainly: for almost all cases of practical significance of "generics" - this is compilation time.
Example:
public class GenericsExample<T> { private T member; public T foo(T bar) { return member; } }
Now run: javap -p -c GenericsExample
Compiled from "GenericsExample.java" public class GenericsExample<T> { private T member; public GenericsExample(); Code: 0: aload_0 1: invokespecial #1
As you can see, the decompiler understands that the class uses this generic type T. For more details see here or there .
source share