RFR: 8377895: Create sizeof_auto, to reduce narrowing conversions [v2]

Leo Korinth lkorinth at openjdk.org
Mon Feb 16 14:04:17 UTC 2026


On Mon, 16 Feb 2026 12:17:59 GMT, Johan Sjölen <jsjolen at openjdk.org> wrote:

>> Leo Korinth has updated the pull request incrementally with one additional commit since the last revision:
>> 
>>   Fix test for platforms that can not handle unsigned max sizes
>
> src/hotspot/share/oops/cpCache.hpp line 199:
> 
>> 197: 
>> 198:  public:
>> 199:   static int size() { return align_metadata_size(sizeof_auto<ConstantPoolCache>() / wordSize); }
> 
> Surely, this should no be a part of this PR?

This line of code is one of the /reasons/ for implementing `sizeof_auto`. Without `sizeof_auto` this expression creates an implicit narrowing conversion (a warning in my emacs, and hopefully a compiler error soon). I can remove the change, but I thought it was a nice way to show its value. 

Do you still want me to remove the fix for an implicit narrowing conversion?

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

PR Review Comment: https://git.openjdk.org/jdk/pull/29716#discussion_r2812578007


More information about the hotspot-dev mailing list