Advertisement

From Public to Private to Absent: Refactoring Java Programs under Constrained Accessibility

  • Friedrich Steimann
  • Andreas Thies
Conference paper
Part of the Lecture Notes in Computer Science book series (LNCS, volume 5653)

Abstract

Contemporary refactoring tools for Java aiding in the restructuring of programs have problems with respecting access modifiers such as public and private: while some tools provide hints that referenced elements may become inaccessible due to the intended restructuring, none we have tested prevent changes that alter the meaning of a program, and none take steps that counteract such alterations. To address these problems, we formalize accessibility in Java as a set of constraint rules, and show how the constraints obtained from applying these rules to a program and an intended refactoring allow us to check the preconditions of the refactoring, as well as to compute the changes of access modifiers necessary to preserve the behaviour of the refactored program. We have implemented our framework as a proof of concept in Eclipse, and demonstrated how it improves applicability and success of an important refactoring in a number of sample programs. That our approach is not limited to Java is shown by comparison with the constraint rules for C# and Eiffel.

Keywords

Access Modifier Accessibility Constraint Dynamic Binding Constraint Rule Access Rule 
These keywords were added by machine and not by the authors. This process is experimental and the keywords may be updated as the learning algorithm improves.

Preview

Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.

References

  1. 1.
    Bouillon, P., Großkinsky, E., Steimann, F.: Controlling accessibility in agile projects with the Access Modifier Modifier. In: Proc. of TOOLS, vol. 46, pp. 41–59 (2008)Google Scholar
  2. 2.
    Daniel, B., Dig, D., Garcia, K., Marinov, D.: Automated testing of refactoring engines. In: Proc. of ESEC/SIGSOFT FSE, pp. 185–194 (2007)Google Scholar
  3. 3.
    Eclipse Java Development Tools Version 3.4.1, http://www.eclipse.org
  4. 4.
    Fowler, M.: Refactoring: Improving the Design of Existing Code. Addison-Wesley, Reading (1999)zbMATHGoogle Scholar
  5. 5.
    Frühwirth, T., Abdennadher, S.: Essentials of Constraint Programming. Springer, Berlin (2003)CrossRefzbMATHGoogle Scholar
  6. 6.
    Gosling, J., Joy, B., Steele, G., Bracha, G.: The Java Language Specification, http://java.sun.com/docs/books/jls/
  7. 7.
    Grothoff, C., Palsberg, J., Vitek, J.: Encapsulating objects with confined types. ACM Trans. Program. Lang. Syst. 29(6), 32 (2007)CrossRefGoogle Scholar
  8. 8.
    Grothoff, C.: Introducing: the Java Access Modifier Inference Tool, http://grothoff.org/christian/xtc/jamit/
  9. 9.
    IntelliJ IDEA Version 8, http://www.jetbrains.com/idea/
  10. 10.
    Kegel, H., Steimann, F.: Systematically refactoring inheritance to delegation in Java. In: Proc. of ICSE, pp. 431–440 (2008)Google Scholar
  11. 11.
    Koved, L., Pistoia, M., Kershenbaum, A.: Access rights analysis for Java. In: Proc. of OOPSLA, pp. 359–372 (2002)Google Scholar
  12. 12.
    Meyer, B.: Object-Oriented Software Construction, 2nd edn. Prentice Hall International, Englewood Cliffs (1997)zbMATHGoogle Scholar
  13. 13.
    Microsoft C# Language Specification v1.2, http://download.microsoft.com
  14. 14.
    Müller, P., Poetzsch-Heffter, A.: Kapselung und Methodenbindung: Javas Designprobleme und ihre Korrektur. In: Java-Informations-Tage, pp. 1–10 (1998)Google Scholar
  15. 15.
    NetBeans Integrated Development Environment Version 6.5, http://www.netbeans.org
  16. 16.
    Opdyke, W.: Refactoring Object-Oriented Frameworks. Ph.D. thesis, University of Illinois at Urbana-Champaign (1992)Google Scholar
  17. 17.
    Parnas, D.L.: On the criteria to be used in decomposing systems into modules. Commun. ACM 15(12), 1053–1058 (1972)CrossRefGoogle Scholar
  18. 18.
    Schäfer, M., Ekman, T., de Moor, O.: Sound and extensible renaming for Java. In: Proc. of OOPSLA, pp. 277–294 (2008)Google Scholar
  19. 19.
    Schirmer, N.: Analysing the Java package/access concepts in Isabelle/HOL. Concurrency — Practice and Experience 16(7), 689–706 (2004)CrossRefGoogle Scholar
  20. 20.
    Tamura, N.: Cream: Class Library for Constraint Programming in Java, http://bach.istc.kobe-u.ac.jp/cream/
  21. 21.
    Tip, F., Kiezun, A., Bäumer, D.: Refactoring for generalization using type constraints. In: Proc. of OOPSLA, pp. 13–26 (2003)Google Scholar
  22. 22.
    Tip, F.: Refactoring using type constraints. In: Riis Nielson, H., Filé, G. (eds.) SAS 2007. LNCS, vol. 4634, pp. 1–17. Springer, Heidelberg (2007)CrossRefGoogle Scholar

Copyright information

© Springer-Verlag Berlin Heidelberg 2009

Authors and Affiliations

  • Friedrich Steimann
    • 1
  • Andreas Thies
    • 1
  1. 1.Lehrgebiet Programmiersysteme Fakultät für Mathematik und InformatikFernuniversität in HagenHagenGermany

Personalised recommendations