This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug java/16284] New: GCJ incorrectly reports forbidden 'this' reference error
- From: "stepan at srnet dot cz" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 29 Jun 2004 22:14:55 -0000
- Subject: [Bug java/16284] New: GCJ incorrectly reports forbidden 'this' reference error
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
Used GCJ is from Slackware 10.0, version 3.4.0 (fails also with 3.3.4 from the
same distribution).
Test case:
public class Test {
public Test() {
super();
new TestThread();
}
private class TestThread extends Thread {
public TestThread() {
super(a());
}
}
public String a() {
return "XXX";
}
}
GCJ reports:
Test.java: In class `Test$TestThread':
Test.java: In constructor `(Test)':
Test.java:12: error: Can't reference `this' before the superclass constructor
has been called.
super(a());
^
1 error
That is not correct because there is no use of 'this' when calling Test.a, only
silent argument of type Test is (should) used. Sun's Java 1.4.2 compiler
produces (disassembled with javap):
public Test$TestThread(Test);
Code:
0: aload_0
1: aload_1
2: invokevirtual #1; //Method Test.a:()Ljava/lang/String;
5: invokespecial #2; //Method java/lang/Thread."<init>":(Ljava/lang/String;)V
8: aload_0
9: aload_1
10: putfield #3; //Field this$0:LTest;
13: return
}
--
Summary: GCJ incorrectly reports forbidden 'this' reference error
Product: gcc
Version: 3.4.0
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: java
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: stepan at srnet dot cz
CC: gcc-bugs at gcc dot gnu dot org,java-prs at gcc dot gnu
dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16284