You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Thanks, 'no longer returns null' could have been something like 'no longer returns null when the standard streams are redirected or connected to a virtual terminal'
Huh, thanks. I'd misread the code, too. Indeed, I can produce a null return:
$ cat SystemConsole.java
public class SystemConsole {
public static void main(String[] args) {
System.err.println(System.console());
}
}
$ javac SystemConsole.java && ~/jdk-22-ea+19/bin/java -Djdk.console=nosuchthing SystemConsole > /dev/null
null
I'm hoping that that's at least possible only in the case that the user sets jdk.console (as above), but I wouldn't want to make further assumptions :)
https://errorprone.info/bugpattern/SystemConsoleNull says:
However, it may still return
null
, both from the specification and actual implementation.So I propose to:
(a) rephrase the above sentence to
(b) update the code example to handle the case where
System.console() == null
:The text was updated successfully, but these errors were encountered: