ABSTRACT
Java 5 introduces several new features that offer significant improvements over older Java technology. We consider the new enum construct, which provides language support for enumerated types. Before Java 5, programmers needed to employ various patterns to compensate for the absence of enumerated types in Java. Unfortunately, these compensation patterns lack several highly desirable properties of the enum construct, most notably, type-safety. We demonstrate an automated refactoring tool called Convert Constants to Enum for transforming legacy Java code to use the new enumeration construct. An interprocedural type inferencing algorithm that tracks the flow of enumerated values drives the approach, and the tool is implemented as a seamless extension to existing refactoring support in Eclipse. The resulting code is semantically equivalent to the original, increasingly type-safe, easier to comprehend, less complex, and supports separate compilation.
- }}J. Bloch. Effective Java Programming Language Guide. Prentice Hall PTR, 2001. Google ScholarDigital Library
- }}A. V. Deursen and L. Moonen. Type inference for COBOL systems. In WCRE, 1998. Google ScholarDigital Library
- }}A. V. Deursen and L. Moonen. Understanding cobol systems using inferred types. In IWPC, 1999.Google ScholarCross Ref
- }}P. H. Eidorff, F. Henglein, C. Mossin, H. Niss, M. H. Sørensen, and M. Tofte. Annodomini: From type theory to year 2000 conversion tool. In POPL, 1999. Google ScholarDigital Library
- }}M. Fowler. Refactoring: Improving the Design of Existing Code. Addison-Wesley Professional, 1999. Google ScholarDigital Library
- }}R. Fuhrer, F. Tip, A. Kieżun, J. Dolby, and M. Keller. Efficiently refactoring Java applications to use generic libraries. In ECOOP, pages 71--96, July 2005. Google ScholarDigital Library
- }}J. M. Gravley and A. Lakhotia. Identifying enumeration types modeled with symbolic constants. In WCRE, 1996. Google ScholarDigital Library
- }}J. Kerievsky. Refactoring to Patterns. Pearson, 2004. Google ScholarDigital Library
- }}R. Khatchadourian, J. Sawin, and A. Rountev. Automated refactoring of legacy Java software to enumerated types. In ICSM, 2007.Google ScholarCross Ref
- }}A. Kie&3380;un, M. D. Ernst, F. Tip, and R. M. Fuhrer. Refactoring for parameterizing Java classes. In ICSE, 2007.Google Scholar
- }}B. C. Pierce. Types and programming languages. MIT Press, 2002. Google ScholarDigital Library
- }}G. Ramalingam, J. Field, and F. Tip. Aggregate structure identification and its application to program analysis. In POPL, 1999. Google ScholarDigital Library
- }}W. Tansey and E. Tilevich. Annotation refactoring: inferring upgrade transformations for legacy applications. In OOPSLA, 2008. Google ScholarDigital Library
Index Terms
- Enumeration refactoring: a tool for automatically converting Java constants to enumerated types
Recommendations
Automated refactoring of legacy Java software to enumerated types
Modern Java languages introduce several new features that offer significant improvements over older Java technology. In this article we consider the new enum construct, which provides language support for enumerated types. Prior to recent Java languages,...
Evaluating the Java Native Interface JNI: Leveraging Existing Native Code, Libraries and Threads to a Running Java Virtual Machine
This article aims to explore JNI features and to discover fundamental operations of the Java programming language, such as arrays, objects, classes, threads and exception handling, and to illustrate these by using various algorithms and code samples. ...
Object and reference immutability using Java generics
ESEC-FSE '07: Proceedings of the the 6th joint meeting of the European software engineering conference and the ACM SIGSOFT symposium on The foundations of software engineeringA compiler-checked immutability guarantee provides useful documentation, facilitates reasoning, and enables optimizations. This paper presents Immutability Generic Java (IGJ), a novel language extension that expresses immutability without changing Java'...
Comments