Modularly Typesafe Interface Dispatch in JPred

2006 International Workshop on Foundations and Developments of Object-Oriented Languages (FOOL/WOOD 2006), Charleston, South Carolina, January 14, 2006.
Christopher Frost, Todd Millstein
Multiple dispatch generalizes the receiver-oriented dynamic dispatch of traditional object-oriented (OO) languages by allowing the run-time classes of all arguments to be employed. While research over the last decade has shown how to integrate multiple dispatch with the modular static typechecking found in traditional OO languages, that work has been forced to impose unnatural restrictions or modifications in order to safely accommodate multiple inheritance. In the context of Java, the effect has been to make it difficult to dispatch on interfaces.

In this paper, we illustrate how the concept of predicate dispatch, which generalizes multiple dispatch by allowing each method to be guarded by a predicate indicating when the method should be invoked, provides a simple but practical way to support dispatch on interfaces while preserving modular typechecking. We have instantiated our approach in the context of JPred, an existing extension to Java supporting predicate dispatch that previously disallowed dispatch on interfaces altogether. We have formalized our approach in a core subset of JPred and proven an associated type soundness theorem. We have also performed two case studies using JPred, on the JPred compiler itself and on portions of Eclipse, to demonstrate the utility of our approach in practice.

[PDF | Implementation | Project Page]

Superceded by this paper.