Bug 82205

Summary: Problem with compareTo() under JDK 1.5
Product: [Eclipse Project] JDT Reporter: Daniel R Somerfield <dsomerfi>
Component: CoreAssignee: Kent Johnson <kent_johnson>
Status: RESOLVED WORKSFORME QA Contact:
Severity: major    
Priority: P3    
Version: 3.1   
Target Milestone: 3.1 M5   
Hardware: PC   
OS: Windows XP   
Whiteboard:

Description Daniel R Somerfield CLA 2005-01-04 19:56:47 EST
This appears to be an outage in 1.5 implementation, although I am not sure. If
you import the source code for the org.eclipse.jdi.debug (jdimodelsrc.zip), you
will notice an error in PrimitiveValueImpl.compareTo(). It seems that it can't
find the compareTo(Object) method in the Character class, among others.
Interestingly, if you go Character.compareTo(), you will notice that while the
Outline view shows both compareTo() methods, you cannot jump to the
compareTo(Object) method.
Comment 1 Jerome Lanneluc CLA 2005-01-05 05:07:11 EST
Can you please specify the Eclipse build number ? Also do you have a 1.5 rt.jar
library on your classpath, or a 1.4.x one ?
Comment 2 Daniel R Somerfield CLA 2005-01-05 12:22:04 EST
This is the M4 build: 200412162000.

I am running under 1.4.2, but I am using the 1.5 jre that I setup under
"Installed Java Runtime Environments". The 1.5 configuration, my default, is
pointing to the 1.5 rt.jar.
Comment 3 Olivier Thomann CLA 2005-02-02 13:40:04 EST
The Eclipse compiler is right. In 1.5, the
java.lang.Character.compareTo(java.lang.Object) method doesn't exist anymore. It
is a bridge method.
As a bridge method, it cannot be accessed directly.

Try to compile this test case:
public class X {
	public static void main(String[] args) {
		Object o = new Object();
		Character c = new Character('c');
		System.out.println(c.compareTo(o));
	}
}

using javac 1.5.0_01. It doesn't compile.
X.java:5: compareTo(java.lang.Character) in java.lang.Character cannot be
applied to (java.lang.Object)
                System.out.println(c.compareTo(o));
                                    ^
1 error
Only java.lang.Character.compareTo(java.lang.Character) exists in 1.5. In 1.4,
both methods existed.
This seems to be a case where there is no backward compatibility.

Need further investigation.
Comment 4 Kent Johnson CLA 2005-02-02 13:45:45 EST
The jdi code will need to be changed to compile under 1.5.