Bug 96760 - TreeSet<T>.contains(T t) can throw AbstractMethodError
Summary: TreeSet<T>.contains(T t) can throw AbstractMethodError
Status: RESOLVED WORKSFORME
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.1   Edit
Hardware: Other Linux
: P3 major (vote)
Target Milestone: 3.1 RC1   Edit
Assignee: Kent Johnson CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-05-26 06:24 EDT by Steve Jefferson CLA
Modified: 2005-05-26 12:28 EDT (History)
0 users

See Also:


Attachments
Test case for reporducing problem. (108.81 KB, application/octet-stream)
2005-05-26 06:36 EDT, Steve Jefferson CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Steve Jefferson CLA 2005-05-26 06:24:40 EDT
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)
Comment 1 Steve Jefferson CLA 2005-05-26 06:36:38 EDT
Created attachment 21804 [details]
Test case for reporducing problem.
Comment 2 Kent Johnson CLA 2005-05-26 12:28:55 EDT
This works for me with the latest.

Please double check with RC1 & reopen if it fails for you.