Skip to main content

Revealing Purity and Side Effects on Functions for Reusing Java Libraries

  • Conference paper

Part of the book series: Lecture Notes in Computer Science ((LNPSE,volume 8919))

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

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

Learn about institutional subscriptions

Preview

Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.

References

  1. Bell, J.S., Kaiser, G.E.: Unit test virtualization with vmvm (2013)

    Google Scholar 

  2. Bruneton, E., Lenglet, R., Coupaye, T.: Asm: A code manipulation tool to implement adaptable systems. Adaptable and Extensible Component Systems 30 (2002)

    Google Scholar 

  3. 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)

    Google Scholar 

  4. Goetz, B.: Java theory and practice: I have to document that (2002), http://www.ibm.com/developerworks/java/library/j-jtp0821/index.html

  5. Gordon, C., Parkinson, M., Parsons, J., Bromfield, A., Duffy, J.: Uniqueness and reference immutability for safe parallelism (2012)

    Google Scholar 

  6. Holt, R.C., Cordy, J.R.: The turing programming language. Communications of the ACM 31(12), 1410–1423 (1988)

    Article  Google Scholar 

  7. Huang, W., Milanova, A., Ernst, W.: Reim & reiminfer: Checking and inference of reference immutability and method purity. In: OOPSLA (2012)

    Google Scholar 

  8. Javarifier, J.Q.: Inference of reference immutability in Java. Ph.D. thesis, Massachusetts Institute of Technology (2008)

    Google Scholar 

  9. 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

    Google Scholar 

  10. 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)

    Article  Google Scholar 

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

    Google Scholar 

  12. Martin, R.C.: Clean code: A handbook of agile software craftsmanship. Prentice Hall (2008)

    Google Scholar 

  13. Mettler, A., Wagner, D., Close, T.: Joe-e: A security-oriented subset of java. In: Network and Distributed Systems Symposium. Internet Society (2010)

    Google Scholar 

  14. 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)

    Chapter  Google Scholar 

  15. 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)

    Google Scholar 

  16. Raymond, C.: The importance of error code backwards compatibility (2005), http://blogs.msdn.com/b/oldnewthing/archive/2005/01/18/355177.aspx

  17. Sălcianu, A.: Pointer analysis and its applications for Java programs. Ph.D. thesis, Citeseer (2001)

    Google Scholar 

  18. 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)

    Chapter  Google Scholar 

  19. Tschantz, M., Ernst, M.: Javari: Adding reference immutability to Java, vol. 40. ACM (2005)

    Google Scholar 

Download references

Author information

Authors and Affiliations

Authors

Editor information

Editors and Affiliations

Rights and permissions

Reprints 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)

Publish with us

Policies and ethics