I have a Scala code like this:
class Callee { @throws(classOf[MyCheckedException]) def doStuff() { } }
Calling it from Java as follows:
public class Caller { public static void main(String[] args) {
Deleting a catch block results in an error from the Java compiler talking about the "unhandled exception type MyCheckedException". Adding a catch block to MyCheckedException causes the compiler to complain that the catch block is unavailable because the exception is never thrown.
If I catch an Exception and make an instanceOf, I can catch the correct exception coming from doStuff, but I thought that the @throws annotation should generate the correct bytecode for the correct catch block to work. Am I mistaken, or is there a mistake here?
For the record, this is with Scala 2.9.2 and Java 1.6.
Edit:. It compiles a fine calling javac / scalac using sbt from the command line. The error is obvious only at compile time like in Eclipse, which means that the error is present either in the Java Eclipse compiler or in some part of the IDE. Can others reproduce it like this? I am using Eclipse 3.7.2
David north
source share