The following file is miscompiled by gcj -C: public class Outer extends Thread {
public class Inner extends Thread { private Inner () { start (); } } } It uses the wrong "this" to call start(): Outer$Inner(Outer); Code: 0: aload_0 1: aload_1 2: putfield #12; //Field this$0:LOuter; 5: aload_0 6: invokespecial #15; //Method java/lang/Thread."<init>":()V 9: aload_1 10: invokevirtual #18; //Method java/lang/Thread.start:()V 13: return } Sun's compiler outputs correct code: private Outer$Inner(Outer); Code: 0: aload_0 1: aload_1 2: putfield #1; //Field this$0:LOuter; 5: aload_0 6: invokespecial #2; //Method java/lang/Thread."<init>":()V 9: aload_0 10: invokevirtual #3; //Method start:()V 13: return } The difference is at 9. Note: The bug does not occur if you just replace start() (which is declared in java.lang.Thread) with notify() (which is declared in java.lang.Object). -- Summary: Wrong "this" used when call made to superclass which is also superclass of enclosing class Product: gcc Version: 4.1.0 Status: UNCONFIRMED Severity: normal Priority: P2 Component: java AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: greenrd at greenrd dot org 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=23230