gcj (GCC) 4.1.2 20070626 (Red Hat 4.1.2-13) public class n { public static void main(String[] args) { throw null; } }
$ gcj -C n.java n.java: In class 'n': n.java: In method 'n.main(java.lang.String[])': n.java:5: error: Checked exception null isn't thrown from a try block. throw null; ^ 1 error This is allowed according to JLS 14.18 "throw Expression ; [...] f evaluation of the Expression completes normally, producing a null value, then an instance V' of class NullPointerException is created and thrown instead of null." This is with the old source frontend, with the new frontend based on ecj, this does compile correctly. -- Summary: throw null Product: gcc Version: 4.1.2 Status: UNCONFIRMED Severity: normal Priority: P3 Component: java AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: mark at gcc dot gnu dot org http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33023