RFR: 8315678: Classfile API ConstantPool::entryCount and ConstantPool::entryByIndex methods are confusing [v3]
Adam Sotona
asotona at openjdk.org
Thu Sep 14 18:32:50 UTC 2023
On Thu, 14 Sep 2023 16:17:35 GMT, Brian Goetz <briangoetz at openjdk.org> wrote:
>> Adam Sotona has updated the pull request with a new target base due to a merge or a rebase. The incremental webrev excludes the unrelated changes brought in by the merge/rebase. The pull request contains four additional commits since the last revision:
>>
>> - fixed javac tests
>> - Merge branch 'master' into JDK-8315678-cp-iterable
>> - fixed tests
>> - 8315678: Classfile API ConstantPool::entryCount and ConstantPool::entryByIndex is confusing
>
> src/java.base/share/classes/jdk/internal/classfile/constantpool/ConstantPool.java line 51:
>
>> 49:
>> 50: /**
>> 51: * {@return the size of the constant pool}
>
> There is still some confusion over the meaning of this method, as "size" (as well as "entry count") could refer to either (a) the number of slots in the constant pool or (b) the number of actual entries in the constant pool, since Constant_{Long,Double} can use two slots. I agree with the name "size" but we should further clarify that this is the number of slots, but that (a) not all slots necessarily correspond to a valid entry (and therefore entryByIndex may fail) and (b) that iterating the pool may yield fewer entries than the size.
I'll mention it in the javadoc
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/15567#discussion_r1326368849
More information about the core-libs-dev
mailing list