Skip to main content

Purity and Side Effect Analysis for Java Programs

  • Conference paper
Verification, Model Checking, and Abstract Interpretation (VMCAI 2005)

Part of the book series: Lecture Notes in Computer Science ((LNTCS,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.

This is a preview of subscription content, log in via an institution to check access.

Access this chapter

Chapter
USD 29.95
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
eBook
USD 39.99
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
Softcover Book
USD 54.99
Price excludes VAT (USA)
  • Compact, lightweight edition
  • Dispatched in 3 to 5 business days
  • Free shipping worldwide - see info

Tax calculation will be finalised at checkout

Purchases are for personal use only

Institutional subscriptions

Preview

Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.

References

  1. Ananian, C.S.: MIT FLEX compiler infrastructure for Java (1998-2004), Available from http://www.flex-compiler.lcs.mit.edu

  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. Boyapati, C., Khurshid, S., Marinov, D.: Korat: Automated testing based on Java predicates. In: Proc. ISSTA (2002)

    Google Scholar 

  4. Boyapati, C., Rinard, M.C.: A parameterized type system for race-free Java programs. In: Proc. 16th OOPSLA (2001)

    Google Scholar 

  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. 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. Carlisle, M.C., Rogers, A.: Software caching and computation migration in Olden. In: Proc. 5th PPoPP (1995)

    Google Scholar 

  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)

    Chapter  Google Scholar 

  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. Clarke, D., Drossopoulou, S.: Ownership, encapsulation and the disjointness of type and effect. In: Proc. 17th OOPSLA (2002)

    Google Scholar 

  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. 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. Crary, K., Walker, D., Morrisett, G.: Typed memory management in a calculus of capabilities. In: Proc. 26th POPL (1999)

    Google Scholar 

  14. DeLine, R., Fähndrich, M.: Typestates for objects. In: Odersky, M. (ed.) ECOOP 2004. LNCS, vol. 3086, pp. 465–490. Springer, Heidelberg (2004)

    Chapter  Google Scholar 

  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. Hind, M., Pioli, A.: Which pointer analysis should I use? In: Proc. ISSTA (2000)

    Google Scholar 

  17. Jouvelot, P., Gifford, D.K.: Algebraic reconstruction of types and effects. In: Proc. 18th POPL (1991)

    Google Scholar 

  18. Kuncak, V., Lam, P., Rinard, M.: Role analysis. In: Proc. 29th POPL (2002)

    Google Scholar 

  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. Leavens, G.T.: Advances and issues in JML. In: Presentation at the Java Verification Workshop (2002)

    Google Scholar 

  21. Leavens, G.T., Baker, A.L., Ruby, C.: Preliminary design of JML. Technical Report 96-06p, Iowa State University (2001)

    Google Scholar 

  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. Lucassen, J.M., Gifford, D.K.: Polymorphic effect systems. In: Proc. 15th POPL (1988)

    Google Scholar 

  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. 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. 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. Rinard, M., Sălcianu, A., Bugrara, S.: A classification system and analysis for aspect-oriented programs. In: Proc. 12th FSE (2004)

    Google Scholar 

  28. Rountev, A.: Precise identification of side-effect-free methods in Java. In: IEEE International Conference on Software Maintenance (2004)

    Google Scholar 

  29. Salcianu, A.: Pointer analysis and its applications to Java programs. Master’s thesis, MIT Laboratory for Computer Science (2001)

    Google Scholar 

  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. Spoto, F., Poll, E.: Static analysis for JML’s assignable clauses. In: Proc. 10th FOOL (2003)

    Google Scholar 

  32. Tkachuk, O., Dwyer, M.B.: Adapting side effects analysis for modular program model checking. In: Proc. 11th FSE (2003)

    Google Scholar 

  33. Tofte, M., Birkedal, L.: A region inference algorithm. Transactions on Programming Languages and Systems 20(4) (1998)

    Google Scholar 

  34. Visser, W., Havelund, K., Brat, G., Park, S.: Model checking programs. In: Proc. 15th ASE (2000)

    Google Scholar 

  35. Whaley, J., Rinard, M.: Compositional pointer and escape analysis for Java programs. In: Proc. 14th OOPSLA (1999)

    Google Scholar 

Download references

Author information

Authors and Affiliations

Authors

Editor information

Editors and Affiliations

Rights and permissions

Reprints and permissions

Copyright information

© 2005 Springer-Verlag Berlin Heidelberg

About this paper

Cite this paper

Sălcianu, A., Rinard, M. (2005). Purity and Side Effect Analysis for Java Programs. In: Cousot, R. (eds) Verification, Model Checking, and Abstract Interpretation. VMCAI 2005. Lecture Notes in Computer Science, vol 3385. Springer, Berlin, Heidelberg. https://doi.org/10.1007/978-3-540-30579-8_14

Download citation

  • DOI: https://doi.org/10.1007/978-3-540-30579-8_14

  • Publisher Name: Springer, Berlin, Heidelberg

  • Print ISBN: 978-3-540-24297-0

  • Online ISBN: 978-3-540-30579-8

  • eBook Packages: Computer ScienceComputer Science (R0)

Publish with us

Policies and ethics