-
Bug
-
Resolution: Duplicate
-
P2
-
5.0
-
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
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
- duplicates
-
JDK-6199662 javac: compilation success depends on compilation order
-
- Closed
-
- relates to
-
JDK-6325201 make erasure non-destructive
-
- Closed
-
-
JDK-5086027 Inner class of generic class cannot extend Throwable
-
- Closed
-