
Untitled
By: a guest on
Jul 31st, 2012 | syntax:
None | size: 0.50 KB | hits: 13 | expires: Never
@throws in Scala does not allow calling Java to catch correct exception type
class Callee {
@throws(classOf[MyCheckedException])
def doStuff() {
}
}
public class Caller {
public static void main(String[] args) {
// this won't compile; the Java compiler complains that the catch block is unreachable
// however without the catch block, it complains "unhandled exception MyCheckedException"
try {
new Callee().doStuff();
}
catch (MyCheckedException e) {
}
}
}