lastnpe / eclipse-null-eea-augments

Eclipse External null Annotations (EEA) repository
http://lastnpe.org
Eclipse Public License 2.0
41 stars 22 forks source link

System.out probably should not be @Nullable #137

Closed agentgt closed 3 years ago

agentgt commented 3 years ago

System.out being nullable is painful.

It is indeed nullable but in practice it is rarely.

agentgt commented 3 years ago

I suppose one could argue don't use system.out but we do for unit tests where slf4j isn't worth importing.

J-N-K commented 3 years ago

I agree that this is very unfortunatey (as is @Nullable on Optional.orElse) but I don't think we should add technically incorrect annotations. because it is more convenient.

In unit tests you can probably work around that with a single

private static final PrintStream SYSTEM_OUT = Objects.requireNonNull(System.out);
agentgt commented 3 years ago

Yeah I totally agree. I for some reason thought it was very rare but looking at the code its entirely possible and its better to be exact for contracts.