Compiler error in Juno; same code compiles in Indigo [message #1043227] |
Wed, 17 April 2013 12:49 |
Steve Cohen Messages: 46 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 13:45 |
Steve Cohen Messages: 46 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.
|
|
|
|
Powered by
FUDForum. Page generated in 0.01777 seconds