Today i was writing some heavy reflection-using code, and i came across this behavior i can't explain: why does
Type[] types = ((ParameterizedType)m.getGenericReturnType()).getActualTypeArguments();
Class[] c = (Class[])types;
Throw a ClassCastException, when iterating over that same array and casting every single element, i.e.
for(Type t : types) {
Class c = (Class)t;
}
succeeds?
I mean, if the casting of a single element to another class is possible, why isn't the casting between arrays of the same types possible as well?
There probably is a reason, but i can't seem to find one...