GENERAL TYPES VS. SPECIFIC TYPES
![](grayLine4.gif)
Types describe the ways in which code may be used and reused. A single piece of code can often be used with several types of objects. The identity function, for example, applies to many different classes:
identity(x) {
return x;
}
Assume that identity
is a static method in Java:
public static Object identity(Object x) {
return x;
}
The most general type of the function is Object->Object
(since Object
is the ultimate superclass of every class in Java - the root of the class hierarchy). This general type specifies the legal use of the identity
function. Regardless of the exact class of the argument x
, identity
succeeds, returning an object of the same class.
In the context of a specific program that invokes identity
only on objects of class A
, the method could be represented by the type A->A
. This type is the most specific type possible with respect to the target program, describing the actual use of identity
. If another program calls identity
on both int
and float
objects, its most specific type is {int->int, float->float}
. Note that most specific types are relative to a particular program - in our case, the program being analyzed for call graph construction and modification.
RELEVANCE
As with concrete and abstract types, general and specific types serve different purposes. General types are helpful in determining how a piece of code may be used, while most specific types are essential in determining how the code is used in a certain program. To build a call graph with the smallest possible number of unrealizable call chains, we want the less conservative, more exact type information provided by most specific types in the context of the source program. In fact, the ideal for the template call graph construction and modification upon the deletion of a call site is a combination of the most specific and most concrete types possible. The call graph would thus be smaller and more manageable, and fewer edges would have to be deleted and added during the propagation of changes. But in practice, type inferencers often must settle for slightly more general types due to the demands of practicality. The Cartesian Product Algorithm (and its concomitant typing system) devised by Ole Agesen and used by Professor Souter in her work on incremental call graph updates was designed to infer more specific types than many other type inference schemes.
Home |
DMP |
Project |
Journal |
Contact
Relevant Java Classes |
Delete Call Site |
Template Call Graph |
Research |
Final Report
Previous (Type Handling)
Next (Polymorphism)
©2002, Katie Heise