We decided to not use List.of(), Set.of() and Map.of(), preferring Collections.emptyList(), etc. We should have a checkstyle rule to prevent creeping them accidentally in the codebase. Note that we only want to prohibit the non-argument versions, using List.of(a) etc. is fine.

Comment From: dreis2211

May I ask why that decision was taken?

Comment From: dreis2211

And if that is settled already, I guess we can close #28174 , #28175 & #28176

Comment From: mbhave

@dreis2211 We discussed this on the team call today and decided that Collections.emptyList() was more explicit than List.of() for creating empty lists. However, we might decide to change this in the future because there is the consistency argument in favor of List.of(). For #28174, #28175 and #28178, we've decided to put those on hold for now. We won't be doing a blanket replacement across the entire codebase but will approach it piecemeal for new usages. List.of()/Set.of()/Map.of() throw an NPE on contains(null) and will require closer examination than just replacing all occurrences of the Collections methods.

Comment From: dreis2211

The null "safety" is a pro-argument in my book. But of course this might be a change in behaviour in certain cases. I don't have strong feelings either way. But it seemed a bit counter-intuitive to really disallow their usages via checkstyle - also given that we had tickets for using these methods. Thanks for shedding some light on the thought process 👍

Comment From: wilkinsona

@dreis2211 We're only disallowing the use of the zero-argument of() methods. List.of(a), Set.of(a, b), and so on will be permitted and we're already making some use of those methods.

Comment From: dreis2211

Aaah - got it. Misinterpreted this. Thanks for clarifying @wilkinsona

Comment From: mhalbritter

Thanks for the clarification @mbhave and @wilkinsona. I've edited the description to make it more clear that we only want to prohibit the non-args variants.

Comment From: philwebb

Closing in favor of PR #32655. Thanks @bertoltmeier!