public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* java/5850: resolving inherited member variables
@ 2002-03-06  4:46 goran
  0 siblings, 0 replies; only message in thread
From: goran @ 2002-03-06  4:46 UTC (permalink / raw)
  To: gcc-gnats

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 2258 bytes --]


>Number:         5850
>Category:       java
>Synopsis:       resolving inherited member variables with same name works poorly
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          rejects-legal
>Submitter-Id:   net
>Arrival-Date:   Wed Mar 06 04:46:03 PST 2002
>Closed-Date:
>Last-Modified:
>Originator:     
>Release:        3.2 20020305 (experimental)
>Organization:
>Environment:
System: Linux cm-linux.lla.sema.se 2.4.17 #8 mån feb 18 17:25:46 CET 2002 i686 unknown
Architecture: i686

	
host: i686-pc-linux-gnu
build: i686-pc-linux-gnu
target: i686-pc-linux-gnu
configured with: ./configure i686-pc-linux-gnu --prefix=/usr/local/gcc --enable-threads --enable-languages=c++,java
>Description:
In an inner class inherits a variable ad to outer class inherits one
with the same name GCJ can't pick the right one

--------------------------- snip ----------------------------------------------
bash-2.05a$ gcj x.java y.java y1.java 
x.java: In class `x$x1':
x.java: In method `x$x1.getId()':
x.java:6: Can't make a static reference to nonstatic variable `id' in class `x$x1'.
               return new Integer(id);
                                  ^
1 error
--------------------------- snip ----------------------------------------------

Jikes/JDK resolvs this right.
 
>How-To-Repeat:
compile this 3 files, the error is in evident in file x.java

--------------------------- snip (x.java) -------------------------------------

public class x extends y
{
    private static class x1 extends y1 {
        public Integer getId() {
            return new Integer(id); // this.id works with JDK and gcj
        }
    }
    public static void main(String[] args)
    {
	x1 t = new x1();
	System.out.println(t.getId());
    }
}

--------------------------- snip (y.java) -------------------------------------

public class y
{
    protected final int id = 1;
}

--------------------------- snip (y1.java) ------------------------------------

public class y1
{
    protected final int id = 2;
}

--------------------------- snip ----------------------------------------------

>Fix:
workaround: this.id instead of just id fix it.


>Release-Note:
>Audit-Trail:
>Unformatted:


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

only message in thread, other threads:[~2002-03-06 12:46 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-03-06  4:46 java/5850: resolving inherited member variables goran

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