Bug 12434

Summary: Field called java causes confusion.
Product: gcc Reporter: Ralph Loader <suckfish>
Component: javaAssignee: Not yet assigned to anyone <unassigned>
Status: RESOLVED FIXED    
Severity: normal CC: gcc-bugs, java-prs
Priority: P2 Keywords: rejects-valid
Version: 3.4.0   
Target Milestone: 4.3.0   
Host: Target:
Build: Known to work:
Known to fail: Last reconfirmed: 2005-07-23 05:28:31
Bug Depends on: 28067    
Bug Blocks: 13607    

Description Ralph Loader 2003-09-28 11:03:37 UTC
gcj implements an expression like foo.class by synthesizing a call to
java.lang.class.forName.

The compiler gets a bit confused if you have a field called java.

$ dev/test/bin/gcj -fsyntax-only broken.java
broken.java: In class `broken':
broken.java: In method `class$(java.lang.String)':
broken.java:8: error: Can't make a static reference to nonstatic variable `java'
in class `broken'.
   }
   ^
1 error


It should be possible to fix this by setting RESOLVE_PACKAGE_NAME_P on the
synthesized name, and then making sure we don't change that later.  The name
resolution code is "interesting" though.

The method name on the error message above is interesting too.

class broken {
    int java;

    Class foo()
    {
	return broken.class;
    }
}
Comment 1 Andrew Pinski 2003-09-30 22:17:57 UTC
I can confirm this on the mainline (20030925).
Comment 2 Tom Tromey 2007-01-09 20:45:50 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.