Bug 11435 - compiler bug: overwriting implicitely abstract method in anonymous inner class
Summary: compiler bug: overwriting implicitely abstract method in anonymous inner class
Status: RESOLVED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 2.0   Edit
Hardware: All All
: P3 blocker (vote)
Target Milestone: 2.0 M4   Edit
Assignee: Philipe Mulet CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2002-03-15 03:14 EST by Ilja Preuss CLA
Modified: 2002-03-15 07:31 EST (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Ilja Preuss CLA 2002-03-15 03:14:26 EST
The following code results in a compile time error (build 20020214):

  public void Test() {
    AbstractTableModel tm = new AbstractTableModel() {
      public int getColumnCount() {
        return 0;
      }

      public int getRowCount() {
        return 0;
      }

      public Object getValueAt(int rowIndex, int columnIndex) {
        return null;
      }

    };
    tm.getColumnCount(); // <-- compile time error
  }

"The method geColumnCount() is undefined for the type 
javax.swing.table.AbstractTableModel"
Comment 1 Philipe Mulet CLA 2002-03-15 04:24:22 EST
This isn't a compiler bug. Since 1.4, jdk libraries are no longer containing 
default abstract methods (on abstract classes implementing interfaces). This is 
fooling the Eclipse 1.3 compiler diagnosis since their implementation is 
reyling on their existence. Note that Javac 1.3 would refuse alltogether to 
perform against 1.4 libraries (using -bootclasspath option).

So as not to see this error, you can either switch the Eclipse compiler to 1.4 
compliance level (see Workbench>Preferences>Java>Compiler>JDK Compliance), or 
point at 1.3 class libraries if using 1.3 compliance mode.

Also see bug 10701.

Closing

*** This bug has been marked as a duplicate of 10701 ***
Comment 2 Philipe Mulet CLA 2002-03-15 07:30:07 EST
Actually, I take my previous comment back. We should be backward compatible in 
1.3 mode, the absence of default abstract methods occurred since 1.2 targets. 
The testcase of this defect involves 1.4 level classfiles, but the issue could 
be reproduced with any library compiled with target 1.2 and above, and our 
compiler 1.3 will incorrectly react to these.

e.g.

compile in target 1.2 mode the following:
[public abstract class A implements I {
}
interface I {
  void foo();
}
]

then compile in 1.3 source mode (target 1.1), the following source
against the classfile produced by the first compilation.
[public class C {
  void bar(A a){
    a.foo();
  }
}
]

Javac 1.3 accepts this code, and we should too.
Comment 3 Philipe Mulet CLA 2002-03-15 07:31:22 EST
Made the target 1.2 behavior (method lookup) the default one. It has nothing to 
do with the target VM level, we have to accept both situations.

Regression test added.
Fixed