Salve a tutti,
ho bisogno di un chiarimento per quanto rigurda la gestione delle ecezioni in java.
Se trovo un throw (new Eccezione) in un blocco finally, che succede?
Il compilatore si ferma e da sempre e in ogni caso errore di compilazione oppure va a cercare il catch dell'eccezione nella funzione che ha richiamato la funzione che ha generato l'errore? e se tale funzione è il main?
qui ad esempio:
Il compilatore darà errore di compilazione ma...per quale preciso motivo?codice:class MyExc1 extends Exception { } class MyExc2 extends Exception { } class MyExc3 extends MyExc2 { } public class D1 { public static void main(String[] argv){ try { p(); } catch( MyExc2 k ) {} finally { System.out.print(1); throw( new MyExc2() ); } } static void p() { try {} catch( MyExc1 s ) { System.out.print(2); } catch( MyExc3 k ) { } catch( Exception u ) {} finally { System.out.print(3); throw( new MyExc3() ); } } }