Pure Danger Tech


JavaOne: Eugene Kuleshov, Misko Hevery on practical byte code

07 May 2008

This BOF was “Practical applications of static bytecode based analysis”. Eugene did the first half of the presentation and went over the basic capabilities of ASM. ASM is a great library for doing bytecode generation, transformation, and analysis. We use ASM a lot at Terracotta so this was mostly review for me but it did fill in a couple questions for me.

Eugene also covered Cobertura, which is a code coverage tool that uses ASM to instrument counters around every method, branch, etc. He showed a nice example of how this can do code coverage for other languages like Groovy as well, including detecting coverage problems that exist only in bytecode and aren’t visible in the source.

After that, Misko Hevery from Google took over and showed some ways they are using ASM to build testing and quality tools at Google. He talked about two tools – the Google Singleton Detector and the Testability Explorer. The Google Singleton Detector has been around for a while and can be used on your code base to detect things matching a classic singleton pattern and also some more subtle singleton variants which they call hingeltons, fingletons, and mingletons”. </p>

They showed some examples of running this on different open source code bases and that led into a discussion of how some singletons are not necessarily a problem as it’s really an issue with mutable global state, so singleton constants aren’t not really an issue.

So, they also developed a tool call Testability Explorer that can examine the bytecode of a project and assign a testability index to each class and display the results. The testability explorer examines a bunch of different stuff related to dependencies and mutable state. You can see the results from many popular open source projects at http://testabilityexplorer.org. Check it out on your own project!