fix NPE in loops (with cast) and wrong check message with classes
extending exceptions (java 7 only)