FULL PRODUCT VERSION :
java version "1.7.0_01"
Java(TM) SE Runtime Environment (build 1.7.0_01-b08)
Java HotSpot(TM) 64-Bit Server VM (build 21.1-b02, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows [Version 6.1.7601]
A DESCRIPTION OF THE PROBLEM :
Code that was working in Java 6 does not compile with Java 7 anymore.
As the result we can't move on with adopting Java 7 for existing projects.
REGRESSION. Last worked in version 6u29
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Copy provide source code into file B.java and try to compile it using:
>javac B.java
Compilation should fail.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Compilation succeeds and program prints "boolean wins!" to the console.
ACTUAL -
Compilation fails.
ERROR MESSAGES/STACK TRACES THAT OCCUR :
B.java:13: error: reference to m1 is ambiguous, both method m1(boolean,Object...) in A and method m1(Object...) in A match
a.m1(true, "A", new Integer(100), null);
^
1 error
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
class A {
void m1(boolean flag, Object...args) {
System.out.println("boolean wins!");
}
void m1(Object...args) {
System.out.println("DEFAULT");
}
}
public class B {
public static void main(String[] args) {
A a = new A();
a.m1(true, "A", new Integer(100), null);
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
As workaround it is possible to change definition of first m1 method so that it uses Boolean instead of boolean in which case program compiles and runs as expected.