As far as I can tell, it should be legal in Java 8.
See Table 15.25-E. Type of conditional expression (3rd operand, part III) :
3rd → null 2nd ↓ int lub(Integer,null)
lub(Integer,null) must be an Integer . Basically, if you have a boolean form condition boolean ? int : null boolean ? int : null , the result of the expression must be Integer , and it becomes unboxed. (I think you already know this is happening.)
Thus, according to the specification, it should be the same.
Sounds like a compiler error. Many of them were discovered, I would say, try updating to the latest version.
source share