Abstract
Reuse of software components requires the comprehension of the behavior and possible side effects among APIs of program components. Meanwhile, identifying problematic usage of these components is difficult with conventional static analysis. Purity and side effects are important properties of methods that often are neglected by the documentations of the object oriented languages such as Java. In this paper, we studied these properties by using a static analysis technique to automatically infer the state dependencies for the return value and side effects of methods. As a result, the effect information reveals purity of methods as well as well-defined state interactions between objects. We have implemented the analyzer targeting Java bytecode and tested it on some open source Java software libraries with different scale and characteristic. From our experimental results, we found that 24–44% of the methods in the evaluated open source Java libraries are pure, which indicates that a large percentage of the methods are suitable for high level refactoring. Our study can help programmers to understand and reuse these libraries.
This is a preview of subscription content, log in via an institution.
Buying options
Tax calculation will be finalised at checkout
Purchases are for personal use only
Learn about institutional subscriptionsPreview
Unable to display preview. Download preview PDF.
References
Bell, J.S., Kaiser, G.E.: Unit test virtualization with vmvm (2013)
Bruneton, E., Lenglet, R., Coupaye, T.: Asm: A code manipulation tool to implement adaptable systems. Adaptable and Extensible Component Systems 30 (2002)
Finifter, M., Mettler, A., Sastry, N., Wagner, D.: Verifiable functional purity in java. In: Proc. of the 15th ACM Conference on Computer and Communications Security, pp. 161–174. ACM (2008)
Goetz, B.: Java theory and practice: I have to document that (2002), http://www.ibm.com/developerworks/java/library/j-jtp0821/index.html
Gordon, C., Parkinson, M., Parsons, J., Bromfield, A., Duffy, J.: Uniqueness and reference immutability for safe parallelism (2012)
Holt, R.C., Cordy, J.R.: The turing programming language. Communications of the ACM 31(12), 1410–1423 (1988)
Huang, W., Milanova, A., Ernst, W.: Reim & reiminfer: Checking and inference of reference immutability and method purity. In: OOPSLA (2012)
Javarifier, J.Q.: Inference of reference immutability in Java. Ph.D. thesis, Massachusetts Institute of Technology (2008)
Kjolstad, F., Dig, D., Acevedo, G., Snir, M.: Transformation for class immutability. In: Proceedings of the 33rd International Conference on Software Engineering, ICSE 2011, pp. 61–70. ACM, New York (2011), http://doi.acm.org/10.1145/1985793.1985803
Lampson, B.W., Horning, J.J., London, R.L., Mitchell, J.G., Popek, G.J.: Report on the programming language euclid. ACM Sigplan Notices 12(2), 1–79 (1977)
Leavens, G.T., Baker, A.L., Ruby, C.: Preliminary design of jml. Technical Report 96-06p, Iowa State University (2001)
Martin, R.C.: Clean code: A handbook of agile software craftsmanship. Prentice Hall (2008)
Mettler, A., Wagner, D., Close, T.: Joe-e: A security-oriented subset of java. In: Network and Distributed Systems Symposium. Internet Society (2010)
Pearce, D.J.: JPure: A modular purity system for java. In: Knoop, J. (ed.) CC 2011. LNCS, vol. 6601, pp. 104–123. Springer, Heidelberg (2011)
Peyton Jones, S.L., Wadler, P.: Imperative functional programming. In: Proceedings of the 20th ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, pp. 71–84. ACM (1993)
Raymond, C.: The importance of error code backwards compatibility (2005), http://blogs.msdn.com/b/oldnewthing/archive/2005/01/18/355177.aspx
Sălcianu, A.: Pointer analysis and its applications for Java programs. Ph.D. thesis, Citeseer (2001)
Sălcianu, A., Rinard, M.: Purity and side effect analysis for java programs. In: Cousot, R. (ed.) VMCAI 2005. LNCS, vol. 3385, pp. 199–215. Springer, Heidelberg (2005)
Tschantz, M., Ernst, M.: Javari: Adding reference immutability to Java, vol. 40. ACM (2005)
Author information
Authors and Affiliations
Editor information
Editors and Affiliations
Rights and permissions
Copyright information
© 2014 Springer International Publishing Switzerland
About this paper
Cite this paper
Yang, J., Hotta, K., Higo, Y., Kusumoto, S. (2014). Revealing Purity and Side Effects on Functions for Reusing Java Libraries. In: Schaefer, I., Stamelos, I. (eds) Software Reuse for Dynamic Systems in the Cloud and Beyond. ICSR 2015. Lecture Notes in Computer Science, vol 8919. Springer, Cham. https://doi.org/10.1007/978-3-319-14130-5_22
Download citation
DOI: https://doi.org/10.1007/978-3-319-14130-5_22
Publisher Name: Springer, Cham
Print ISBN: 978-3-319-14129-9
Online ISBN: 978-3-319-14130-5
eBook Packages: Computer ScienceComputer Science (R0)