Enumeration refactoring: a tool for automatically converting Java constants to enumerated types

  • Authors:
  • Raffi Khatchadourian;Benjamin Muskalla

  • Affiliations:
  • Ohio State University, Columbus, OH, USA;EclipseSource, Karlsruhe, Germany

  • Venue:
  • Proceedings of the IEEE/ACM international conference on Automated software engineering
  • Year:
  • 2010

Quantified Score

Hi-index 0.00

Visualization

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.