This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug java/33023] New: throw null
- From: "mark at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 8 Aug 2007 10:31:41 -0000
- Subject: [Bug java/33023] New: throw null
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
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