Details
-
Bug
-
Status: Closed
-
P2
-
Resolution: Fixed
-
8
-
b122
-
generic
-
generic
-
Verified
Backports
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-8031688 | 9 | Attila Szegedi | P2 | Closed | Fixed | b02 |
JDK-8031260 | 8u5 | Attila Szegedi | P2 | Resolved | Fixed | b03 |
Description
Widening of types allows widening of boolean to int. This causes undesirable results with both ternary operator and return values of functions. Both examples below print "1", when they should print "true":
print((function (x) { return x ? true : 0 })(true))
print((function (x) { if(x) { return true } else { return 0 } })(true))
print((function (x) { return x ? true : 0 })(true))
print((function (x) { if(x) { return true } else { return 0 } })(true))
Attachments
Issue Links
- backported by
-
JDK-8031260 Widening of booleans causes bad results
-
- Resolved
-
-
JDK-8031688 Widening of booleans causes bad results
-
- Closed
-