Community
Participate
Working Groups
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"
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 ***
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.
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