-
Bug
-
Resolution: Fixed
-
P4
-
1.0
-
1.1
-
sparc
-
solaris_2.4
-
Not verified
The following code doesn't compile, but should. Just because t.foo wasn't
explicit about throwing RuntimeException and Error objects doesn't mean
that subclasses should be so restricted. u.foo is, in fact, declaring only exceptions
that are legal to raise in t.foo:
The code:
class t {
void foo() { }
}
class u extends t {
void foo() throws NullPointerException { }
}
The error:
t.java:6: Invalid exception class java.lang.NullPointerException in throws clause. The exception must be a subclass of an exception thrown by void foo() from class t.
void foo() throws NullPointerException { }
^
explicit about throwing RuntimeException and Error objects doesn't mean
that subclasses should be so restricted. u.foo is, in fact, declaring only exceptions
that are legal to raise in t.foo:
The code:
class t {
void foo() { }
}
class u extends t {
void foo() throws NullPointerException { }
}
The error:
t.java:6: Invalid exception class java.lang.NullPointerException in throws clause. The exception must be a subclass of an exception thrown by void foo() from class t.
void foo() throws NullPointerException { }
^