views:

85

answers:

1

I want the Java compiler to give me the highest level of warnings possible. Currently I compile with -Xlint. Is there anyway for me to get more warnings? The warnings provided by Xlint seem paltry.

I just compiled this code with -Xlint and got no warnings:

double x = 22/7;
double y = 22/7;

if(x == y) {
  System.err.println("They are equal!");
}

If I did this in C++ and compiled using gcc with the option -Wfloat-equal, the compiler would issue a warning. Java issues no warning whatsoever. I am using Java 6.

+4  A: 

There are no way to get this warning in javac. Alternatively, use FindBug -- it can check this type of pattern.

J-16 SDiZ