Skip to main content
Erschienen in: Automated Software Engineering 4/2017

10.12.2016

Automated refactoring of legacy Java software to enumerated types

verfasst von: Raffi Khatchadourian

Erschienen in: Automated Software Engineering | Ausgabe 4/2017

Einloggen

Aktivieren Sie unsere intelligente Suche, um passende Fachinhalte oder Patente zu finden.

search-config
loading …

Abstract

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, programmers needed to employ various patterns (e.g., the weak enum pattern) 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 present a novel fully-automated approach for transforming legacy Java code to use the new enumeration construct. This semantics-preserving approach increases type safety, produces code that is easier to comprehend, removes unnecessary complexity, and eliminates brittleness problems due to separate compilation. At the core of the proposed approach is an interprocedural type inferencing algorithm which tracks the flow of enumerated values. The algorithm was implemented as an open source, publicly available Eclipse plug-in and evaluated experimentally on 17 large Java benchmarks. Our results indicate that analysis cost is practical and the algorithm can successfully refactor a substantial number of fields to enumerated types. This work is a significant step towards providing automated tool support for migrating legacy Java software to modern Java technologies.

Sie haben noch keine Lizenz? Dann Informieren Sie sich jetzt über unsere Produkte:

Springer Professional "Wirtschaft+Technik"

Online-Abonnement

Mit Springer Professional "Wirtschaft+Technik" erhalten Sie Zugriff auf:

  • über 102.000 Bücher
  • über 537 Zeitschriften

aus folgenden Fachgebieten:

  • Automobil + Motoren
  • Bauwesen + Immobilien
  • Business IT + Informatik
  • Elektrotechnik + Elektronik
  • Energie + Nachhaltigkeit
  • Finance + Banking
  • Management + Führung
  • Marketing + Vertrieb
  • Maschinenbau + Werkstoffe
  • Versicherung + Risiko

Jetzt Wissensvorsprung sichern!

Springer Professional "Technik"

Online-Abonnement

Mit Springer Professional "Technik" erhalten Sie Zugriff auf:

  • über 67.000 Bücher
  • über 390 Zeitschriften

aus folgenden Fachgebieten:

  • Automobil + Motoren
  • Bauwesen + Immobilien
  • Business IT + Informatik
  • Elektrotechnik + Elektronik
  • Energie + Nachhaltigkeit
  • Maschinenbau + Werkstoffe




 

Jetzt Wissensvorsprung sichern!

Springer Professional "Wirtschaft"

Online-Abonnement

Mit Springer Professional "Wirtschaft" erhalten Sie Zugriff auf:

  • über 67.000 Bücher
  • über 340 Zeitschriften

aus folgenden Fachgebieten:

  • Bauwesen + Immobilien
  • Business IT + Informatik
  • Finance + Banking
  • Management + Führung
  • Marketing + Vertrieb
  • Versicherung + Risiko




Jetzt Wissensvorsprung sichern!

Fußnoten
1
This example was inspired by one of the authors’ work at the Center for Automotive Research at the Ohio State University.
 
2
A similar pattern called Type Codes is described in Fowler (1999) and Kerievsky (2004).
 
3
We exclude boolean from this list for several reasons: (1) The type has only two values, true and false, thus any transformed enum type can only have two members and (2) our algorithm becomes simpler due to this exclusion.
 
4
Although the focus of our tool is to refactor legacy Java software to utilize the new enum construct, we do not discriminate against current Java software (e.g., those written in Java \(\ge 5\)). In this case, uses of the enum identifier for the purpose of declaring language enumerated types is acceptable.
 
5
Larger in terms of the maximum capacity held by values of the primitive type in bytes.
 
8
java5 denotes the package java. included in the Java 5 JDK.
 
9
Excludes boolean types.
 
10
The term interface is used here not to solely denote that of Java interfaces, but instead to denote the broader notion of interfaces which, in Java, would also include class declarations.
 
11
inter-program or inter-module in the case of COBOL.
 
