RFR: 8299444 java.util.Set.copyOf allocates needlessly for empty input collections [v2]

Viktor Klang duke at openjdk.org
Tue Jan 24 13:45:29 UTC 2023


On Tue, 24 Jan 2023 11:07:07 GMT, Rémi Forax <forax at openjdk.org> wrote:

>> @stuart-marks Sorry, missed this notification. I initially had the same idea, but decided against it because it forces me to suppress "rawtypes" since `coll instanceof ListN` is not considered to be a rawtype, but `coll instanceof ListN c` is. And currently it won't allow for `coll instanceof ListN<E> c`...
>
> `coll instanceof ListN<?> list` should work.

@forax @stuart-marks Yeah, that works. It's unfortunate that it's not possible to match on the actual (generic) type, as then both sides of the || could use type unification to avoid having to do the cast on the return value as well. Submitted a commit to switch to the wildcard version.

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

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


More information about the core-libs-dev mailing list