RFR: 8309692: Fix -Wconversion warnings in javaClasses

Kim Barrett kbarrett at openjdk.org
Tue Jun 13 07:41:58 UTC 2023


On Fri, 9 Jun 2023 16:00:51 GMT, Coleen Phillimore <coleenp at openjdk.org> wrote:

> Please review this trivial patch to remove implicit integer conversions in javaClasses.inline.hpp/cpp files.
> Tested tier1-4.

Oh well, I didn't notice this had already been integrated.

src/hotspot/share/classfile/javaClasses.inline.hpp line 329:

> 327:   if (version > USHRT_MAX || version < 0) version = USHRT_MAX;
> 328:   assert((u2)bci == bci, "bci should be short");
> 329:   return build_int_from_shorts((u2)version, (u2)bci);

How about instead, something like

return build_int_from_shorts((u2)version, checked_cast<u2>(bci));

I guess that loses the explicit message, but seems otherwise clearer to me.

src/hotspot/share/classfile/javaClasses.inline.hpp line 336:

> 334:   assert((u2)mid == mid, "mid should be short");
> 335:   assert((u2)cpref == cpref, "cpref should be short");
> 336:   return build_int_from_shorts((u2)cpref, (u2)mid);

Similarly here, could use

return build_int_from_shorts(checked_cast<u2>(cpref), checked_cast<u2>(mid));

-------------

PR Comment: https://git.openjdk.org/jdk/pull/14397#issuecomment-1588720584
PR Review Comment: https://git.openjdk.org/jdk/pull/14397#discussion_r1227664809
PR Review Comment: https://git.openjdk.org/jdk/pull/14397#discussion_r1227667007


More information about the hotspot-runtime-dev mailing list