RFR: 8244681: Add a warning for possibly lossy conversion in compound assignments [v3]
Magnus Ihse Bursie
ihse at openjdk.java.net
Wed May 11 13:05:46 UTC 2022
On Wed, 11 May 2022 07:45:39 GMT, Adam Sotona <asotona at openjdk.org> wrote:
>> Please review this patch adding new lint option, **lossy-conversions**, to javac to warn about type casts in compound assignments with possible lossy conversions.
>>
>> The new lint warning is shown if the type of the right-hand operand of a compound assignment is not assignment compatible with the type of the variable.
>>
>> The implementation of the warning is based on similar check performed to emit "possible lossy conversion" compilation error for simple assignments.
>>
>> Proposed patch also include complex matrix-style test with positive and negative test cases of lossy conversions in compound assignments.
>>
>> Proposed patch also disables this new lint option in all affected JDK modules and libraries to allow smooth JDK build. Individual cases to address possibly lossy conversions warnings in JDK are already addressed in a separate umbrella issue and its sub-tasks.
>>
>> Thanks for your review,
>> Adam
>
> Adam Sotona has updated the pull request incrementally with one additional commit since the last revision:
>
> 8244681: Add a warning for possibly lossy conversion in compound assignments
> recommended correction of the warning description
Check updates on JDK-8286374 subtasks.
make/modules/jdk.jfr/Java.gmk line 26:
> 24: #
> 25:
> 26: DISABLED_WARNINGS_java += exports lossy-conversions
Note that with the fix of JDK-8286392 (and JDK-8286396) the `lossy-conversions` warning should not be disabled for the JFR code.
In general, you need to check which of the subtasks of JDK-8286374 that has been fixed, and adjust the makefiles accordingly, before pushing this fix.
(In the future, it might be easier to push the fix which disables the warnings first, and then file follow-up bugs on aa per-component basis, and remind them to remove the disabling in the makefile. That way there won't be a race between individual fixes and a "master" bug like this.)
-------------
Changes requested by ihse (Reviewer).
PR: https://git.openjdk.java.net/jdk/pull/8599
More information about the compiler-dev
mailing list