Name: sgC58550 Date: 03/25/97
The following program compiles without warnings:
public class warn {
public static void main(String argv[]) {
new warn();
String s;
boolean a = false, b = true;
if (a = b)
s = "Goodbye, cruel world!";
else
s = "Hello, world!";
System.out.println(s);
}
public void warn() {
System.out.println("Constructor");
}
}
However, the assignment of b to a inside the if conditional and
the declaration of a method that has a return type and the same
name as the class (making it look like it's a constructor when
it's not) will very often be not what the programmer meant.
I'm used to compilers such as g++ that give warnings on many
suspect contructions such as the two above, and allow the
user to selectively turn on and off these various warnings.
I'd like to be able to provide javac with command-line options
so that the above code will generate two warnings, or compile
with no warnings, depending on what warnings I'm interested in.
company - UCSB , email - ###@###.###
======================================================================
- duplicates
-
JDK-4128179 # Add a lint-like facility to javac
-
- Closed
-