Inference of Generic Types in Java

Future versions of Java will include support for parametric polymorphism, or generic classes. This will bring many benefits to Java programmers, not least because current Java practise makes heavy use of pseudo-generic classes. Such classes (for example, those in package java.util) have logically...

Full description

Bibliographic Details
Main Authors: Donovan, Alan, Ernst, Michael D.
Published: 2023
Online Access:https://hdl.handle.net/1721.1/149981
_version_ 1811088023645847552
author Donovan, Alan
Ernst, Michael D.
author_facet Donovan, Alan
Ernst, Michael D.
author_sort Donovan, Alan
collection MIT
description Future versions of Java will include support for parametric polymorphism, or generic classes. This will bring many benefits to Java programmers, not least because current Java practise makes heavy use of pseudo-generic classes. Such classes (for example, those in package java.util) have logically generic specifications and documentation, but the type system cannot prove their patterns of use to be safe. This work aims to solve the problem of automatic translation of Java source code into Generic Java (GJ) source code. We present two algorithms that together can be used to translate automatically a Java source program into a semantically-equivalent GJ program with generic types. The first algorithm infers a candidate generalisation for any class, based on the methods of that class in isolation. The second algorithm analyses the whole program; it determines a precise parametric type for every value in the program. Optionally, it also refines the generalisations produced by the first analysis as required by the patterns of use of those classes in client code.
first_indexed 2024-09-23T13:55:01Z
id mit-1721.1/149981
institution Massachusetts Institute of Technology
last_indexed 2024-09-23T13:55:01Z
publishDate 2023
record_format dspace
spelling mit-1721.1/1499812023-03-30T03:34:32Z Inference of Generic Types in Java Donovan, Alan Ernst, Michael D. Future versions of Java will include support for parametric polymorphism, or generic classes. This will bring many benefits to Java programmers, not least because current Java practise makes heavy use of pseudo-generic classes. Such classes (for example, those in package java.util) have logically generic specifications and documentation, but the type system cannot prove their patterns of use to be safe. This work aims to solve the problem of automatic translation of Java source code into Generic Java (GJ) source code. We present two algorithms that together can be used to translate automatically a Java source program into a semantically-equivalent GJ program with generic types. The first algorithm infers a candidate generalisation for any class, based on the methods of that class in isolation. The second algorithm analyses the whole program; it determines a precise parametric type for every value in the program. Optionally, it also refines the generalisations produced by the first analysis as required by the patterns of use of those classes in client code. 2023-03-29T15:37:03Z 2023-03-29T15:37:03Z 2003-03 https://hdl.handle.net/1721.1/149981 MIT-LCS-TR-889 application/pdf
spellingShingle Donovan, Alan
Ernst, Michael D.
Inference of Generic Types in Java
title Inference of Generic Types in Java
title_full Inference of Generic Types in Java
title_fullStr Inference of Generic Types in Java
title_full_unstemmed Inference of Generic Types in Java
title_short Inference of Generic Types in Java
title_sort inference of generic types in java
url https://hdl.handle.net/1721.1/149981
work_keys_str_mv AT donovanalan inferenceofgenerictypesinjava
AT ernstmichaeld inferenceofgenerictypesinjava