On Mon, 20 Feb 2023 13:24:27 GMT, Tingjun Yuan <d...@openjdk.org> wrote:

>> src/java.base/share/classes/java/util/Set.java line 742:
>> 
>>> 740:         E e1 = it.next();
>>> 741:         if (!it.hasNext()) {
>>> 742:             return Set.of(e0, e1);
>> 
>> Bad change, doesn't handle e0.equals(e1), and this is getting beyond the 
>> original issue
>
>> Bad change, doesn't handle e0.equals(e1), and this is getting beyond the 
>> original issue
> 
> `Set.of(E, E)` handles duplication. If `coll` is 
> `{Jumbo,Regular}EnumSetCompatible`, then we don't have to create the 
> `HashSet`.

no, Set.copyOf explicitly allows duplications, unlike Set.of. You need to read 
the specs so you know what you are doing.

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

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

Reply via email to