On Wed, 6 Sep 2023 08:10:12 GMT, ExE Boss <d...@openjdk.org> wrote: >> 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`.
The size of the pool can never go down so the iterator should behave correctly even when underlying pool is modified. Primary purpose of the iterator is to replace not very intuitive (and frequently coded wrong - even in our own tests) for loop iteration: for(int index = 1; index < pool.size(); index += pool.entryByIndex(index).width()) ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/15567#discussion_r1317355090