因为在 java 6 中它看起来像这样:
public final static PrintStream out = nullPrintStream();
/**
* The following two methods exist because in, out, and err must be
* initialized to null. The compiler, however, cannot be permitted to
* inline access to them, since they are later set to more sensible values
* by initializeSystemClass().
*/
private static PrintStream nullPrintStream() throws NullPointerException {
if (currentTimeMillis() > 0) {
return null;
}
throw new NullPointerException();
}
所以我猜他们在 java 7 中对其进行了简化,并向编译器添加了一些异常。
JVM 在本机代码中管理 out、in 和 err,所以它给出的这个错误消息是没有意义的。