On Tue, 5 Sep 2023 15:25:04 GMT, Adam Sotona <asot...@openjdk.org> wrote:
>> Classfile API `ConstantPool::entryCount` and `ConstantPool::entryByIndex` >> methods are confusing and unsafe to use without knowledge of constant pool >> specification. >> This patch renames `ConstantPool::entryCount` to `ConstantPool::size` and >> adds checks to `ConstantPool::entryByIndex` for invalid or unusable indexes. >> `ConstantPool` newly extends `Iterable<PoolEntry>` for simplified user >> iteration over all pool entries. >> Range checks for invalid index have been added also to >> `ConstantPoo::bootstrapMethodEntry` methods and several `@jvms` javadoc tags >> have been added to pool entries. >> >> Please review. >> >> Thanks, >> Adam > > Adam Sotona has updated the pull request incrementally with one additional > commit since the last revision: > > fixed tests src/java.base/share/classes/jdk/internal/classfile/constantpool/ConstantPool.java line 76: > 74: } > 75: }; > 76: } This iterator isn’t entirely correct, because if the constant pool is modified between the call to `hasNext()` and `next()`, then it may throw `NoSuchElementException`. Additionally, `hasNext()` can go from returning `false` to returning `true`. ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/15567#discussion_r1316903003