On Thu, 5 Jan 2023 01:02:11 GMT, Sergey Bylokhov <s...@openjdk.org> wrote:

>> There's no regression test. However, with the current code (prior to this 
>> change) a call to `Set.of(zeroLengthArray)` returns the same instance as 
>> `Set.of()`, so it's difficult to write a simple functional test for this 
>> change. The test would have to assert that "no HashSet is allocated along 
>> this code path" which is much harder to test and frankly probably isn't 
>> worth it. So, please add one of the `noreg-*` labels to the bug to indicate 
>> the rationale for omitting a regression test.
>> 
>> https://openjdk.org/guide/#jbs-label-dictionary
>> 
>> I'd probably add the `Map.copyOf` change to this PR to avoid some 
>> bug/PR/review overhead. Thanks for mentioning this @shipilev.
>
>> so it's difficult to write a simple functional test for this change.
> 
> It is possible to track that for some "custom" and empty collection the only 
> method will be called is `isEmpty` and nothing else. Not sure how it is 
> useful or not.

@mrserb @stuart-marks I've pushed two additional commits which adds the 
isEmpty-check for Map and List as well, although the improvement there should 
be smaller, especially for Lists.

-------------

PR: https://git.openjdk.org/jdk/pull/11847

Reply via email to