Existing code within java.base uses implicit casts for a variety of compound assignments.
8244681: proposes to add compiler warnings for possible lossy conversions
The warnings should be addressed to clear up the warnings by adding explicit casts to replace the implicit casts.
In most cases, the cast matches the type of the right-hand side to type of the compound assignment.
Since these casts are truncating the value, there might be a different refactoring that avoids the cast.
From the CSR:
"If the type of the right-hand operand of a compound assignment is not assignment compatible with the type of the variable, a cast is implied and possible lossy conversion may silently occur. While similar situations are resolved as compilation errors for primitive assignments, there are no similar rules defined for compound assignments."
8244681: proposes to add compiler warnings for possible lossy conversions
The warnings should be addressed to clear up the warnings by adding explicit casts to replace the implicit casts.
In most cases, the cast matches the type of the right-hand side to type of the compound assignment.
Since these casts are truncating the value, there might be a different refactoring that avoids the cast.
From the CSR:
"If the type of the right-hand operand of a compound assignment is not assignment compatible with the type of the variable, a cast is implied and possible lossy conversion may silently occur. While similar situations are resolved as compilation errors for primitive assignments, there are no similar rules defined for compound assignments."
- relates to
-
JDK-8244681 Add a warning for possibly lossy conversion in compound assignments
-
- Resolved
-
-
JDK-8286689 (se) Adjusting to select timeout after EINTR messed up after JDK-8286378
-
- Closed
-