18

I am using Java 1.7, Eclipse 3.7 with the FindBugs plugin from the marketplace. The example is as nice as heaven:

class Application
{
  public static void main( String[] args )
  {
    System.out.println( "Bla" );
  }
}

This message was not present in the past and the internal implementation was always in System:

public final static PrintStream out = null;

So Findbugs IS right, but did something change that the message occur now?

oers
  • 18,436
  • 13
  • 66
  • 75
  • 1
    Not necessarily, there is likely a block somewhere that is assigning `out` to something (a `static` block). Based on the documentation, FindBugs is still experimental and may not always work properly. This sounds like a bug in findbugs...Ii assume the code works if you run it through a standard JVM? – Chris Thompson Jul 06 '11 at 16:22
  • 2
    Sure it works. I think it has something to do with the switch to Java 7 because the initialisation is NOT in the static {} anymore (which I think it was, I don't have a Java 6 version right now). – Johnannes Münch Jul 06 '11 at 16:32

3 Answers3

15

Because in java 6 it looked like this:

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();
}

so I guess they simplified it in java 7 and added some exceptions to the compiler.

JVM manages out, in, and err in native code, so this error message it gives is pointless.

Denis Tulskiy
  • 19,012
  • 6
  • 50
  • 68
11

This is marked as a bug in Findbugs 1.3.9. It has been fixed for Findbugs 2.0, and might be backported.

Thirler
  • 20,239
  • 14
  • 63
  • 92
  • 1
    Unfortunately it's still happening. At least I still get this error by means of the Findbugs plugin of Maven. Which is supposed to use Findbugs 2 as of release 2.3.3. – Jan Goyvaerts Jan 24 '12 at 13:25
  • In that case it might worth reporting the bug again, the comments clearly state it should be fixed in findbugs 2. – Thirler Jan 24 '12 at 15:04
3

This only happens with openjdk, not the sun jdk.

The problem is a patch posted in 2010 to allow system times older than 1970.

http://mail.openjdk.java.net/pipermail/distro-pkg-dev/2010-July/009869.html

Ivan Kelly
  • 204
  • 1
  • 3