Java, now with builtin lint.
By user12607856 on Jun 21, 2004
A couple of weeks ago, I got a chance to see Josh Bloch and Neal Rafter do one of the talks they will be giving at JavaOne this year. This was in the Auditorium at the Santa Clara campus, and was for Sun employees who might not get a chance to go to the conference sessions at JavaOne.
Lots of great stuff, but something that caught my ear was that the "javac" command now has a -Xlint option that provides lint style output of your Java code.
Cool. So I tried this on JSDT, a Java collaboration toolkit that I wrote, just to see what it would pick up on. I always run lint on my C code, so it's nice to automatically have something similar for Java (yes, I know about Java lint but it's not quite the same thing).
Well first javac in J2SE 1.5 wouldn't compile my code because I was using "enum" as a variable name, and it's now a keyword in the language. That was an easy one to fix. After it successfully compiled, it started giving me lint messages. Lots of them. They boiled down to the following three types:
- warning: [serial] serializable class classname has no definition of serialVersionUID
- warning: [unchecked] unchecked call to addElement(E) as a member of the raw type java.util.Vector
- warning: [unchecked] unchecked call to put(K,V) as a member of the raw type java.util.Hashtable
Nothing life threatening, but they should be easy to fixup. Thanks for adding this facility to the compiler.