RFR: 8313564: Fix -Wconversion warnings in classfile code [v2]

David Holmes dholmes at openjdk.org
Wed Aug 2 23:42:21 UTC 2023


On Wed, 2 Aug 2023 13:40:12 GMT, Coleen Phillimore <coleenp at openjdk.org> wrote:

>> This patch fixes various -Wconversion warnings in classfile code.  I broke the change into commits so the changes are easier to see.
>> Tested with tier1-4.
>
> Coleen Phillimore has updated the pull request incrementally with one additional commit since the last revision:
> 
>   Missed a case that gets -Wconversion warning for ContendedPaddingWidth.  prefetch_data_size() returns uint, so added a checked_cast<> to catch the case where it would return greater than signed int max.

A couple of queries/comments but overall seems reasonable.

Thanbks.

src/hotspot/share/classfile/loaderConstraints.cpp line 498:

> 496:     for (int i = 0; i < len; i++) {
> 497:       LoaderConstraint* probe = set.constraint_at(i);
> 498:       sum += (int)sizeof(*probe) + (probe->num_loaders() * (int)sizeof(ClassLoaderData*));

Can't you just cast the final result to int?

src/hotspot/share/classfile/stringTable.cpp line 891:

> 889: 
> 890:   _shared_table.reset();
> 891:   CompactHashtableWriter writer((int)_items_count, ArchiveBuilder::string_stats());

This makes me question why `Items_count` Is a size_t, when we treat it as an int.

src/hotspot/share/runtime/flags/jvmFlagConstraintsRuntime.cpp line 59:

> 57:   if ((value % BytesPerLong) != 0) {
> 58:     JVMFlag::printError(verbose,
> 59:                         "ContendedPaddingWidth (%u) must be "

Why %u when it is an int?

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

Marked as reviewed by dholmes (Reviewer).

PR Review: https://git.openjdk.org/jdk/pull/15111#pullrequestreview-1559971126
PR Review Comment: https://git.openjdk.org/jdk/pull/15111#discussion_r1282505262
PR Review Comment: https://git.openjdk.org/jdk/pull/15111#discussion_r1282505740
PR Review Comment: https://git.openjdk.org/jdk/pull/15111#discussion_r1282506266


More information about the graal-dev mailing list