public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* java/9884: gcj compiles code that uses non-static inner classes from static context
@ 2003-02-28  0:06 mjrauhal
  0 siblings, 0 replies; only message in thread
From: mjrauhal @ 2003-02-28  0:06 UTC (permalink / raw)
  To: gcc-gnats


>Number:         9884
>Category:       java
>Synopsis:       gcj compiles code that uses non-static inner classes from static context
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          accepts-illegal
>Submitter-Id:   net
>Arrival-Date:   Fri Feb 28 00:06:00 UTC 2003
>Closed-Date:
>Last-Modified:
>Originator:     Mikko Rauhala
>Release:        3.2.3
>Organization:
>Environment:
Debian GNU/Linux (unstable), recently upgraded (gcj-3.2
package version 3.2.3-0pre2).
>Description:
gcj accepts code that uses non-static inner classes from
static context. This is AFAIK illegal in Java, and Sun's
compiler rejects it with the message:

InnerClassBug.java:11: non-static variable this cannot be referenced from a static context
        InnerClass theObjectThatShouldNotBe = new InnerClass();
                                              ^
1 error
>How-To-Repeat:
Compile the following snippet of code and run it (command:
"gcj-wrapper-3.2 InnerClassBug.java && gij-3.2 InnerClassBug"):

public class InnerClassBug {
    class InnerClass {
	InnerClass() {
	}
	void sayHi() {
	    System.out.println("Hi, I'm the Object that Should Not Be.");
	}
    }

    public static void main(String args[]) {
	InnerClass theObjectThatShouldNotBe = new InnerClass();
	theObjectThatShouldNotBe.sayHi();
    }
}
>Fix:
Give an error message when that kind of thing is attempted.
>Release-Note:
>Audit-Trail:
>Unformatted:


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2003-02-28  0:06 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-02-28  0:06 java/9884: gcj compiles code that uses non-static inner classes from static context mjrauhal

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).