Skip to main content

Reasoning About Exceptional Behavior at the Level of Java Bytecode

  • Conference paper
  • First Online:
Integrated Formal Methods (iFM 2023)

Part of the book series: Lecture Notes in Computer Science ((LNCS,volume 14300))

Included in the following conference series:

  • 153 Accesses

Abstract

A program’s exceptional behavior can substantially complicate its control flow, and hence accurately reasoning about the program’s correctness. On the other hand, formally verifying realistic programs is likely to involve exceptions—a ubiquitous feature in modern programming languages.

In this paper, we present a novel approach to verify the exceptional behavior of Java programs, which extends our previous work on ByteBack. ByteBack works on a program’s bytecode, while providing means to specify the intended behavior at the source-code level; this approach sets ByteBack apart from most state-of-the-art verifiers that target source code. To explicitly model a program’s exceptional behavior in a way that is amenable to formal reasoning, we introduce Vimp: a high-level bytecode representation that extends the Soot framework’s Grimp with verification-oriented features, thus serving as an intermediate layer between bytecode and the Boogie intermediate verification language. Working on bytecode through this intermediate layer brings flexibility and adaptability to new language versions and variants: as our experiments demonstrate, ByteBack can verify programs involving exceptional behavior in all versions of Java, as well as in Scala and Kotlin (two other popular JVM languages).

Work partially supported by SNF grant 200021-207919 (LastMile).

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

    In the following, we occasionally take some liberties with Grimp and Vimp code, using a readable syntax that mixes bytecode instruction and Java statement syntax; for example, represents an invocation of method that corresponds to a suitable variant of bytecode’s .

  2. 2.

    Since the root of all exception types in Java is class —a concrete class—an exception type cannot be a subtype of multiple exception classes, and hence T is strictly a tree.

  3. 3.

    https://docs.oracle.com/javase/9/docs/api/java/lang/invoke/StringConcatFactory.html.

  4. 4.

    We focus on these exception-related programs, but the latest version of ByteBack also verifies correctly the 35 other programs we introduced in previous work to demonstrate its fundamental verification capabilities.

  5. 5.

    Smoke tests provide no absolute guarantee of consistency, but are often practically effective.

