A Formalisation of Java Strings for Program Specification and Verification

  • Richard Bubel
  • Reiner Hähnle
  • Ulrich Geilmann
Part of the Lecture Notes in Computer Science book series (LNCS, volume 7041)


We present a formalisation of Java Strings tailored to specification and verification of programs (using dynamic logic). The formalism allows to specify and verify properties about the content of strings—the most common use-case—in an easy and natural manner. Each instance of type String is related to an abstract data type representing the string content as an immutable sequence of characters. This avoids serious technicalities that would arise if the specification had to resort to Java arrays to represent sequences of characters. We also discuss advanced aspects of Java Strings including string literals and the string pool and support for regular expressions. The approach has been implemented in the KeY verification system. We demonstrate its practical applicability by case studies including the verification of a string sanitization function.


Regular Expression Dynamic Logic Symbolic Execution Kripke Structure Java Modeling Language 
These keywords were added by machine and not by the authors. This process is experimental and the keywords may be updated as the learning algorithm improves.


Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.


  1. 1.
    Barnett, M., Leino, K.R.M., Schulte, W.: The Spec# Programming System: an Overview. In: Barthe, G., Burdy, L., Huisman, M., Lanet, J.-L., Muntean, T. (eds.) CASSIS 2004. LNCS, vol. 3362, pp. 49–69. Springer, Heidelberg (2005)CrossRefGoogle Scholar
  2. 2.
    Stenzel, K.: Verification of Java Card Programs. PhD thesis, Fakultät für angewandte Informatik, University of Augsburg (2005)Google Scholar
  3. 3.
    Beckert, B., Hähnle, R., Schmitt, P. (eds.): Verification of Object-Oriented Software. The KeY Approach. LNCS (LNAI), vol. 4334. Springer, Heidelberg (2007)Google Scholar
  4. 4.
    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)CrossRefGoogle Scholar
  5. 5.
    Gosling, J., Joy, B., Steele, G., Bracha, G.: Java Language Specification, 3rd edn. The Java Series. Addison-Wesley, Boston (2005)zbMATHGoogle Scholar
  6. 6.
    Rümmer, P.: Sequential, parallel, and quantified updates of first-order structures. In: Hermann, M., Voronkov, A. (eds.) LPAR 2006. LNCS (LNAI), vol. 4246, pp. 422–436. Springer, Heidelberg (2006)CrossRefGoogle Scholar
  7. 7.
    Geilmann, U.: Formal verification using Java’s String class. Studienarbeit, Chalmers University of Technology and Universität Karlsruhe (November 2009),
  8. 8.
    Gries, D., Schneider, F.B.: Avoiding the undefined by underspecification. In: van Leeuwen, J. (ed.) Computer Science Today. LNCS, vol. 1000, pp. 366–373. Springer, Heidelberg (1995)CrossRefGoogle Scholar
  9. 9.
    Leavens, G.T., Poll, E., Clifton, C., Cheon, Y., Ruby, C., Cok, D., Müller, P., Kiniry, J., Chalin, P.: JML Reference Manual. Draft rev. 1.200 (February 2007)Google Scholar
  10. 10.
    Conti, J.J., Russo, A.: A taint mode for python via a library. In: OWASP AppSec Research 2010 (2010)Google Scholar
  11. 11.
    Chang, W., Streiff, B., Lin, C.: Efficient and extensible security enforcement using dynamic data flow analysis. In: Proc. of CCS 2008, pp. 39–50. ACM, New York (2008)Google Scholar
  12. 12.
    Kiezun, A., Ganesh, V., Guo, P.J., Hooimeijer, P., Ernst, M.D.: Hampi: A solver for string constraints. In: Proc. of ISSTA 2009. ACM, New York (2009)Google Scholar
  13. 13.
    Starostin, A.: Formal verification of a c-library for strings. Master’s thesis, Saarland University (2006)Google Scholar
  14. 14.
    Leino, K.R.M., Müller, P., Wallenburg, A.: Flexible immutability with frozen objects. In: Shankar, N., Woodcock, J. (eds.) VSTTE 2008. LNCS, vol. 5295, pp. 192–208. Springer, Heidelberg (2008)CrossRefGoogle Scholar
  15. 15.
    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)CrossRefGoogle Scholar
  16. 16.
    Leino, K.R.M.: Dafny: An automatic program verifier for functional correctness. In: Clarke, E.M., Voronkov, A. (eds.) LPAR-16 2010. LNCS, vol. 6355, pp. 348–370. Springer, Heidelberg (2010)CrossRefGoogle Scholar
  17. 17.
    Leino, K.R., Müller, P.: A basis for verifying multi-threaded programs. In: Castagna, G. (ed.) ESOP 2009. LNCS, vol. 5502, pp. 378–393. Springer, Heidelberg (2009)CrossRefGoogle Scholar

Copyright information

© Springer-Verlag Berlin Heidelberg 2011

Authors and Affiliations

  • Richard Bubel
    • 1
  • Reiner Hähnle
    • 1
  • Ulrich Geilmann
    • 2
  1. 1.Department of Computer Science and EngineeringChalmers University of TechnologySweden
  2. 2.Department of Computer ScienceKITKarlsruheGermany

Personalised recommendations