Exception transparency - lone throws (no checked exceptions)
Peter Levart
peter.levart at marand.si
Thu Jun 10 06:30:48 PDT 2010
Hello Stephen,
Interesting proposal. You don't specify what happens if code in a method calls a method with "lone throws" but doesn't catch anything or catches only some exceptions (but not all Throwables). Does the calling method have to declare "lone throws" too?
interface Block<T> {
public void invoke(T element) throws;
}
class MyBlock implements Block<String> {
public void invoke(String element) throws {
new File(element).getCanonicalFile().delete();
}
}
void myMethod() { // ?? do we have to declare "lone throws" here?
try {
MyBlock b = new MyBlock();
b.invoke("C:\README.txt");
} catch (SQLException ex) { // will not be thrown from MyBlock.invoke anyway...
...
}
}
If not, does that mean that "sneaky" thown exceptions can be thrown by such methods?
Regards, Peter
More information about the lambda-dev
mailing list