-
Bug
-
Resolution: Not an Issue
-
P4
-
None
-
1.1.7, 1.2.0
-
generic
-
generic
allan.jacobs@Eng 1998-09-17
algol% setenv JDK /net/mulder.eng/export/mulder3/jdk12x/sparc/jdk1.2FCS_J
algol% ${JDK}/bin/java -fullversion
java full version "JDK-1.2fcs-J"
algol% uname -a
SunOS algol 5.6 Generic sun4u sparc SUNW,Ultra-2
algol% ${JDK}/bin/javac -d . X.java
algol% ${JDK}/bin/java X
java.lang.NullPointerException
java.lang.IllegalArgumentException
algol% cat X.java
class A {
void s(int i) throws NullPointerException {
throw new NullPointerException();
}
}
public class X extends A {
public static void main( String[] argv ) {
X ob = new X();
try { ob.s(0); }
catch (Exception e) { System.out.println(e); }
try { ob.s(1); }
catch (Exception e) { System.out.println(e); }
}
void s(int i) throws NullPointerException,IllegalArgumentException {
if (i==0) throw new NullPointerException();
else if (i==1) throw new IllegalArgumentException();
}
}
The code X.java should generate a compile-time error. The relevant section in the
JLS is 8.4.4.
"A method that overrides or hides another method (s8.4.6), including methods that
implement abstract methods defined in interfaces, may not be declared to throw more
checked exceptions thatn the overriden or hidden method."
The bug was discovered using Plum Hall test jvs/ch8neg/j844p51a_z.
allan.jacobs@Eng 1998-09-17
Also in JDK1.1.7J.