December 1, 2011 is the first JDK8 Warnings Cleanup Day (WCD).
This is an OpenJDK community effort to stamp out warnings in the JDK build. You mean there are warnings when you build the JDK? There certainly are, but they’re fairly well hidden in the log files. In many cases you need to add build options to javac such as -Xlint:all to see them. If you do this, you’ll see that there are over 10,000 warnings emitted by javac during the course of the build. How did they all get there? There are many reasons, but there are two main ones.
Prior to Java SE 5.0, a Java compiler was required to either compile a program without error, or fail to compile a program due to errors. There was no official concept of “warning.” The introduction of generics in Java SE 5.0, however, required a Java compiler to produce unchecked warnings for potentially dangerous uses of raw types. Older code that hadn’t been updated to use generics suddenly compiled with many “Recompile with -Xlint:unchecked” warning messages. There’s still a lot of this obsolescent code in the JDK. In fact, these warning messages account for the majority of warning messages that occur in builds of the JDK.
In addition to these mandatory warnings, javac in JDK1.5 was enhanced to produce warnings about “legal, but suspect and often problematic, program constructs.” (See Java SE 5.0 New Features and Enhancements.) An example of such a construct is a switch statement that “falls through.” The scope of these warnings was expanded significantly in javac in JDK7. The kinds of warnings and options for controlling them are detailed in the JDK7 tool documentation for javac. In particular, javac can produce warnings about undesirable, but relatively harmless, uses of raw types. These “harmless” uses are described in Maurizio Cimadamore’s article, Diagnosing Raw Types.
In the Summer of 2011, Sasha Boulgakov, a summer intern, did some analysis about build warnings and how to reduce them. He discovered that there were over 13,500 warnings issued during the build of the jdk repository alone, that is, not including corba, hotspot, jaxp, jaxws, and langtools repositories. (A notable point is that the langtools team has been quite diligent about warnings, having kept their build at zero warnings for quite some time. Kudos to the langtools team and especially Jon Gibbons for their efforts.) Although Sasha had only a short summer with us, he managed to knock off around 2,800 warnings from the jdk repository’s build. Further work by Oracle engineer Kurchi Hazra has brought this down further to around 10,000 which is where we stand today.
Why are warnings important? Most of them are probably noise and don’t represent real problems. Since the compiler is doing us the favor of pointing out “suspect and often problematic” code, a certain portion of these warnings indicate actual bugs. However, this message is drowned out in all the noise. If we could get rid of all the noise, we’d be able to see the real bugs more clearly.
That brings us to Warnings Cleanup Day.
This is a collaborative effort among the OpenJDK community members (inside and outside of Oracle) to clean up the build warnings. For this first event, we’re focusing on warnings from javac emitted during the build of the jdk repository. (There are also warnings emitted during native code compilation, but that’s a totally different subject.) We don’t have any specific numeric goals, but we’re going to try to knock off as many as we can. You can see the initial announcement here. The main WCD page is here, and the division of labor and status updates will be posted here and updated during the day. Email discussion will occur on email@example.com and some of us will be hanging out on the #openjdk IRC as well.
Let’s clean up those warnings!
Updated 9 Oct 2012 with clarifications on Java language and javac history from Alex Buckley.