The Infer Type Refactoring

Infer Type is a new Eclipse refactoring that helps you decouple your code. If you have already made use of Eclipse refactorings, Infer Type is best introduced as a sibling to Extract Interface, Generalize Type, and Use Supertype Where Possible. However, it cannot be emulated by any combination of these, and Infer Type may turn out to be just what you need in many cases.

Infer Type is the first Eclipse refactoring that computes a new type for your program. The members of this new type are determined by a program’s use of a declaration element (anything that is declared with a type, i.e., a field, a non-void method, a parameter, or a temporary), where use is defined as everything that is accessed from this declaration element or any other declaration element it might get assigned to (through explicit assignments, parameter passing, or return statements). In brief, Infer Type computes the transitive closure of the use of a declaration element under assignment, as determined by a static program (or data flow) analysis, and constructs the new type from this closure. Also, it redeclares the declaration element with the new type and inserts it (the new type) in the type hierarchy so that all assignments remain type correct. In certain cases, Infer Type will compute and insert more than one new type (this may be necessary to keep the program type correct); in others it will detect that a suitable type is already available and suggest its use instead.


If you are in doubt whether Infer Type is at all useful for you, you will find a brief introduction, as well as more advance material here. A quick hands-on example in the context of the Dependency Injection pattern can be found here; it explains much of what you need to know about Infer Type to get started.


To make use of Infer Type, you will have to install it from its Eclipse update site, which is Infer Type builds on GEF 3.1, so you need to install this version of GEF first (3.0.1 has been tested to work also). A step-by-step how-to can be found here.

System requirements

Infer Type has been developed under and tested for Eclipse 3.1.0 (both Windows and Solaris). It requires GEF 3.1 (3.0.1 has been tested to work also) and profits from sufficient RAM (option -vmargs -Xms400M -Xmx400M or higher recommended).

Bugs and known issues

Open Source

Infer Type is part of the intoJ suite and as such open source. You can check it out here.

The IntoJ Team, 2005.