Why does ClassCastException not show the class name?
In Java 1.4.2 and earlier versions, if you get a ClassCastExcep开发者_如何学Pythontion, you can see the exception stack trace but not the class name. If you want to find out the class of the object for which casting failed, you have to debug.
Is it still the same in later Java versions? If so, when did it change?
This changed with Java5, when the exception message started including the actual name of the class of the object being cast. Should've been there from the start, it took them ages to add it.
精彩评论