Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » Java Development Tools (JDT) » Compiler error in Juno; same code compiles in Indigo(Variable argument methods produce ambiguous code error in Juno)
Compiler error in Juno; same code compiles in Indigo [message #1043227] Wed, 17 April 2013 08:49 Go to next message
Steve Cohen is currently offline Steve Cohen
Messages: 43
Registered: July 2009
Member
I have a body of code that compiles under Eclipse Indigo. Workspace is configured to use jdk1.6.0_23. M2E plugin is installed. This code compiles in Eclipse, outside of Eclipse and has run without incident for at least two years.

Trying to port this project to Eclipse Juno. Same configuration. M2E in use. Same compiler. No settings I can find appear different. Yet I get a few compiler errors that I can't make go away.

The errors all occur in methods with different signatures involving variable arguments:
       public void errorf(String format, Object... params) {
              errorf(format, null, 0, params);
       }

       public void errorf(String format, Throwable t, Object... params) {
              errorf( format, t, 0, params);
       }

       public void errorf(String format, Throwable t, int errorCode, Object... params) {
              logf(t, Level.ERROR, errorCode, format, params);
       }


The errors occur where these methods are called.

"The method errorf(String, Object[]) is ambiguous for the type LogHelper."

Why should the IDE cause the same compiler to behave differently between Eclipse versions? Can someone point at a setting I may be overlooking that would cause this?
Re: Compiler error in Juno; same code compiles in Indigo [message #1043270 is a reply to message #1043227] Wed, 17 April 2013 09:45 Go to previous messageGo to next message
Steve Cohen is currently offline Steve Cohen
Messages: 43
Registered: July 2009
Member
Found answer myself, here:
http://stackoverflow.com/questions/11323415/is-eclipse-juno-wrong-with-this-ambiguous-method-error
This is apparently an error in jdk5 and jdk6 fixed in jdk7 and Juno is following the correct model even though my project is set for JDK 1.6 compliance. Does Eclipse have jdk7 built in somehow?
Several workarounds are mentioned here but in my case, since all the ambiguous errors are under my control, I found an actual fix that does not do violence to my intent in writing the code as I did. There is only a problem when you precede an Object ... parameter with a primitive type. Changing the method signature of the third method above to

       public void errorf(String format, Throwable t, Integer errorCode, Object... params) {
              logf(t, Level.ERROR, errorCode, format, params);
       }

makes the error go away. I will leave this to a language lawyer (any here?) to explain.
Re: Compiler error in Juno; same code compiles in Indigo [message #1044024 is a reply to message #1043270] Thu, 18 April 2013 08:04 Go to previous message
Stephan Herrmann is currently offline Stephan Herrmann
Messages: 1001
Registered: July 2009
Senior Member
Steve Cohen wrote on Wed, 17 April 2013 15:45
Does Eclipse have jdk7 built in somehow?


Eclipse does not use javac, see, e.g., http://www.eclipse.org/jdt/core/.
Previous Topic:How do I read from the console of the target platform?
Next Topic:Programmatically import formatter preferences
Goto Forum:
  


Current Time: Mon Sep 01 03:41:56 EDT 2014

Powered by FUDForum. Page generated in 0.10137 seconds