Joh*_*nch 18 java eclipse findbugs java-7
我正在使用Java 1.7,Eclipse 3.7和市场上的FindBugs插件.这个例子和天堂一样好:
class Application
{
public static void main( String[] args )
{
System.out.println( "Bla" );
}
}
Run Code Online (Sandbox Code Playgroud)
此消息在过去不存在,内部实现始终在系统中:
public final static PrintStream out = null;
Run Code Online (Sandbox Code Playgroud)
所以Findbugs是对的,但现在消息发生了什么改变?
Den*_*kiy 15
因为在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();
}
Run Code Online (Sandbox Code Playgroud)
所以我猜他们在java 7中简化了它,并在编译器中添加了一些例外.
JVM在本机代码中管理out,in和err,因此它给出的错误消息毫无意义.
归档时间: |
|
查看次数: |
6259 次 |
最近记录: |