...because they don't tell me what the class of the "wrong" object was. No message, just empty. Where is the difficulty in telling me, what the actual type of the object was that caused the class cast exception? I rarely see them, but when I see them it's not informative enough -- I have to run the debugger but those rare class cast exceptions are often hard to reproduce...
Sun, please add runtime type of the casted object to the ClassCastExceptions message
Can you run your Java Application from the Eclipse Java Debugger? - Well then just set a Java Exception Breakpoint (See my blog on them).
ReplyDeleteThe NPEs suck too. I don't like code that just does a throw new NullPointerException(). Why is it so difficult to write throw new NullPointerException("bla is null")? And if it's generated by the VM that it's even easier to generate a message.
ReplyDeletebeen there, hated it, made Kaffe tell me the types and their class loaders when it throws such an exception a few years ago. I believe sun's done that now too with their implementation in the mustang builds.
ReplyDeleteThey did in mustang! *sniffle*
ReplyDeleteThey did just this in mustang
ReplyDeleteThis is a regression bug in 1.4.1 and is fixed again in 1.5: http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4826718
ReplyDeleteIMHO it would be even better if they would also include the target class in the message.
As described in Gunnar, I am really wondering whether the new version of JDK (e.g., mustang) has solved the problem, namely explicitly showing which variable is null.
ReplyDeleteThank you very much!
Cool article as for me. It would be great to read something more concerning that matter. Thnx for giving that material.
ReplyDeleteJoan Stepsen
Wise geek