RFR: 8314258: Add integer_cast for checking conversions don't change the value [v5]
Kim Barrett
kbarrett at openjdk.org
Wed Feb 25 20:35:39 UTC 2026
On Wed, 18 Feb 2026 09:26:48 GMT, Andrew Haley <aph at openjdk.org> wrote:
> I'm not keen on the naked boolean argument to `integer_cast`. Does this look better with an enum type rather than a boolean?
I considered doing that, but it seemed like it might visually dominate a call
site in a way that doesn't seem helpful. For most readers, the interesting
point of a call is the checked conversion, and the potential tautology is a
minor side issue. Also, I don't expect disabling the tautology check to be
common, so it seemed like somewhat excessive ceremony. (Of course, being
infrequent can also be used as an argument for being more explicit via
naming.) But maybe it's not so bad. I've pushed an update that uses a scoped
enum instead of a bool, along with a few real uses (not in tests).
I'm not planning to integrate the uses as is. I think that's roughly all of
the places that currently need it if we universally replaced integer
checked_cast with integer_cast, except I didn't all of the zAddress.inline.hpp
cases.
So what do y'all think?
-------------
PR Comment: https://git.openjdk.org/jdk/pull/29582#issuecomment-3961875913
More information about the hotspot-dev
mailing list