References

  1. Ahrendt, W., et al.: The KeY platform for verification and analysis of java programs. In: Giannakopoulou, D., Kroening, D. (eds.) VSTTE 2014. LNCS, vol. 8471, pp. 55–71. Springer, Cham (2014). https://doi.org/10.1007/978-3-319-12154-3_4

  2. Banerjee, S., Clapp, L., Sridharan, M.: NullAway: practical type-based null safety for Java. In: Dumas, M., Pfahl, D., Apel, S., Russo, A. (eds.) Proceedings of the ACM Joint Meeting on European Software Engineering Conference and Symposium on the Foundations of Software Engineering, ESEC/SIGSOFT FSE 2019, Tallinn, Estonia, 26–30 August 2019, pp. 740–750. ACM (2019). https://doi.org/10.1145/3338906.3338919

  3. Barnett, M., Chang, B.-Y.E., DeLine, R., Jacobs, B., Leino, K.R.M.: Boogie: a modular reusable verifier for object-oriented programs. In: de Boer, F.S., Bonsangue, M.M., Graf, S., de Roever, W.-P. (eds.) FMCO 2005. LNCS, vol. 4111, pp. 364–387. Springer, Heidelberg (2006). https://doi.org/10.1007/11804192_17

  4. Calcagno, C., et al.: Moving fast with software verification. In: Havelund, K., Holzmann, G., Joshi, R. (eds.) NFM 2015. LNCS, vol. 9058, pp. 3–11. Springer, Cham (2015). https://doi.org/10.1007/978-3-319-17524-9_1

  5. Chrząszcz, J., Huisman, M., Schubert, A.: BML and related tools. In: de Boer, F.S., Bonsangue, M.M., Madelaine, E. (eds.) FMCO 2008. LNCS, vol. 5751, pp. 278–297. Springer, Heidelberg (2009). https://doi.org/10.1007/978-3-642-04167-9_14

  6. Cok, D.R.: OpenJML: Software verification for Java 7 using JML, OpenJDK, and Eclipse. In: Dubois, C., Giannakopoulou, D., Méry, D. (eds.) Proceedings 1st Workshop on Formal Integrated Development Environment, F-IDE 2014, Grenoble, 6 April 2014. EPTCS, 149, pp. 79–92 (2014). https://doi.org/10.4204/EPTCS.149.8

  7. Filliâtre, J.-C., Marché, C.: The Why/Krakatoa/Caduceus platform for deductive program verification. In: Damm, W., Hermanns, H. (eds.) CAV 2007. LNCS, vol. 4590, pp. 173–177. Springer, Heidelberg (2007). https://doi.org/10.1007/978-3-540-73368-3_21

  8. Gurfinkel, A., Kahsai, T., Komuravelli, A., Navas, J.A.: The SeaHorn verification framework. In: Kroening, D., Păsăreanu, C.S. (eds.) CAV 2015. LNCS, vol. 9206, pp. 343–361. Springer, Cham (2015). https://doi.org/10.1007/978-3-319-21690-4_20

  9. Hiep, H.A., Maathuis, O., Bian, J., de Boer, F.S., de Gouw, S.: Verifying OpenJDK’s LinkedList using KeY (extended paper). Int. J. Softw. Tools Technol. Transf. 24(5), 783–802 (2022). https://doi.org/10.1007/s10009-022-00679-7

  10. Kahsai, T., Rümmer, P., Sanchez, H., Schäf, M.: JayHorn: a framework for verifying Java programs. In: Chaudhuri, S., Farzan, A. (eds.) CAV 2016. LNCS, vol. 9779, pp. 352–358. Springer, Cham (2016). https://doi.org/10.1007/978-3-319-41528-4_19

  11. Lam, P., Bodden, E., Lhoták, O., Hendren, L.: The Soot framework for Java program analysis: a retrospective. In: Cetus Users and Compiler Infrastructure Workshop (CETUS 2011) (2011). https://www.bodden.de/pubs/lblh11soot.pdf

  12. Marché, C., Paulin-Mohring, C., Urbain, X.: The KRAKATOA tool for certification of JAVA/JAVACARD programs annotated in JML. J. Log. Algeb. Methods Prog. 58(1–2), 89–106 (2004). https://doi.org/10.1016/j.jlap.2003.07.006

  13. Marcilio, D., Furia, C.A.: How Java programmers test exceptional behavior. In: Proceedings of the 18th Mining Software Repositories Conference (MSR), pp. 207–218. IEEE (2021)

    Google Scholar 

  14. Marcilio, D., Furia, C.A.: What is thrown? Lightweight precise automatic extraction of exception preconditions in Java methods. In: Proceedings of the 38th IEEE International Conference on Software Maintenance and Evolution (ICSME), pp. 340–351. IEEE Computer Society (2022)

    Google Scholar 

  15. Melo, H., Coelho, R., Treude, C.: Unveiling exception handling guidelines adopted by Java developers. In: SANER. IEEE (2019)

    Google Scholar 

  16. Müller, P., Nordio, M.: Proof-transforming compilation of programs with abrupt termination. In: Proceedings of SAVCBS, pp. 39–46. ACM (2007). https://doi.org/10.1145/1292316.1292321

  17. Nakshatri, S., Hegde, M., Thandra, S.: Analysis of exception handling patterns in Java projects: An empirical study. IEEE/ACM MSR (2016)

    Google Scholar 

  18. Necula, G.C.: Proof-carrying code. In: Lee, P., Henglein, F., Jones, N.D. (eds.) POPL, pp. 106–119. ACM Press (1997). https://doi.org/10.1145/263699.263712

  19. Paganoni, M., Furia, C.A.: ByteBack iFM 2023 Replication Package (2023). https://doi.org/10.5281/zenodo.8335240

  20. Paganoni, M., Furia, C.A.: Verifying functional correctness properties at the level of Java bytecode. In: Chechik, M., Katoen, J.P., Leucker, M. (eds.) Proceedings of the 25th International Symposium on Formal Methods (FM). LNCS, vol. 14000, pp. 343–363. Springer, Cham (2023). https://doi.org/10.1007/978-3-031-27481-7_20

  21. Papi, M.M., Ali, M., Jr., T.L.C., Perkins, J.H., Ernst, M.D.: Practical pluggable types for Java. In: Ryder, B.G., Zeller, A. (eds.) Proceedings of the ACM/SIGSOFT International Symposium on Software Testing and Analysis, ISSTA 2008, Seattle, 20–24 July 2008, pp. 201–212. ACM (2008). https://doi.org/10.1145/1390630.1390656

  22. Polikarpova, N., Tschannen, J., Furia, C.A.: A fully verified container library. Formal Aspects Comput. 30(5), 495–523 (2018)

    Article  MathSciNet  Google Scholar 

  23. Rakamarić, Z., Emmi, M.: SMACK: decoupling source language details from verifier implementations. In: Biere, A., Bloem, R. (eds.) CAV 2014. LNCS, vol. 8559, pp. 106–113. Springer, Cham (2014). https://doi.org/10.1007/978-3-319-08867-9_7

  24. Rudich, A., Darvas, Á., Müller, P.: Checking well-formedness of pure-method specifications. In: Cuellar, J., Maibaum, T., Sere, K. (eds.) FM 2008. LNCS, vol. 5014, pp. 68–83. Springer, Heidelberg (2008). https://doi.org/10.1007/978-3-540-68237-0_7

  25. Rümmer, P.: JayHorn: a Java model checker. In: Murray, T., Ernst, G. (eds.) Proceedings of the 21st Workshop on Formal Techniques for Java-like Programs, FTfJP@ECOOP 2019, London, 15 July 2019, p. 1:1. ACM (2019). https://doi.org/10.1145/3340672.3341113

  26. Vallée-Rai, R., Co, P., Gagnon, E., Hendren, L.J., Lam, P., Sundaresan, V.: Soot - a Java bytecode optimization framework. In: MacKay, S.A., Johnson, J.H. (eds.) Proceedings of the 1999 Conference of the Centre for Advanced Studies on Collaborative Research, 8–11 November 1999, Mississauga, p. 13. IBM (1999). https://dl.acm.org/citation.cfm?id=782008

  27. Weimer, W., Necula, G.C.: Finding and preventing run-time error handling mistakes. In: Proceedings of the 19th Annual ACM SIGPLAN Conference on Object-Oriented Programming, Systems, Languages, and Applications, OOPSLA 2004 (October), pp. 24–28, 2004. Vancouver, BC, Canada, pp. 419–431. ACM (2004). https://doi.org/10.1145/1028976.1029011

