GCJ miscompiles part of the classpath AWT demo application in:

classpath/examples/gnu/classpath/examples/awt/Demo.java

In an anonoymous inner class ActionListener implementation, an unqualified call
to a superclass of the outer class is called on "this" instead of the outer
class.

This happens with either source->native or source->bytecode compilation.

class Super
{
    void dispose()
    {
      System.out.println("OK");
    }
}

public class PR27812
{
  public static void main(String[] args)
  {
    Y y = new Y();
    y.y();
  }

  static interface I
  {
    abstract void actionPerformed();
  }

  static class Y extends Super
  {
    void y()
    {
      new I () {
          public void actionPerformed () {
            dispose();
          }
        }.actionPerformed();
    }
  }
}

$ gcj -C PR27812.java
$ gij PR27812
Exception in thread "main" java.lang.NoSuchMethodError: method
PR27812$Y$1.dispose with signature ()V was not found.
   at PR27812$Y$1.actionPerformed (PR27812.java:28)
   at PR27812$Y.y (PR27812.java:30)
   at PR27812.main (PR27812.java:14)


-- 
           Summary: Classpath AWT Demo: anonymous class call miscompilation
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: java
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: mckinlay at redhat dot com


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=27812

Reply via email to