Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-2031987 | 1.4.0 | Neal Gafter | P3 | Closed | Fixed | beta |
The following code has been compiled with Kestrel's javac:
class test {
public static void main (String [] args) {
System.out.println(true?0:false);
if((true?false:0)==(true?false:0));
}
}
According to JLS 15.24.2 "The conditional operator may be used to choose between second and third operands of numeric type, or second and third operands of type boolean, or second and
third operands that are each of either reference type or the null type. All other cases
result in a compile-time error."
So, "Can't convert boolean to int" or something like that error message should appear.
konstantin.boudnik@eng 2000-02-15
class test {
public static void main (String [] args) {
System.out.println(true?0:false);
if((true?false:0)==(true?false:0));
}
}
According to JLS 15.24.2 "The conditional operator may be used to choose between second and third operands of numeric type, or second and third operands of type boolean, or second and
third operands that are each of either reference type or the null type. All other cases
result in a compile-time error."
So, "Can't convert boolean to int" or something like that error message should appear.
konstantin.boudnik@eng 2000-02-15
- backported by
-
JDK-2031987 javac allows to use different types of 2nd and 3rd ops in Conditional Op. ?
- Closed