Please review this PR which proposes we replace `j.u.ArrayDeque` with `j.u.ArrayList` in `jdk.internal.loader.URLClassPath`.
The motivation for using a double-ended queue may have been that "original" search path URLs are added to the tail of the queue while any "loader discovered" class path URLs are inserted at the head such that they are processed first. By splitting these two concerns and processing loader discovered class path URLs separately from the original search path, we no longer need a double-ended queue. We can replace `ArrayDeque` with `ArrayList`. Advantages: * A "hello world" Java program no longer loads `ArrayDeque`, `Deque` and `Queue` (`URLClassPath` is the only consumer of these classes during startup) * One data structure is simpler than two * We no longer need to manage search path URLs across two different collections * Code and comments to dance around `ArrayDeque` calling into lambda too early is no longer a concern and can be removed * I think this PR leaves the code overall simpler and easier to follow. Testing: This PR introduces a new test to verify that URLs disovered via a multi-level tree paths discovered via `Class-Path` JAR attributes are found in the expected DFS order. The ordering aspect seems to lack existing coverage. ------------- Commit messages: - Fold synchronization into the nextURL method - Be specific about which list is consumed tail-first - Fix comments in nextURL - Rename fields and improve their documentation - Add test to verify DFS discovery order of a multi-level Class-Path JAR tree. - Spell fix 'guarded' - Simplify reversed-order adding to loaderPath - Initialize 'loaderPath' ArrayList eagerly - Document that access to the 'path', 'pathCursor', 'loaderPath' and nextURL() method requires holding a lock on 'path' - Revert added leading whitespace - ... and 1 more: https://git.openjdk.org/jdk/compare/a0e6f028...6d21f049 Changes: https://git.openjdk.org/jdk/pull/29288/files Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=29288&range=00 Issue: https://bugs.openjdk.org/browse/JDK-8375580 Stats: 249 lines in 2 files changed: 206 ins; 20 del; 23 mod Patch: https://git.openjdk.org/jdk/pull/29288.diff Fetch: git fetch https://git.openjdk.org/jdk.git pull/29288/head:pull/29288 PR: https://git.openjdk.org/jdk/pull/29288
