Pour tester, met les différents appels de.demo_1(), de.demo_2() et de.demo_3() en commentaire
/*
* Created on Aug 23, 2005
*
*/
/**
* @author HackTrack
*
*/
public class DemoException {
public DemoException() {
super();
}
public void demo_1() throws NumberFormatException {
throw new NumberFormatException();
}
public void demo_2() throws Exception {
throw new Exception();
}
public void demo_3() throws ClassCastException {
throw new ClassCastException();
}
public static void main(String[] args) {
DemoException de = new DemoException();
try {
//de.demo_1();
//de.demo_2();
de.demo_3();
} catch (Exception e) {
if (e.getClass().getName().equals("java.lang.Exception")) {
System.out.println("Exception");
} else {
System.out.println("NOT Exception [" + e.getClass().getName() + "]");
}
}
}
}
;-)
HackTrack