On Thu, 3 Dec 2026 03:30:41 GMT, Daisuke Yamazaki <[email protected]> wrote:
>> Please review this fix for `Set.ofLazy` and `Map.ofLazy` behaviour. >> >> When looking up an object that is equal to a stored candidate but is a >> different instance, >> `Set.contains()` and `Map.get()` pass the lookup argument to the computing >> function instead of the stored candidate. >> >> This change stores the candidates in an array and uses the lookup index to >> retrieve the corresponding candidate before calling the computing function. >> >> Regression tests have been added for both `Set` and `Map` to verify that the >> computing function receives the stored candidate. >> >> Tests: >> - `LazySetTest` >> - `tier1` >> >> --------- >> - [x] I confirm that I make this contribution in accordance with the >> [OpenJDK Interim AI Policy](https://openjdk.org/legal/ai). > > Daisuke Yamazaki has updated the pull request incrementally with one > additional commit since the last revision: > > review src/java.base/share/classes/java/util/LazyCollections.java line 243: > 241: @Override > 242: public K keyAt(int index) { > 243: if (index != 0) throw new IndexOutOfBoundsException(); While these are safeguards, we never call keyAt/valueAt without checking the slot number first? Do we really need them? src/java.base/share/classes/java/util/LazyCollections.java line 248: > 246: > 247: @Override > 248: public int valueAt(int index) { Would it make sense to `@ForceInline` these methods? ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/34144#discussion_r4783735282 PR Review Comment: https://git.openjdk.org/jdk/pull/34144#discussion_r4783741971
