This is the mail archive of the
java-prs@gcc.gnu.org
mailing list for the Java project.
[Bug java/18215] New: GCJ disallows some references to 'this' from an enclosing class
- From: "csm at gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: java-prs at gcc dot gnu dot org
- Date: 29 Oct 2004 03:51:39 -0000
- Subject: [Bug java/18215] New: GCJ disallows some references to 'this' from an enclosing class
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
In the constructor of a member class, GCJ does not allow you to do a 'super'
call with an argument that calls an instance method of the enclosing class.
For example, GCJ rejects this perfectly valid class:
--- outer.java ---
public class outer
{
private String name;
public outer (String name)
{
this.name = name;
}
public String getID()
{
return name;
}
public class inner extends Thread
{
public inner()
{
super ("thread-" + getID());
}
}
}
--- outer.java ---
This is valid because the call to 'getID()' is referencing the 'this' from the
enclosing class. GCJ also rejects 'outer.this.getID()' in this example, so there
does not appear to be a workaround.
GCJ fails with:
outer.java: In class `outer$inner':
outer.java: In constructor `(outer)':
outer.java:19: error: Can't reference `this' before the superclass constructor
has been called.
super ("thread-" + outer.this.getID());
^
1 error
Tested on:
gcj (GCC) 3.4.2
gcj (GCC) 4.0.0 20041025 (experimental)
--
Summary: GCJ disallows some references to 'this' from an
enclosing class
Product: gcc
Version: 4.0.0
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: java
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: csm at gnu dot org
CC: gcc-bugs at gcc dot gnu dot org,java-prs at gcc dot gnu
dot org
GCC build triplet: i686-pc-linux-gnu
GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18215