Bug 241438 - The Eclipse Compiler wrongly reports methods as ambiguous if the JDK Compliance level is set to 1.3
Summary: The Eclipse Compiler wrongly reports methods as ambiguous if the JDK Complian...
Status: VERIFIED WORKSFORME
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.3.2   Edit
Hardware: PC Windows XP
: P3 major (vote)
Target Milestone: 3.5 M1   Edit
Assignee: Kent Johnson CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-07-18 16:38 EDT by Daniel Mateescu CLA
Modified: 2008-08-06 15:16 EDT (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Daniel Mateescu CLA 2008-07-18 16:38:11 EDT
In Eclipse 3.3.2, the Eclipse Compiler reports valid methods as ambiguous when the JDK Compliance Level is set to 1.3. In the code below, the compiler will report the error "The method myMethod(Object) is ambiguous for the type ClassA.ClassB". This false abiguity is not reported if the JDK Compliance Level is set to 1.4 or above.
Fixing this issue seems important, because compiling for CLDC requires a 1.3 target.  This issue will occur for any JavaME development, and will impact the MTJ project as well.

public class ClassA {
      public ClassA() {
               ClassB b = new ClassB();
               b.myMethod((String)null); // This gives a compilation error   when target is set to java 1.3
      }

      public void myMethod(Object a) {
      }

      public void myMethod(String a) {
      }


      public class ClassB extends ClassA {
            public void myMethod(Object a) {    
            }
      }
}
 

Please note that the problem disappears when ClassB also overrides the method with a String parameter.
Thank you.
Daniel
Comment 1 Remy Suen CLA 2008-07-18 16:52:25 EDT
I tried compiling the file with '-source 1.2' and '-source 1.3' with JDK 6's javac and it seems to work.
Comment 2 Kent Johnson CLA 2008-07-21 10:12:04 EDT
Which JRE are you compiling against ? Is it also 1.3 ?
Comment 3 Remy Suen CLA 2008-07-21 10:14:01 EDT
(In reply to comment #2)
> Which JRE are you compiling against ? Is it also 1.3 ?

If you were talking to me, then I presume no since I'd assume the JDK 6 javac would just use the JDK 6 libraries.

For the record, I'm pretty sure I've seen something like this when writing eRCP code which targets a CDC-1.0/Foundation-1.0 JRE.
Comment 4 Kent Johnson CLA 2008-07-21 10:18:19 EDT
Actually I was asking Daniel what version his JRE is.

If the JRE version is above 1.3 then that is likely the problem.
Comment 5 Daniel Mateescu CLA 2008-07-21 11:09:56 EDT
(In reply to comment #4)
> Actually I was asking Daniel what version his JRE is.
> If the JRE version is above 1.3 then that is likely the problem.

Hi Kent.
The JRE version I'm using is 1.5.0_06. 
Regards,
Daniel
Comment 6 Daniel Mateescu CLA 2008-07-21 11:14:55 EDT
I still think it's worth fixing it, many JavaME developers are using a JRE above 1.3 and targetting a JDK compliance of 1.3, as CLDC requires.
Daniel
Comment 7 Kent Johnson CLA 2008-07-21 12:48:51 EDT
Actually its the SourceLevel = 1.3 that CLDC needs, NOT the ComplianceLevel.

You want to prevent users from using 1.5 Java constructs in their code.

The ComplianceLevel should match the JRE version.

To duplicate what you've done with javac, you need to run javac 1.3 & point it at the class libraries from 1.5/6.0. Then you'll see the same ambiguous errors.
Comment 8 Olivier Thomann CLA 2008-08-06 15:16:47 EDT
Verified for 3.5M1 using I20080805-1307