Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-6280975

Parameterized exceptions are erased too soon

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P2 P2
    • 6
    • 5.0
    • tools
    • generic
    • generic

      SomeNode.java
           1 class SomeNode extends NamedNode {}
      IRNode.java
           1 public interface IRNode
           2 {
           3 public <Return, Input, ExceptionType extends Exception> Return execute (IRNamedNodeAlgo<Return,Input,ExceptionType> algo, Input... input) throws ExceptionType;
           4
           5 }
      IRNamedNodeAlgo.java
           1 public interface IRNamedNodeAlgo<Return, Input, ExceptionType extends Exception>
           2 {
           3
           4 public Return forNamedNode(IRNode node, Input... input) throws ExceptionType;
           5
           6 public Return forNonNamedNode(IRNode node, Input... input) throws ExceptionType;
           7
           8 }
      NamedNode.java
           1 public class NamedNode implements IRNode
           2 {
           3
           4 public <Return, Input, ExceptionType extends Exception> Return execute(IRNamedNodeAlgo<Return,Input,ExceptionType> algo, Input... input) throws ExceptionType
           5 {
           6 return algo.forNamedNode(this, input);
           7 }
           8
           9 }

      Compiles without problem:
      javac IRNode.java IRNamedNodeAlgo.java NamedNode.java SomeNode.java

      Can't compile:
      javac SomeNode.java IRNode.java IRNamedNodeAlgo.java NamedNode.java
      NamedNode.java:6: unreported exception java.lang.Exception; must be caught or declared to be thrown
      return algo.forNamedNode(this, input);
                              ^
      1 error

      See: http://forum.java.sun.com/thread.jspa?threadID=633301&tstart=0

      javac -J-fullversion
      java full version "1.5.0_01-b08"

      ###@###.### 2005-06-06 16:51:45 GMT

            jjg Jonathan Gibbons
            ahe Peter Ahe
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: