On Tue, 30 Jun 2026 02:30:36 GMT, Chen Liang <[email protected]> wrote:
>> As noted in https://bugs.openjdk.org/browse/JDK-8386802, `Util.entryList` >> and `Util.moduleEntryList` copy their input lists using indexed access. This >> is fine for `RandomAccess` lists but can be inefficient for >> sequentially-accessed implementations. >> >> This patch keeps the existing indexed path for `RandomAccess` lists and >> falls back to iteration otherwise. Regression coverage is added for >> non-`RandomAccess` inputs. >> >> Testing: >> - `make CONF_CHECK=ignore java.base-java images` >> - `make CONF_CHECK=ignore test-only >> TEST="test/jdk/jdk/classfile/UtilTest.java"` >> - `make CONF_CHECK=ignore test-only TEST="test/jdk/jdk/classfile"` >> - `make CONF_CHECK=ignore test-only TEST="test/jdk:tier1" >> JTREG="VERBOSE=summary"` >> >> --------- >> - [x] I confirm that I make this contribution in accordance with the >> [OpenJDK Interim AI Policy](https://openjdk.org/legal/ai). > > Let's just keep the iterator loop and remove the `get` loop for clarity. @liach > the iterator can throw NSEE if the list shrinks unexpectedly That likely won’t happen, as the `Iterator` traversal ends when `hasNext()` returns `false`. The fix for that case is to check that `i == result.length` after the end of the loop, and throw an exception[^1] if not. [^1]: [`ConcurrentModificationException`] is probably appropriate here [`ConcurrentModificationException`]: https://docs.oracle.com/en/java/javase/26/docs/api/java.base/java/util/ConcurrentModificationException.html ------------- PR Comment: https://git.openjdk.org/jdk/pull/31719#issuecomment-4845126649
