Community
Participate
Working Groups
It is possible to get TreeSet<T>.contains(T t) to throw an AbstractMethodError. This occurs on code compiled by Eclipse 3.1.M7 but not for code compiled by Sun 1.5.0_03 JDK. Can provide code for simple test case if required; however code is roughly as follows: 1. Create an interface 'Thing' which extends Comparable<Thing>. 2. Create an implementation of 'Thing', 'ThingImpl' say which provides an an implementation of 'int compareTo(Thing t)'. 3. Create (in a JUnit test case, say) a TreeSet<Thing>, create an instance of ThingImpl and add to the TreeSet. 4. Call 'contains()' on the TreeSet, passing the ThingImpl instance previously added to the set. This should throw an AbstractMethodError with a stack trace something like below. As stated previously, this does not occur with code compiled under Sun JDK 1.5.0_03 but does on code compiled by Eclipse 3.1M7. Also occurs when running Eclipse-generated code under Sun JDK so looks like an Eclipse compiler problem. java.lang.AbstractMethodError: ThingImpl.compareTo(Ljava/lang/Object;)I at java.util.TreeMap.compare(TreeMap.java:1093) at java.util.TreeMap.getEntry(TreeMap.java:347) at java.util.TreeMap.containsKey(TreeMap.java:204) at java.util.TreeSet.contains(TreeSet.java:196) at ThingTest.testIt(ThingTest.java:24) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:585) at junit.framework.TestCase.runTest(TestCase.java:154) at junit.framework.TestCase.runBare(TestCase.java:127) at junit.framework.TestResult$1.protect(TestResult.java:106) at junit.framework.TestResult.runProtected(TestResult.java:124) at junit.framework.TestResult.run(TestResult.java:109) at junit.framework.TestCase.run(TestCase.java:118) at junit.framework.TestSuite.runTest(TestSuite.java:208) at junit.framework.TestSuite.run(TestSuite.java:203) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:474) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:342) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:194)
Created attachment 21804 [details] Test case for reporducing problem.
This works for me with the latest. Please double check with RC1 & reopen if it fails for you.