RFR: 8307312: Replace "int which" with "int cp_index" in constantPool

Matias Saavedra Silva matsaave at openjdk.org
Mon Jul 31 15:05:55 UTC 2023


On Sun, 30 Jul 2023 22:12:42 GMT, David Holmes <dholmes at openjdk.org> wrote:

>> Many accessors in the constant pool take an argument "int which" that is meant to represent an ambiguous index. Despite this, several methods in the API use "int which" when the argument is exclusively a constant pool index. This patch aims to rename all of these instances to "int cp_index" in order to be more clear and to distinguish methods that take constant pool indices and methods that use derived indices.
>> 
>> The callers have been updated to use more clear naming as well. Verified with tier 1-5 tests.
>
> src/hotspot/share/oops/constantPool.cpp line 456:
> 
>> 454: }
>> 455: 
>> 456: void ConstantPool::string_at_put(int obj_index, oop str) {
> 
> Should `obj_index` be `cp_index` here?

In this case `obj_index` refers to an index into the resolved references array. The argument `which` was supposed to refer to a constant pool index but it was not actually used.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/15027#discussion_r1279441912


More information about the hotspot-dev mailing list