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.
Preview
Unable to display preview. Download preview PDF.
Similar content being viewed by others
References
Ananian, C.S.: MIT FLEX compiler infrastructure for Java (1998-2004), Available from http://www.flex-compiler.lcs.mit.edu
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)
Boyapati, C., Khurshid, S., Marinov, D.: Korat: Automated testing based on Java predicates. In: Proc. ISSTA (2002)
Boyapati, C., Rinard, M.C.: A parameterized type system for race-free Java programs. In: Proc. 16th OOPSLA (2001)
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)
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)
Carlisle, M.C., Rogers, A.: Software caching and computation migration in Olden. In: Proc. 5th PPoPP (1995)
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)
Choi, J.-D., Burke, M., Carini, P.: Efficient flow-sensitive interprocedural computation of pointer-induced aliases and side effects. In: Proc. 20th POPL (1993)
Clarke, D., Drossopoulou, S.: Ownership, encapsulation and the disjointness of type and effect. In: Proc. 17th OOPSLA (2002)
Corbett, J., Dwyer, M., Hatcliff, J., Pasareanu, C.: Bandera: Extracting finite-state models from Java source code. In: Proc. 22nd ICSE (2000)
Corbett, J.C.: Using shape analysis to reduce finite-state models of concurrent java programs. Software Engineering and Methodology 9(1) (2000)
Crary, K., Walker, D., Morrisett, G.: Typed memory management in a calculus of capabilities. In: Proc. 26th POPL (1999)
DeLine, R., Fähndrich, M.: Typestates for objects. In: Odersky, M. (ed.) ECOOP 2004. LNCS, vol. 3086, pp. 465–490. Springer, Heidelberg (2004)
Flanagan, C., Leino, K.R.M., Lilibridge, M., Nelson, G., Saxe, J.B., Stata, R.: Extended Static Checking for Java. In: Proc. PLDI (2002)
Hind, M., Pioli, A.: Which pointer analysis should I use? In: Proc. ISSTA (2000)
Jouvelot, P., Gifford, D.K.: Algebraic reconstruction of types and effects. In: Proc. 18th POPL (1991)
Kuncak, V., Lam, P., Rinard, M.: Role analysis. In: Proc. 29th POPL (2002)
Kuncak, V., Leino, K.R.M.: In-place refinement for effect checking. In: 2nd Intl. Workshop on Automated Verification of Infinite-State Systems (2003)
Leavens, G.T.: Advances and issues in JML. In: Presentation at the Java Verification Workshop (2002)
Leavens, G.T., Baker, A.L., Ruby, C.: Preliminary design of JML. Technical Report 96-06p, Iowa State University (2001)
Leino, K.R.M., Poetzsch-Heffter, A., Zhou, Y.: Using data groups to specify and check side effects. In: Proc. PLDI (2002)
Lucassen, J.M., Gifford, D.K.: Polymorphic effect systems. In: Proc. 15th POPL (1988)
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)
Milanova, A., Rountev, A., Ryder, B.G.: Parameterized object sensitivity for points-to and side-effect analyses for Java. In: Proc. ISSTA (2002)
Mueller, P., Poetzsch-Heffter, A., Leavens, G.T.: Modular specification of frame properties in JML. Technical Report TR 02-02, Iowa State University (2002)
Rinard, M., Sălcianu, A., Bugrara, S.: A classification system and analysis for aspect-oriented programs. In: Proc. 12th FSE (2004)
Rountev, A.: Precise identification of side-effect-free methods in Java. In: IEEE International Conference on Software Maintenance (2004)
Salcianu, A.: Pointer analysis and its applications to Java programs. Master’s thesis, MIT Laboratory for Computer Science (2001)
Salcianu, A., Rinard, M.: A combined pointer and purity analysis for Java programs. Technical Report MIT-CSAIL-TR-949, MIT CSAIL (2004)
Spoto, F., Poll, E.: Static analysis for JML’s assignable clauses. In: Proc. 10th FOOL (2003)
Tkachuk, O., Dwyer, M.B.: Adapting side effects analysis for modular program model checking. In: Proc. 11th FSE (2003)
Tofte, M., Birkedal, L.: A region inference algorithm. Transactions on Programming Languages and Systems 20(4) (1998)
Visser, W., Havelund, K., Brat, G., Park, S.: Model checking programs. In: Proc. 15th ASE (2000)
Whaley, J., Rinard, M.: Compositional pointer and escape analysis for Java programs. In: Proc. 14th OOPSLA (1999)
Author information
Authors and Affiliations
Editor information
Editors and Affiliations
Rights 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)