Related types

  • Authors:
  • Johnni Winther;Michael I. Schwartzbach

  • Affiliations:
  • Department of Computer Science, Aarhus University;Department of Computer Science, Aarhus University

  • Venue:
  • Proceedings of the 25th European conference on Object-oriented programming
  • Year:
  • 2011

Quantified Score

Hi-index 0.00

Visualization

Abstract

We have identified a large class of Java errors that are caused by method calls becoming trivial since their formal and actual argument types are unrelated. A classical example is a call to the equals method on a String object with an Integer argument, which always returns false, but similar situations occur for many other methods in common frameworks. Typically, the programmer has provided the wrong arguments and meant for the call to have a non-trivial effect. We give a thorough analysis of the bug patterns found through our experiments which show that such errors are not only frequent in development code but also persist in production code. We formalize the notion of relatedness between actual and formal types and capture this in an extension of the Java 1.6 type system. The resulting compiler, which is fully implemented and backwards compatible, performs a static analysis that is modular and efficient.