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 条
[21]  
IGARASHI A, 2001, FOOL
[22]  
IGARASHI A, 2002, ICOOP, P441
[23]  
*JAVASOFT SUN MICR, PROT JSR014 ADD GEN
[24]   A BEHAVIORAL NOTION OF SUBTYPING [J].
LISKOV, BH ;
WING, JM .
ACM TRANSACTIONS ON PROGRAMMING LANGUAGES AND SYSTEMS, 1994, 16 (06) :1811-1841
[25]  
MCADAM B, 2001, SCOTTISH FUNCTIONAL, P159
[26]   THEORY OF TYPE POLYMORPHISM IN PROGRAMMING [J].
MILNER, R .
JOURNAL OF COMPUTER AND SYSTEM SCIENCES, 1978, 17 (03) :348-375
[27]   Lackwit: A program understanding tool based on type inference [J].
OCallahan, R ;
Jackson, D .
PROCEEDINGS OF THE 1997 INTERNATIONAL CONFERENCE ON SOFTWARE ENGINEERING, 1997, :338-348
[28]  
OCALLAHAN R, 2001, THESIS CARNEGIE MELL
[29]  
OHORI A, 1989, OOPSLA, P445
[30]  
PALSBERG J, 1991, OOPSLA 91 CONFERENCE PROCEEDINGS : OBJECT-ORIENTED PROGRAMMING SYSTEMS, LANGUAGES, AND APPLICATIONS, P146, DOI 10.1145/118014.117965