Literatur
Zurück zum Zitat Bäumer, D., Gamma, E., Kiezun, A.: Integrating refactoring support into a Java development tool. In: OOPSLA’01 Companion (2001) Bäumer, D., Gamma, E., Kiezun, A.: Integrating refactoring support into a Java development tool. In: OOPSLA’01 Companion (2001)
Zurück zum Zitat Bloch, J.: Effective Java Programming Language Guide. Prentice Hall PTR, Upper Saddle River (2001) Bloch, J.: Effective Java Programming Language Guide. Prentice Hall PTR, Upper Saddle River (2001)
Zurück zum Zitat Bracha, G., Cohen, N., Kemper, C., Odersky, M., Stoutamire, D., Thorup, K., Wadler, P.: Adding generics to the Java programming language: public draft specification, version 2.0. Tech. Rep. JSR 014, Java Community Process (2003) Bracha, G., Cohen, N., Kemper, C., Odersky, M., Stoutamire, D., Thorup, K., Wadler, P.: Adding generics to the Java programming language: public draft specification, version 2.0. Tech. Rep. JSR 014, Java Community Process (2003)
Zurück zum Zitat Dean, J., Grove, D., Chambers, C.: Optimization of object-oriented programs using static class hierarchy analysis. In: European Conference on Object-Oriented Programming, pp. 77–101 (1995) Dean, J., Grove, D., Chambers, C.: Optimization of object-oriented programs using static class hierarchy analysis. In: European Conference on Object-Oriented Programming, pp. 77–101 (1995)
Zurück zum Zitat Deursen, A.V., Moonen, L.: Type inference for COBOL systems. In: Working Conference on Reverse Engineering, IEEE Computer Society, Washington, DC, USA, pp. 220–230 (1998). doi:10.1109/WCRE.1998.723192 Deursen, A.V., Moonen, L.: Type inference for COBOL systems. In: Working Conference on Reverse Engineering, IEEE Computer Society, Washington, DC, USA, pp. 220–230 (1998). doi:10.​1109/​WCRE.​1998.​723192
Zurück zum Zitat Deursen, A.V., Moonen, L.: Understanding cobol systems using inferred types. In: International Workshop on Program Comprehension, IEEE Computer Society, Washington, DC, pp. 74–81 (1999). doi:10.1109/WPC.1999.777746 Deursen, A.V., Moonen, L.: Understanding cobol systems using inferred types. In: International Workshop on Program Comprehension, IEEE Computer Society, Washington, DC, pp. 74–81 (1999). doi:10.​1109/​WPC.​1999.​777746
Zurück zum Zitat Dig, D., Marrero, J., Ernst, M.D. (2009) Refactoring sequential java code for concurrency via concurrent libraries. In: International Conference on Software Engineering, IEEE Computer Society, Washington, DC, ICSE ’09, pp. 397–407. doi:10.1109/ICSE.2009.5070539 Dig, D., Marrero, J., Ernst, M.D. (2009) Refactoring sequential java code for concurrency via concurrent libraries. In: International Conference on Software Engineering, IEEE Computer Society, Washington, DC, ICSE ’09, pp. 397–407. doi:10.​1109/​ICSE.​2009.​5070539
Zurück zum Zitat Donovan, A., Kiezun, A., Tschantz, M.S., Ernst, M.D.: Converting Java programs to use generic libraries. In: Object-Oriented Programming, Systems, Languages and Applications, pp. 15–34 (2004) Donovan, A., Kiezun, A., Tschantz, M.S., Ernst, M.D.: Converting Java programs to use generic libraries. In: Object-Oriented Programming, Systems, Languages and Applications, pp. 15–34 (2004)
Zurück zum Zitat Eidorff, P.H., Henglein, F., Mossin, C., Niss, H., Sørensen, M.H., Tofte, M.: Annodomini: from type theory to year 2000 conversion tool. In: ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, pp. 1–14. ACM Press, New York, NY (1999). doi:10.1145/292540.292543 Eidorff, P.H., Henglein, F., Mossin, C., Niss, H., Sørensen, M.H., Tofte, M.: Annodomini: from type theory to year 2000 conversion tool. In: ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, pp. 1–14. ACM Press, New York, NY (1999). doi:10.​1145/​292540.​292543
Zurück zum Zitat Fowler, M.: Refactoring: Improving the Design of Existing Code. Addison-Wesley Professional, Reading (1999) Fowler, M.: Refactoring: Improving the Design of Existing Code. Addison-Wesley Professional, Reading (1999)
Zurück zum Zitat Fuhrer, R., Tip, F., Kiezun, A., Dolby, J., Keller, M.: Efficiently refactoring Java applications to use generic libraries. In: European Conference on (2005) Object-Oriented Programming, pp. 71–96 Fuhrer, R., Tip, F., Kiezun, A., Dolby, J., Keller, M.: Efficiently refactoring Java applications to use generic libraries. In: European Conference on (2005) Object-Oriented Programming, pp. 71–96
Zurück zum Zitat Gamma, E., Helm, R., Johnson, R., Vlissides, J.: Design Patterns: Elements of Reusable Object-Oriented Software. Addison-Wesley, Boston (1995)MATH Gamma, E., Helm, R., Johnson, R., Vlissides, J.: Design Patterns: Elements of Reusable Object-Oriented Software. Addison-Wesley, Boston (1995)MATH
Zurück zum Zitat Gosling, J., Joy, B., Steele, G., Bracha, G.: Java\(^{{\rm TM}}\) Language Specification, 3rd edn. Addison-Wesley, Boston (2005) Gosling, J., Joy, B., Steele, G., Bracha, G.: Java\(^{{\rm TM}}\) Language Specification, 3rd edn. Addison-Wesley, Boston (2005)
Zurück zum Zitat Gravley, J.M., Lakhotia, A.: Identifying enumeration types modeled with symbolic constants. In: Working Conference on Reverse Engineering, IEEE Computer Society, Washington, DC, p. 227 (1996) Gravley, J.M., Lakhotia, A.: Identifying enumeration types modeled with symbolic constants. In: Working Conference on Reverse Engineering, IEEE Computer Society, Washington, DC, p. 227 (1996)
Zurück zum Zitat Kerievsky, J.: Refactoring to Patterns. Pearson Higher Education, London (2004)CrossRef Kerievsky, J.: Refactoring to Patterns. Pearson Higher Education, London (2004)CrossRef
Zurück zum Zitat Khatchadourian, R., Muskalla, B.: Enumeration refactoring: a tool for automatically converting java constants to enumerated types. In: International Conference on Automated Software Engineering, ACM, New York, NY, ASE ’10, pp. 181–182 (2010). doi:10.1145/1858996.1859036 Khatchadourian, R., Muskalla, B.: Enumeration refactoring: a tool for automatically converting java constants to enumerated types. In: International Conference on Automated Software Engineering, ACM, New York, NY, ASE ’10, pp. 181–182 (2010). doi:10.​1145/​1858996.​1859036
Zurück zum Zitat Khatchadourian, R., Sawin, J., Rountev, A.: Automated refactoring of legacy Java software to enumerated types. In: International Conference on Software Maintenance, IEEE, ICSM 2007, pp. 224–233 (2007). doi:10.1109/ICSM.2007.4362635 Khatchadourian, R., Sawin, J., Rountev, A.: Automated refactoring of legacy Java software to enumerated types. In: International Conference on Software Maintenance, IEEE, ICSM 2007, pp. 224–233 (2007). doi:10.​1109/​ICSM.​2007.​4362635
Zurück zum Zitat Kiezun, A., Ernst, M.D., Tip, F., Fuhrer, R.M. (2007) Refactoring for parameterizing Java classes. In: International Conference on Software Engineering Kiezun, A., Ernst, M.D., Tip, F., Fuhrer, R.M. (2007) Refactoring for parameterizing Java classes. In: International Conference on Software Engineering
Zurück zum Zitat Knuth, D.E.: Semantics of context-free languages. Theory Comput. Syst. 2(2) (1967) Knuth, D.E.: Semantics of context-free languages. Theory Comput. Syst. 2(2) (1967)
Zurück zum Zitat Kumar, A., Sutton, A., Stroustrup, B.: Rejuvenating C++ programs through demacrofication. In: International Conference on Software Maintenance, IEEE, pp. 98–107 (2012) Kumar, A., Sutton, A., Stroustrup, B.: Rejuvenating C++ programs through demacrofication. In: International Conference on Software Maintenance, IEEE, pp. 98–107 (2012)
Zurück zum Zitat Palsberg, J., Schwartzbach, M.I.: Object-Oriented Type Systems. Wiley, Chichester (1994)MATH Palsberg, J., Schwartzbach, M.I.: Object-Oriented Type Systems. Wiley, Chichester (1994)MATH
Zurück zum Zitat Pierce, B.C.: Types and Programming Languages. MIT Press, Cambridge (2002)MATH Pierce, B.C.: Types and Programming Languages. MIT Press, Cambridge (2002)MATH
Zurück zum Zitat Ramalingam, G., Field, J., Tip, F.: Aggregate structure identification and its application to program analysis. In: ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, ACM Press, New York, NY, pp. 119–132 (1999). doi:10.1145/292540.292553 Ramalingam, G., Field, J., Tip, F.: Aggregate structure identification and its application to program analysis. In: ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, ACM Press, New York, NY, pp. 119–132 (1999). doi:10.​1145/​292540.​292553
Zurück zum Zitat Steimann, F., Siberski, W., Kúhne, T.: Towards the systematic use of interfaces in java programming. In: PPPJ (2003) Steimann, F., Siberski, W., Kúhne, T.: Towards the systematic use of interfaces in java programming. In: PPPJ (2003)
Zurück zum Zitat Steimann, F., Mayer, P., Meißner, A.: Decoupling classes with inferred interfaces. In: ACM Symposium on Applied Computing, pp. 1404–1408 (2006) Steimann, F., Mayer, P., Meißner, A.: Decoupling classes with inferred interfaces. In: ACM Symposium on Applied Computing, pp. 1404–1408 (2006)
Zurück zum Zitat Sutter, B.D., Tip, F., Dolby, J.: Customization of java library classes using type constraints and profile information. In: European Conference on Object-Oriented Programming, pp. 585–610 (2004) Sutter, B.D., Tip, F., Dolby, J.: Customization of java library classes using type constraints and profile information. In: European Conference on Object-Oriented Programming, pp. 585–610 (2004)
Zurück zum Zitat Tip, F., Kiezun, A., Bäumer, D.: Refactoring for generalization using type constraints. In: Object-Oriented Programming, Systems, Languages and Applications, pp. 13–26 (2003) Tip, F., Kiezun, A., Bäumer, D.: Refactoring for generalization using type constraints. In: Object-Oriented Programming, Systems, Languages and Applications, pp. 13–26 (2003)
Zurück zum Zitat Tip, F., Fuhrer, R., Dolby, J., Kiezun, A.: Refactoring techniques for migrating applications to generic Java container classes. Tech. Rep. RC 23238, IBM T.J. Watson Research Center (2004) Tip, F., Fuhrer, R., Dolby, J., Kiezun, A.: Refactoring techniques for migrating applications to generic Java container classes. Tech. Rep. RC 23238, IBM T.J. Watson Research Center (2004)
Zurück zum Zitat Vallée-Rai, R., et al.: Optimizing Java bytecode using the Soot framework: is it feasible? International Conference on Compiler Construction, LNCS, Vol. 1781, pp. 18–34 (2000) Vallée-Rai, R., et al.: Optimizing Java bytecode using the Soot framework: is it feasible? International Conference on Compiler Construction, LNCS, Vol. 1781, pp. 18–34 (2000)
Zurück zum Zitat von Dincklage, D., Diwan, A.: Converting Java classes to use generics. In: Object-Oriented Programming, Systems, Languages and Applications, pp. 1–14 (2004) von Dincklage, D., Diwan, A.: Converting Java classes to use generics. In: Object-Oriented Programming, Systems, Languages and Applications, pp. 1–14 (2004)
Metadaten
Titel
Automated refactoring of legacy Java software to enumerated types
verfasst von
Raffi Khatchadourian
Publikationsdatum
10.12.2016
Verlag
Springer US
Erschienen in
Automated Software Engineering / Ausgabe 4/2017
Print ISSN: 0928-8910
Elektronische ISSN: 1573-7535
DOI
https://doi.org/10.1007/s10515-016-0208-8

Weitere Artikel der Ausgabe 4/2017

Automated Software Engineering 4/2017 Zur Ausgabe