Building Useful Program Analysis Tools Using an Extensible Java Compiler

Edward Aftandilian
Siddharth Priya
Sundaresan Krishnan
International Working Conference on Source Code Analysis and Manipulation (SCAM), IEEE (2012), pp. 14-23

Abstract

Large software companies need customized tools to manage their source code. These tools are often built in an ad-hoc fashion, using brittle technologies such as regular expressions and home-grown parsers. Changes in the language
cause the tools to break. More importantly, these ad-hoc tools often do not support uncommon-but-valid code code patterns.

We report our experiences building source-code analysis tools at Google on top of a third-party, open-source, extensible compiler. We describe three tools in use on our Java codebase. The first, Strict Java Dependencies, enforces our dependency policy in order to reduce JAR file sizes and testing load. The second, error-prone, adds new error checks to the compilation process and automates repair of those errors at a whole-codebase scale. The third, Thindex, reduces the indexing burden for a Java IDE so that it can support Google-sized projects.