there are many question about java-7 feature "precise rethrow" and final Exception ex
, i couldn't find clear answer for my question.
what is the relation between "precise rethrow" and final Exception
?
public static void main(String args[]) throws OpenException, CloseException {
boolean flag = true;
try {
if (flag){
throw new OpenException();
}
else {
throw new CloseException();
}
}
catch (final Exception e) {
System.out.println(e.getMessage());
throw e;
}
}
is that obligatory to use final
keyword if i want to use "precise rethrow" ?
catch (final Exception e) {
System.out.println(e.getMessage());
throw e;
}
if it is not obligatory can i reassign the ex
reference to a new exception?
catch (Exception e) {
System.out.println(e.getMessage());
e=new AnotherException();
throw e;
}