public inbox for java-prs@sourceware.org help / color / mirror / Atom feed
From: "vadimn at redhat dot com" <gcc-bugzilla@gcc.gnu.org> To: java-prs@gcc.gnu.org Subject: [Bug libgcj/16677] New: GCJ fails to reject invalid code Date: Thu, 22 Jul 2004 21:34:00 -0000 [thread overview] Message-ID: <20040722213425.16677.vadimn@redhat.com> (raw) In the process of producing a test case for PR16675, we ran across another bug. See below. Bryce points out that it is similar to PR9884. As far as I can tell, it's the exact same issue, in which case please mark this as a duplicate. Here goes. The following snippet of code is not valid. | $ cat Test.java | public class Test { | public static void main(String[] s) { | new Object() { | public String toString() { | return "enclosing class: " + Test.this.getClass(); | } | }.toString(); | } | } Sun's javac compiler correctly rejects it like so: | $ java -version | java version "1.4.2_04" | Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_04-b05) | Java HotSpot(TM) Client VM (build 1.4.2_04-b05, mixed mode) | $ javac Test.java | Test.java:5: non-static variable this cannot be referenced from a static context | return "enclosing class: " + Test.this.getClass(); | ^ | 1 error | $ echo $? | 1 GCJ accepts it: | $ gcj -C Test.java | $ echo $? | 0 The generated bytecode produces a runtime error: | $ gij Test | Exception in thread "main" java.lang.NullPointerException | at Test$1.toString() (Unknown Source) | at Test.main(java.lang.String[]) (Unknown Source) -- Summary: GCJ fails to reject invalid code Product: gcc Version: 3.4.0 Status: UNCONFIRMED Severity: normal Priority: P2 Component: libgcj AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: vadimn at redhat dot com CC: gcc-bugs at gcc dot gnu dot org,java-prs at gcc dot gnu dot org http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16677
next reply other threads:[~2004-07-22 21:34 UTC|newest] Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top 2004-07-22 21:34 vadimn at redhat dot com [this message] 2004-07-22 21:53 ` [Bug libgcj/16677] Failure to reject illegal access to enclosing "this" across static context mckinlay at redhat dot com 2004-07-22 21:53 ` [Bug java/16677] " mckinlay at redhat dot com 2004-07-22 21:55 ` pinskia at gcc dot gnu dot org 2004-07-23 9:12 ` pinskia at gcc dot gnu dot org 2004-07-23 9:13 ` pinskia at gcc dot gnu dot org 2004-07-23 9:24 ` pinskia at gcc dot gnu dot org
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20040722213425.16677.vadimn@redhat.com \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=java-prs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).