重构泛型实例有利于提高软件的复用性和类型安全,但现有重构方法的时间复杂度较高,不适用于即时持续的重构.分析了变量类型传播分析方法在重构中的不足,提出了一种改进的泛型变量类型传播分析方法.该方法通过引入一种可以描述复杂参数化类型关系的泛型类型传播图,以复制节点的方式实现泛型变量属性敏感的类型分析,并通过解决别名问题来提高分析的精度.实例研究表明,可以在与程序规模呈近似线性增长的时间复杂度内实施重构。取得了较满意的效果.
Refactoring generic instantiation is valuable for improving reusability and type safety of software. Most of the existing approaches of refactoring legacy code are not suitable for on-line and persistent refactoring because of their complexity. This paper proposes an instantiation refactoring approach for Java programs based on an extended variable type analysis algorithm. A generic type propagation graph is constructed, and new constructs used to express generic type analysis are added to the graph, so it is suitable to do a generic variable field sensitive type analysis. The paper also discusses how to use alias information to improve the refactoring. The case study shows that the results are satisfactory.