Converting Java']Java programs to use generic libraries

被引:23
作者
Donovan, A [1 ]
Kiezun, A [1 ]
Tschantz, MS [1 ]
Ernst, MD [1 ]
机构
[1] MIT, Comp Sci & Artificial Intelligence Lab, Cambridge, MA 02139 USA
关键词
generic types; parameterized types; parametric polymorphism; type inference; instantiation types; !text type='JS']JS[!/text]R-14; !text type='Java']Java[!/text] 1.5; !text type='Java']Java[!/text] 5; raw types;
D O I
10.1145/1035292.1028979
中图分类号
TP31 [计算机软件];
学科分类号
081202 ; 0835 ;
摘要
Java 1.5 will include a type system (called JSR-14) that supports parametric polymorphism, or generic classes. This will bring many benefits to Java programmers, not least because current Java practice makes heavy use of logically-generic classes, including container classes. Translation of Java source code into semantically equivalent JSR-14 source code requires two steps: parameterization (adding type parameters to class definitions) and instantiation (adding the type arguments at each use of a parameterized class). Parameterization need be done only once for a class, whereas instantiation must be performed for each client, of which there are potentially many more. Therefore, this work focuses on the instantiation problem. We present a technique to determine sound and precise JSR-14 types at each use of a class for which a generic type specification is available. Our approach uses a precise and context-sensitive pointer analysis to determine possible types at allocation sites, and a set-constraint-based analysis (that incorporates guarded, or conditional, constraints) to choose consistent types for both allocation and declaration sites. The technique handles all features of the JSR-14 type system, notably the raw types that provide backward compatibility. We have implemented our analysis in a tool that automatically inserts type parameters into Java code, and we report its performance when applied to a number of real-world Java programs.
引用
收藏
页码:15 / 34
页数:20
相关论文
共 46 条
[41]  
Vallee-Rai R., 1999, P CASCON 1999, P125
[42]  
von Dincklage D., 2004, OOPSLA
[43]  
WANG T, 2001, ICOOP, P99
[44]  
YU D, 2004, POPL 04, P39
[45]  
[No title captured]
[46]  
[No title captured]