It is detail, but I want to know why this happens.
Exemplary code:
Class klasa = Enum.class;
for(Type t : klasa.getGenericInterfaces())
System.out.println(t);
Output o the program:
java.lang.Comparable<E>
interface java.io.Serializable
Why on the output there is no interface word before java.lang.Comparable<E>
. It is interface, yes?
In my opinion output should be:
**interface** java.lang.Comparable<E>
interface java.io.Serializable
Comparable is specially treated?
What happens is that you get two different subclasses of java.lang.reflect.Type
; one that is a generic type (probably j.l.r.ParameterizedType
), and one that is a specific (non-generic) interface type (a j.l.Class<?>
).
What do you want to do with that information, and why?