This may seem a dumb question (as it could be very project specific) but in this case it’s general enough:
I’m running a piece of code which gives the ClassCastException, with the error message I wrote as title. Here the mentioned cast is from an object of type java.lang.reflect.Type to Class<?>.
Apart from primitive types, which type in Java is not a class?
Thanks for your answers
A
Classis aTypebut aTypeisn’t necessary aClass, sinceClassimplementsType.Basically, your
myTypecould also be any of the implementing classes of the interfacesGenericArrayType,ParameterizedType,TypeVariableorWildcardType, since they all extend theTypeinterface.Try to print
myType.getClass()to see the type you mean: you’ll getClass<TheSaidType>.