FULL PRODUCT VERSION :
java version "1.6.0_12"
Java(TM) SE Runtime Environment (build 1.6.0_12-b04)
Java HotSpot(TM) Client VM (build 11.2-b01, mixed mode, sharing)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows XP [Version 5.1.2600]
A DESCRIPTION OF THE PROBLEM :
When the types of a conditional operator are incompatible, the error message reads "neither is a subtype of the other". While that is true, the message seems to indicate that it is required that one be a subtype of the other. This is probably left over from the time when that was the case. My reading of the spec is that a conditional operator will always have a valid result type unless one or both of the operand types is void. Perhaps the error message should indicate "void operand not allowed", or something like that.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Compile program.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Error message indicating that void types are not allowed as operands to the conditional operator.
ACTUAL -
Error message that seems to imply that one operand to the conditional operator must be a subtype of the other.
ERROR MESSAGES/STACK TRACES THAT OCCUR :
CondTest.java:3: incompatible types for ?: neither is a subtype of the other
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
public class CondTest {
public static void main(String[] args) {
Object o = ((3 > 2)? "x" : "x".wait());
}
}
---------- END SOURCE ----------