Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Jul 31st, 2012  |  syntax: None  |  size: 0.50 KB  |  hits: 13  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. @throws in Scala does not allow calling Java to catch correct exception type
  2. class Callee {
  3.   @throws(classOf[MyCheckedException])
  4.   def doStuff() {
  5.   }
  6. }
  7.        
  8. public class Caller {
  9.  
  10.   public static void main(String[] args) {
  11.     // this won't compile; the Java compiler complains that the catch block is unreachable
  12.     // however without the catch block, it complains "unhandled exception MyCheckedException"
  13.     try {
  14.       new Callee().doStuff();
  15.     }
  16.     catch (MyCheckedException e) {
  17.  
  18.     }
  19.   }
  20. }