Advertisement

Purity and Side Effect Analysis for Java Programs

  • Alexandru Sălcianu
  • Martin Rinard
Part of the Lecture Notes in Computer Science book series (LNCS, volume 3385)

Abstract

We present a new purity and side effect analysis for Java programs. A method is pure if it does not mutate any location that exists in the program state right before the invocation of the method. Our analysis is built on top of a combined pointer and escape analysis, and is able to determine that methods are pure even when the methods mutate the heap, provided they mutate only new objects.

Our analysis provides useful information even for impure methods. In particular, it can recognize read-only parameters (a parameter is read-only if the method does not mutate any objects transitively reachable from the parameter) and safe parameters (a parameter is safe if it is read-only and the method does not create any new externally visible heap paths to objects transitively reachable from the parameter). The analysis can also generate regular expressions that characterize the externally visible heap locations that the method mutates.

We have implemented our analysis and used it to analyze several applications. Our results show that our analysis effectively recognizes a variety of pure methods, including pure methods that allocate and mutate complex auxiliary data structures.

Keywords

Regular Expression Java Program Impure Method Inside Node Safe Parameter 
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.
    Ananian, C.S.: MIT FLEX compiler infrastructure for Java (1998-2004), Available from http://www.flex-compiler.lcs.mit.edu
  2. 2.
    Birka, A.: Compiler-enforced immutability for the Java language. Technical Report MIT-LCS-TR-908, MIT Laboratory for Computer Science, Revision of Master’s thesis (June 2003)Google Scholar
  3. 3.
    Boyapati, C., Khurshid, S., Marinov, D.: Korat: Automated testing based on Java predicates. In: Proc. ISSTA (2002)Google Scholar
  4. 4.
    Boyapati, C., Rinard, M.C.: A parameterized type system for race-free Java programs. In: Proc. 16th OOPSLA (2001)Google Scholar
  5. 5.
    Burdy, L., Cheon, Y., Cok, D., Ernst, M.D., Kiniry, J., Leavens, G.T., Leino, K.R.M., Poll, E.: An overview of JML tools and applications. Technical Report NII-R0309, Computing Science Institute, Univ. of Nijmegen (2003)Google Scholar
  6. 6.
    Cahoon, B., McKinley, K.S.: Data flow analysis for software prefetching linked data structures in Java. In: Proc. 10th International Conference on Parallel Architectures and Compilation Techniques (2001)Google Scholar
  7. 7.
    Carlisle, M.C., Rogers, A.: Software caching and computation migration in Olden. In: Proc. 5th PPoPP (1995)Google Scholar
  8. 8.
    Cataño, N., Huismann, M.: ChAsE: a static checker for JML’s assignable clause. In: Zuck, L.D., Attie, P.C., Cortesi, A., Mukhopadhyay, S. (eds.) VMCAI 2003. LNCS, vol. 2575, pp. 26–40. Springer, Heidelberg (2002)CrossRefGoogle Scholar
  9. 9.
    Choi, J.-D., Burke, M., Carini, P.: Efficient flow-sensitive interprocedural computation of pointer-induced aliases and side effects. In: Proc. 20th POPL (1993)Google Scholar
  10. 10.
    Clarke, D., Drossopoulou, S.: Ownership, encapsulation and the disjointness of type and effect. In: Proc. 17th OOPSLA (2002)Google Scholar
  11. 11.
    Corbett, J., Dwyer, M., Hatcliff, J., Pasareanu, C.: Bandera: Extracting finite-state models from Java source code. In: Proc. 22nd ICSE (2000)Google Scholar
  12. 12.
    Corbett, J.C.: Using shape analysis to reduce finite-state models of concurrent java programs. Software Engineering and Methodology 9(1) (2000)Google Scholar
  13. 13.
    Crary, K., Walker, D., Morrisett, G.: Typed memory management in a calculus of capabilities. In: Proc. 26th POPL (1999)Google Scholar
  14. 14.
    DeLine, R., Fähndrich, M.: Typestates for objects. In: Odersky, M. (ed.) ECOOP 2004. LNCS, vol. 3086, pp. 465–490. Springer, Heidelberg (2004)CrossRefGoogle Scholar
  15. 15.
    Flanagan, C., Leino, K.R.M., Lilibridge, M., Nelson, G., Saxe, J.B., Stata, R.: Extended Static Checking for Java. In: Proc. PLDI (2002)Google Scholar
  16. 16.
    Hind, M., Pioli, A.: Which pointer analysis should I use? In: Proc. ISSTA (2000)Google Scholar
  17. 17.
    Jouvelot, P., Gifford, D.K.: Algebraic reconstruction of types and effects. In: Proc. 18th POPL (1991)Google Scholar
  18. 18.
    Kuncak, V., Lam, P., Rinard, M.: Role analysis. In: Proc. 29th POPL (2002)Google Scholar
  19. 19.
    Kuncak, V., Leino, K.R.M.: In-place refinement for effect checking. In: 2nd Intl. Workshop on Automated Verification of Infinite-State Systems (2003)Google Scholar
  20. 20.
    Leavens, G.T.: Advances and issues in JML. In: Presentation at the Java Verification Workshop (2002)Google Scholar
  21. 21.
    Leavens, G.T., Baker, A.L., Ruby, C.: Preliminary design of JML. Technical Report 96-06p, Iowa State University (2001)Google Scholar
  22. 22.
    Leino, K.R.M., Poetzsch-Heffter, A., Zhou, Y.: Using data groups to specify and check side effects. In: Proc. PLDI (2002)Google Scholar
  23. 23.
    Lucassen, J.M., Gifford, D.K.: Polymorphic effect systems. In: Proc. 15th POPL (1988)Google Scholar
  24. 24.
    Marinov, D., Andoni, A., Daniliuc, D., Khurshid, S., Rinard, M.: An evaluation of exhaustive testing for data structures. Technical Report MIT-LCS-TR-921, MIT CSAIL, Cambridge, MA (2003)Google Scholar
  25. 25.
    Milanova, A., Rountev, A., Ryder, B.G.: Parameterized object sensitivity for points-to and side-effect analyses for Java. In: Proc. ISSTA (2002)Google Scholar
  26. 26.
    Mueller, P., Poetzsch-Heffter, A., Leavens, G.T.: Modular specification of frame properties in JML. Technical Report TR 02-02, Iowa State University (2002)Google Scholar
  27. 27.
    Rinard, M., Sălcianu, A., Bugrara, S.: A classification system and analysis for aspect-oriented programs. In: Proc. 12th FSE (2004)Google Scholar
  28. 28.
    Rountev, A.: Precise identification of side-effect-free methods in Java. In: IEEE International Conference on Software Maintenance (2004)Google Scholar
  29. 29.
    Salcianu, A.: Pointer analysis and its applications to Java programs. Master’s thesis, MIT Laboratory for Computer Science (2001)Google Scholar
  30. 30.
    Salcianu, A., Rinard, M.: A combined pointer and purity analysis for Java programs. Technical Report MIT-CSAIL-TR-949, MIT CSAIL (2004)Google Scholar
  31. 31.
    Spoto, F., Poll, E.: Static analysis for JML’s assignable clauses. In: Proc. 10th FOOL (2003)Google Scholar
  32. 32.
    Tkachuk, O., Dwyer, M.B.: Adapting side effects analysis for modular program model checking. In: Proc. 11th FSE (2003)Google Scholar
  33. 33.
    Tofte, M., Birkedal, L.: A region inference algorithm. Transactions on Programming Languages and Systems 20(4) (1998)Google Scholar
  34. 34.
    Visser, W., Havelund, K., Brat, G., Park, S.: Model checking programs. In: Proc. 15th ASE (2000)Google Scholar
  35. 35.
    Whaley, J., Rinard, M.: Compositional pointer and escape analysis for Java programs. In: Proc. 14th OOPSLA (1999)Google Scholar

Copyright information

© Springer-Verlag Berlin Heidelberg 2005

Authors and Affiliations

  • Alexandru Sălcianu
    • 1
  • Martin Rinard
    • 1
  1. 1.Massachusetts Institute of Technology 

Personalised recommendations