Static Analysis for Java in Eclipse

     

Abstract

  Eclipse (http://www.eclipse.org) is one of the most popular Integrated Development Environments (IDE's), thanks in part to its open-source distribution, its portability, an advanced feature set, and a mature Java development tool chain. Eclipse also provides stable API's for representing and manipulating Java programs, with support for the latest language features in Java 5.0. Moreover, it has at its core a powerful plug-in extension mechanism, allowing developers to extend the environment with tools, views, and analyses to suit specific needs.

At the same time, the sheer size of the Eclipse API's and their complexity make for a daunting learning curve. As a result, in spite of being an ideal platform for hosting both commercial and experimental Java analyses and tools, as of yet few programming researchers have implemented their analyses in Eclipse.

To help bridge this gap between potential and reality, this four-hour tutorial will give participants insight into several important aspects of developing static analyses within the Eclipse IDE and exposing their results to users.

 

Target Audience

  Researchers and practitioners interested in implementing static analyses and tools in the setting of a realistic IDE such as the Eclipse environment

Prerequisites:

  • working knowledge of Eclipse as a development environment for ordinary Java applications
  • knowledge of Java language syntax and semantics
  • basic knowledge of fundamental static analysis techniques


Detailed description

 

Part I: Eclipse Overview (1 hour)

The purpose of this part of the tutorial is to give the participant a feel for the basic flow of plug-in development in general, how to hook into the user interface to trigger analyses and present analysis results, and, most significantly, to describe the core Eclipse Java Development Toolkit (JDT) API's. Topics to be covered:

  • Eclipse plug-in architecture (plug-ins, extension points and extensions), how to create plug-in projects, how to manage plug-in dependencies
  • Contributing user interface actions (e.g. view-specific context menu items)
  • Java-related Eclipse API's (both “JDT/Core” and “JDT/UI”): high-level Java model, abstract syntax trees (AST's), type representations, searching, and type hierarchies

Part II: Use/Def Chains (1.5 hours)

In this part of the tutorial, we'll build an end-to-end solution for displaying and navigating use-def/def-use (UD-/DU-) chains to the developer on demand. Using this facility, the user can, e.g., select a variable reference and hit a keystroke, and its reaching definitions are highlighted. We'll walk through a partial implementation of the algorithm, add the missing pieces, and debug it in action in a real Eclipse run-time workbench. Topics to be covered:

  • Anatomy of a simple static analysis algorithm for calculating local use-def/def-use (UD/DU) chains, with particular attention to its use of the Eclipse Java API's
  • Providing an encapsulation that triggers analyses as UI-invokable gestures for exploring intra-procedural static data-flow relationships in a Java program

Part III: Type Analysis (1.5 hours)

In Part III, we'll walk through the implementation of a type analysis algorithm to detect “overly-specific variables”, show its encapsulation as a “smell detector” extension in a simple framework, and finally implement a simple remediating refactoring/quick-fix using the Eclipse JDT. Topics to be covered:

  • A simple, pluggable “smell detection” framework defined using the standard Eclipse extension-point mechanism
  • Defining a smell detector extension
  • Anatomy of a type analysis engine for Java built on the JDT/UI “type constraint” infrastructure, with a specific analysis to detect overly-specific variables
  • Creating “problem markers” that appear in the Eclipse “Problems View” from analysis results
  • Using the Eclipse JDT's AST rewriting infrastructure to create a refactoring that modifies the declaration of an overly-specific variable to the most general possible type as determined by the analysis engine



Robert M. Fuhrer

Biography:

Since receiving his B.S.E. in Electrical Engineering from Princeton University in 1984, Dr. Fuhrer has been developing tools for designing and implementing hardware and software, including hardware/software codesign and cosimulation, high-speed logic simulation, and combinational verification. He received a PhD in Computer Science from Columbia University in 1999 for his work on synthesis, optimization and verification of asynchronous circuits. Since then, Robert has worked in IBM's Research Division on programming technologies, including static analysis, refactoring, and visual programming languages. Robert has written Eclipse plug-ins, including encapsulations for JavaCC and ESC/Java, and a smell detection framework. He has worked with the Eclipse JDT/UI team in Zurich on advanced refactorings over the last two years, and is the co-author of several refactorings.

Research Staff Member
Program Analysis & Transformation Group
IBM Watson Research Center
rfuhrer@watson.ibm.com