Abstract

Parametric methods are recognized as a very useful tool for reusing code and augmenting the expressiveness of an object-oriented language providing parametric classes. This paper focuses on their implementation techniques for Java. Existing proposals for extending Java with parametric polymorphism are outlined, showing and discussing the basic implementation techniques: type-erasure, code-expansion and type-passing. Up until now, only type-erasure and code-expansion have been exploited for the implementation of parametric methods, but they suffer from some problems. Basically, type-erasure is unable to support parametric types at run-time, while code-expansion generally leads to significant increase of both disk and memory overhead. The main goal of this paper is to study a type-passing approach aimed at tackling these issues. This is based on the management of method descriptors, which are objects passed to the method bodies at invocation-time, and which carry information on the instantiation of the method’s type parameters. Run-time efficiency is guaranteed thanks to a special treatment of descriptors deferring their creation at load-time. Dynamic dispatching of method calls is supported by exploiting a data structure called the Virtual Parametric Methods Table, resembling Virtual Methods Tables of C++. The approach here presented turns out to be a significant alternative to the existing proposals for implementing generics in Java, supporting parametric types at run-time without unnecessary code footprint.

Full Text
Published version (Free)

Talk to us

Join us for a 30 min session where you can share your feedback and ask us any queries you have

Schedule a call