Bug 8899 - gcj confused over local classes
Summary: gcj confused over local classes
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: java (show other bugs)
Version: 3.2
: P3 normal
Target Milestone: 4.3.0
Assignee: Not yet assigned to anyone
URL:
Keywords: rejects-valid
Depends on: 28067
Blocks:
  Show dependency treegraph
 
Reported: 2002-12-11 02:16 UTC by Gary Benson
Modified: 2007-01-09 20:44 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2005-09-30 13:35:23


Attachments
Test.java (109 bytes, text/plain)
2003-05-21 15:17 UTC, Gary Benson
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Gary Benson 2002-12-11 02:16:01 UTC
The following code fails to compile because gcj is looking in the wrong Foo class for the constructor:

| public class Test {
|     public void func1() {
| 	class Foo {
| 	    Foo(int i) {
| 	    }
| 	}
| 	Foo f = new Foo(1);
|     }
|     public void func2() {
| 	class Foo {
| 	    Foo(boolean b) {
| 	    }
| 	}
|     }
| }

The error message given is as follows:

| Test.java: In class `Test':
| Test.java: In method `Test.func1()':
| Test.java:7: Can't find constructor `Test$2$Foo(I)' in type `Test$2$Foo'.
|         Foo f = new Foo(1);
|                        ^
| 1 error

Release:
gcc-3.2 patched for PR 1343

Environment:
Red Hat Linux 8.0

How-To-Repeat:
gcj Test.java # attached
Comment 1 Tom Tromey 2002-12-13 10:20:25 UTC
From: Tom Tromey <tromey@redhat.com>
To: gbenson@redhat.com
Cc: gcc-gnats@gcc.gnu.org
Subject: Re: java/8899: gcj confused over local classes
Date: 13 Dec 2002 10:20:25 -0700

 >>>>> "Gary" == Gary Benson <gbenson@redhat.com> writes:
 
 Gary> Number:         8899
 Gary> Synopsis:       gcj confused over local classes
 
 Gary> | public class Test {
 Gary> |     public void func1() {
 Gary> | 	class Foo {
 Gary> | 	    Foo(int i) {
 Gary> | 	    }
 Gary> | 	}
 Gary> | 	Foo f = new Foo(1);
 Gary> |     }
 Gary> |     public void func2() {
 Gary> | 	class Foo {
 Gary> | 	    Foo(boolean b) {
 Gary> | 	    }
 Gary> | 	}
 Gary> |     }
 Gary> | }
 
 I looked at this last night.
 
 It turns out that gcj has no notion of scope for member classes.  It
 puts them all in a single list attached to the class.  So the problem
 is that basic required functionality is missing from gcj.
 
 Tom
Comment 2 Andrew Pinski 2003-05-25 23:27:39 UTC
Still fails on the mainline (20030525):
 
Test.java: In class `Test':
Test.java: In method `Test.func1()':
Test.java:9: error: Can't find constructor `Test$2$Foo(I)' in type `Test$2$Foo'.
        Foo f = new Foo(1);
                        ^
1 error
Comment 3 Tom Tromey 2007-01-09 20:44:26 UTC
All gcj front end bugs have been fixed by the gcj-eclipse branch merge.
I'm mass-closing the affected PRs.
If you believe one of these was closed in error, please reopen it
with a note explaining why.
Thanks.