URL References

  1. https://jcp.org/en/jsr/detail?id=334

  2. https://docs.oracle.com/javase/tutorial/essential/exceptions/runtime.html

  3. https://docs.oracle.com/javase/specs/jvms/se7/html/jvms-2.html#jvms-2.10

  4. https://docs.oracle.com/javase/8/docs/api/java/util/package-summary.html

  5. https://www.oracle.com/java/technologies/javase/jdk7-relnotes.html

Download references

Author information

Authors and Affiliations

Authors

Corresponding author

Correspondence to Marco Paganoni .

Editor information

Editors and Affiliations

Rights and permissions

Reprints and permissions

Copyright information

© 2024 The Author(s), under exclusive license to Springer Nature Switzerland AG

About this paper

Check for updates. Verify currency and authenticity via CrossMark

Cite this paper

Paganoni, M., Furia, C.A. (2024). Reasoning About Exceptional Behavior at the Level of Java Bytecode. In: Herber, P., Wijs, A. (eds) Integrated Formal Methods. iFM 2023. Lecture Notes in Computer Science, vol 14300. Springer, Cham. https://doi.org/10.1007/978-3-031-47705-8_7

Download citation

  • DOI: https://doi.org/10.1007/978-3-031-47705-8_7

  • Published:

  • Publisher Name: Springer, Cham

  • Print ISBN: 978-3-031-47704-1

  • Online ISBN: 978-3-031-47705-8

  • eBook Packages: Computer ScienceComputer Science (R0)

Publish with us

Policies and ethics