[Bug java/18215] New: GCJ disallows some references to 'this' from an enclosing class
csm at gnu dot org
gcc-bugzilla@gcc.gnu.org
Fri Oct 29 03:51:00 GMT 2004
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
More information about the Java-prs
mailing list