Java, now with builtin lint.

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.

The talk described the new features in J2SE 1.5.0 (which is currently available in beta2).

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.

[]

[]

Comments:

Post a Comment:
Comments are closed for this entry.
About

user12607856

Search

Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today