This is the mail archive of the
gcc-prs@gcc.gnu.org
mailing list for the GCC project.
java/1167: Compiler crash on (illegal) attempt to create inner class from static context
- To: java-gnats at sourceware dot cygnus dot com
- Subject: java/1167: Compiler crash on (illegal) attempt to create inner class from static context
- From: bryce at albatross dot co dot nz
- Date: 14 Mar 2000 10:48:36 -0000
- Reply-To: bryce at albatross dot co dot nz
>Number: 1167
>Category: java
>Synopsis: Compiler crash on (illegal) attempt to create inner class from static context
>Confidential: no
>Severity: non-critical
>Priority: medium
>Responsible: apbianco
>State: closed
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Wed Dec 20 12:16:43 PST 2000
>Closed-Date: Wed Mar 22 23:31:55 PST 2000
>Last-Modified: Wed Mar 22 23:40:01 PST 2000
>Originator: Bryce McKinlay
>Release: unknown-1.0
>Organization:
>Environment:
>Description:
// jc1 (2.96 20000313) ice
public class Scope1
{
public static void main(String args[])
{
new A(); // Illegal to create inner class from static context.
}
class A
{
A() {}
}
}
>How-To-Repeat:
>Fix:
This is a revised patch.
>Release-Note:
>Audit-Trail:
Formerly PR gcj/173
State-Changed-From-To: open->feedback
State-Changed-By: apbianco
State-Changed-When: Wed Mar 15 01:11:52 2000
State-Changed-Why:
I proposed a patch.
From: apbianco@cygnus.com
To: apbianco@cygnus.com, bryce@albatross.co.nz,
java-gnats@sourceware.cygnus.com
Cc:
Subject: Re: gcj/173
Date: 15 Mar 2000 09:11:52 -0000
Synopsis: Compiler crash on (illegal) attempt to create inner class from static context
State-Changed-From-To: open->feedback
State-Changed-By: apbianco
State-Changed-When: Wed Mar 15 01:11:52 2000
State-Changed-Why:
I proposed a patch.
http://sourceware.cygnus.com/cgi-bin/gnatsweb.pl?cmd=view&pr=173&database=java
From: Bryce McKinlay <bryce@albatross.co.nz>
To: java-gnats@sourceware.cygnus.com
Cc:
Subject: Re: gcj/173
Date: Wed, 15 Mar 2000 23:49:56 +1300
The patch works for me. I'm not sure I like the javac-style error
message though: "No enclosing instance for inner class `Scope2$A' is in
scope; an explicit one must be provided when creating this inner class."
Is there really actually a way in Java to "provide an explicit instance"
of the enclosing class, thus constructing an inner class from static
code? If there is I've never seen it used or figured it out, and this
error from javac has allways puzzled me because it seems to indicate
that you CAN do just that.
Jikes says "An instance of "Scope2.this" is not accessible here because
it would have to cross a static region in the intervening type
"Scope2"."
I like that slightly better, but maybe "Cannot create instance of
non-static inner class from static context" is all it really needs.
regards
[ bryce ]
From: Alexandre Petit-Bianco <apbianco@cygnus.com>
To: java-gnats@sourceware.cygnus.com
Cc:
Subject: Re: gcj/173
Date: Wed, 15 Mar 2000 11:54:18 -0800 (PST)
Bryce McKinlay writes:
> I like that slightly better, but maybe "Cannot create instance of
> non-static inner class from static context" is all it really needs.
That forces you to handle both cases (static, non static)
separately. What I'll do is keep the "No enclosing instance for inner
class `%s' is in scope" and I'll add the "an explicit one must be
provided when creating this inner class." when in a non static
context.
./A
State-Changed-From-To: feedback->closed
State-Changed-By: apbianco
State-Changed-When: Wed Mar 22 23:31:55 2000
State-Changed-Why:
I checked in a patch to fix the bug:
http://gcc.gnu.org/ml/gcc-patches/2000-03/msg00790.html
From: apbianco@cygnus.com
To: apbianco@cygnus.com, bryce@albatross.co.nz,
java-gnats@sourceware.cygnus.com
Cc:
Subject: Re: gcj/173
Date: 23 Mar 2000 07:31:55 -0000
Synopsis: Compiler crash on (illegal) attempt to create inner class from static context
State-Changed-From-To: feedback->closed
State-Changed-By: apbianco
State-Changed-When: Wed Mar 22 23:31:55 2000
State-Changed-Why:
I checked in a patch to fix the bug:
http://gcc.gnu.org/ml/gcc-patches/2000-03/msg00790.html
http://sourceware.cygnus.com/cgi-bin/gnatsweb.pl?cmd=view&pr=173&database=java
>Unformatted: