Skip to main content

A Type-Directed Algorithm to Generate Well-Typed Featherweight Java Programs

  • Conference paper
  • First Online:
Formal Methods: Foundations and Applications (SBMF 2018)

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

Included in the following conference series:

  • 326 Accesses

Abstract

Property-based testing of compilers or programming languages semantics is difficult to accomplish because it is hard to design a random generator for valid programs. Most compiler test tools do not have a well-specified way of generating type-correct programs, which is a requirement for such testing activities. In this work, we formalize a type-directed procedure to generate random well-typed programs in the context of Featherweight Java, a well-known object-oriented calculus for the Java programming language. We implement the approach using the Haskell programming language and verify it against relevant properties using QuickCheck, a library for property-based testing.

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 49.99
Price excludes VAT (USA)
  • Available as EPUB and PDF
  • Read on any device
  • Instant download
  • Own it forever
Softcover Book
USD 64.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

Notes

  1. 1.

    The source-code for our Haskell interpreter and the complete test suite is available at: https://github.com/fjpub/fj-qc/.

  2. 2.

    Details of implementation and experiments are presented in our technical report, which can be found at: https://github.com/fjpub/fj-qc/raw/master/tr.pdf.

  3. 3.

    A detailed explanation about stupid casts can be found in p. 260 of [19].

  4. 4.

    More details about using QuickCheck for testing the semantic properties of FJ are in our technical report at: https://github.com/fjpub/fj-qc/raw/master/tr.pdf.

References

  1. Allwood, T.O.R., Eisenbach, S.: Tickling Java with a feather. Electron. Notes Theor. Comput. Sci. 238(5), 3–16 (2009). http://dx.doi.org/10.1016/j.entcs.2009.09.037

    Article  Google Scholar 

  2. Bazzichi, F., Spadafora, I.: An automatic generator for compiler testing. IEEE Trans. Softw. Eng. 4, 343–353 (1982)

    Article  Google Scholar 

  3. Blanco, R., Miller, D., Momigliano, A.: Property-based testing via proof reconstruction work-in-progress. In: LFMTP 17: Logical Frameworks and Meta-Languages: Theory and Practice (2017)

    Google Scholar 

  4. Celentano, A., Reghizzi, S.C., Vigna, P.D., Ghezzi, C., Granata, G., Savoretti, F.: Compiler testing using a sentence generator. Softw. Pract. Experience 10(11), 897–918 (1980)

    Google Scholar 

  5. Claessen, K., Hughes, J.: QuickCheck: a lightweight tool for random testing of Haskell programs. In: Proceedings of the Fifth ACM SIGPLAN International Conference on Functional Programming, ICFP 2000, pp. 268–279 (2000). http://doi.acm.org/10.1145/351240.351266

  6. Daniel, B., Dig, D., Garcia, K., Marinov, D.: Automated testing of refactoring engines. In: Proceedings of the the 6th Joint Meeting of the European Software Engineering Conference and the ACM SIGSOFT Symposium on The Foundations of Software Engineering, ESEC-FSE 2007, pp. 185–194 (2007). http://doi.acm.org/10.1145/1287624.1287651

  7. Debbabi, M., Fourati, M.: A formal type system for Java. J. Object Technol. 6(8), 117–184 (2007)

    Article  Google Scholar 

  8. Drienyovszky, D., Horpácsi, D., Thompson, S.: Quickchecking refactoring tools. In: Proceedings of the 9th ACM SIGPLAN Workshop on Erlang, Erlang 2010, pp. 75–80 (2010). http://doi.acm.org/10.1145/1863509.1863521

  9. Gill, A., Runciman, C.: Haskell program coverage. In: Proceedings of the ACM SIGPLAN Workshop on Haskell Workshop, Haskell 2007, pp. 1–12 (2007). http://doi.acm.org/10.1145/1291201.1291203

  10. Gligoric, M., Gvero, T., Jagannath, V., Khurshid, S., Kuncak, V., Marinov, D.: Test generation through programming in Udita. In: Proceedings of the 32nd ACM/IEEE International Conference on Software Engineering, vol. 1, pp. 225–234. ACM (2010)

    Google Scholar 

  11. Gosling, J., Joy, B., Steele, G., Bracha, G., Buckley, A.: The Java language specification, Java SE 8 edition (Java series) (2014)

    Google Scholar 

  12. Igarashi, A., Pierce, B.C., Wadler, P.: Featherweight Java: A minimal core calculus for Java and GJ. ACM Trans. Program. Lang. Syst. 23(3), 396–450 (2001). http://doi.acm.org/10.1145/503502.503505

    Article  Google Scholar 

  13. Klein, C., Flatt, M., Findler, R.B.: Random testing for higher-order, stateful programs. In: Proceedings of the ACM International Conference on Object Oriented Programming Systems Languages and Applications, OOPSLA 2010, pp. 555–566 (2010). http://doi.acm.org/10.1145/1869459.1869505

  14. Le, V., Afshari, M., Su, Z.: Compiler validation via equivalence modulo inputs. SIGPLAN Not. 49(6), 216–226 (2014). http://doi.acm.org/10.1145/2666356.2594334

    Article  Google Scholar 

  15. Lindig, C.: Random testing of C calling conventions. In: Proceedings of the Sixth International Symposium on Automated Analysis-driven Debugging, AADEBUG 2005, pp. 3–12 (2005). http://doi.acm.org/10.1145/1085130.1085132

  16. McBride, C.: Djinn, monotonic. In: PAR@ ITP, pp. 14–17 (2010)

    Google Scholar 

  17. Mongiovi, M., Mendes, G., Gheyi, R., Soares, G., Ribeiro, M.: Scaling testing of refactoring engines. In: 2014 IEEE International Conference on Software Maintenance and Evolution (ICSME), pp. 371–380. IEEE (2014)

    Google Scholar 

  18. Palka, M.H., Claessen, K., Russo, A., Hughes, J.: Testing an optimising compiler by generating random lambda terms. In: Proceedings of the 6th International Workshop on Automation of Software Test, AST 2011, pp. 91–97 (2011). http://doi.acm.org/10.1145/1982595.1982615

  19. Pierce, B.C.: Types and Programming Languages, 1st edn. The MIT Press (2002)

    Google Scholar 

  20. da Silva, T.D., Sampaio, A., Mota, A.: Verifying transformations of java programs using alloy. In: Cornélio, M., Roscoe, B. (eds.) SBMF 2015. LNCS, vol. 9526, pp. 110–126. Springer, Cham (2016). https://doi.org/10.1007/978-3-319-29473-5_7

    Chapter  Google Scholar 

  21. Soares, G., Gheyi, R., Massoni, T.: Automated behavioral testing of refactoring engines. IEEE Trans. Softw. Eng. 39(2), 147–162 (2013)

    Article  Google Scholar 

  22. tiobe.com: TIOBE Index, April 2018. https://www.tiobe.com/tiobe-index/. Accessed 09 Apr 2018

  23. Yang, X., Chen, Y., Eide, E., Regehr, J.: Finding and understanding bugs in C compilers. SIGPLAN Not. 46(6), 283–294 (2011). http://doi.acm.org/10.1145/1993316.1993532

    Article  Google Scholar 

Download references

Author information

Authors and Affiliations

Authors

Corresponding author

Correspondence to Samuel S. Feitosa .

Editor information

Editors and Affiliations

Rights and permissions

Reprints and permissions

Copyright information

© 2018 Springer Nature Switzerland AG

About this paper

Check for updates. Verify currency and authenticity via CrossMark

Cite this paper

Feitosa, S.S., Ribeiro, R.G., Rauber Du Bois, A. (2018). A Type-Directed Algorithm to Generate Well-Typed Featherweight Java Programs. In: Massoni, T., Mousavi, M. (eds) Formal Methods: Foundations and Applications. SBMF 2018. Lecture Notes in Computer Science(), vol 11254. Springer, Cham. https://doi.org/10.1007/978-3-030-03044-5_4

Download citation

  • DOI: https://doi.org/10.1007/978-3-030-03044-5_4

  • Published:

  • Publisher Name: Springer, Cham

  • Print ISBN: 978-3-030-03043-8

  • Online ISBN: 978-3-030-03044-5

  • eBook Packages: Computer ScienceComputer Science (R0)

Publish with us

Policies and ethics