Semantic Foundations and Inference of Non-null Annotations

  • Laurent Hubert
  • Thomas Jensen
  • David Pichardie
Part of the Lecture Notes in Computer Science book series (LNCS, volume 5051)


This paper proposes a semantics-based automatic null pointer analysis for inferring non-null annotations of fields in object-oriented programs. The analysis is formulated for a minimalistic OO language and is expressed as a constraint-based abstract interpretation of the program which for each field of a class infers whether the field is definitely non-null or possibly null after object initialization. The analysis is proved correct with respect to an operational semantics of the minimalistic OO language. This correctness proof has been machine checked using the Coq proof assistant. We also prove the analysis complete with respect to the non-null type system proposed by Fähndrich and Leino, in the sense that for every typable program the analysis is able to prove the absence of null dereferences without any hand-written annotations. Experiments with a prototype implementation of the analysis show that the inference is feasible for large programs.


Type System Null Pointer Correctness Proof Method Signature Abstract Domain 
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.


  1. 1.
    Cachera, D., Jensen, T.P., Pichardie, D., Rusu, V.: Extracting a data flow analyser in constructive logic. Theoretical Computer Science 342(1), 56–78 (2005)zbMATHCrossRefMathSciNetGoogle Scholar
  2. 2.
    Chalin, P., James, P.R.: Non-null references by default in Java: Alleviating the nullity annotation burden. In: Ernst, E. (ed.) ECOOP 2007. LNCS, vol. 4609, pp. 227–247. Springer, Heidelberg (2007)CrossRefGoogle Scholar
  3. 3.
    Cielecki, M., Fulara, J., Jakubczyk, K., Jancewicz, Ł.: Propagation of JML non-null annotations in Java programs. In: Proc. of the 4th international symposium on Principles and practice of programming in Java (PPPJ 2006), pp. 135–140. ACM Press, New York (2006)Google Scholar
  4. 4.
    Das, M., Lerner, S., Seigle, M.: Esp: path-sensitive program verification in polynomial time. In: Proc. of the Conference on Programming language design and implementation (PLDI 2002), pp. 57–68. ACM Press, New York (2002)CrossRefGoogle Scholar
  5. 5.
    Ekman, T., Hedin, G.: Pluggable non-null types for Java (ch. V). In: Ekman, T. (ed.) Extensible Compiler Construction, June 2006, Lund University (2006)Google Scholar
  6. 6.
    Fähndrich, M., Leino, K.R.M.: Declaring and checking non-null types in an object-oriented language. In: Proc. of Conference on Object-Oriented Programming Systems, Languages, and Applications (OOPSLA 2003), pp. 302–312. Springer, Heidelberg (2003)Google Scholar
  7. 7.
    Fähndrich, M., Xia, S.: Establishing object invariants with delayed types. In: OOPSLA 2007: Proc. of the 22nd conference on Object Oriented Programming Systems and Applications, pp. 337–350. ACM, New York (2007)CrossRefGoogle Scholar
  8. 8.
    Flanagan, C., Leino, K.R.M.: Houdini, an annotation assistant for ESC/Java. In: Oliveira, J.N., Zave, P. (eds.) FME 2001. LNCS, vol. 2021, pp. 500–517. Springer, Heidelberg (2001)CrossRefGoogle Scholar
  9. 9.
    Freund, S.N., Mitchell, J.C.: A formal framework for the java bytecode language and verifier. In: Proc. of the 14th conference on Object-oriented programming, systems, languages, and applications (OOPSLA 1999), pp. 147–166. ACM Press, New York (1999)CrossRefGoogle Scholar
  10. 10.
    Hovemeyer, D., Pugh, W.: Finding more null pointer bugs, but not too many. In: PASTE 2007: Proc. of the 7th workshop on Program analysis for software tools and engineering, pp. 9–14. ACM Press, New York (2007)CrossRefGoogle Scholar
  11. 11.
    Hovemeyer, D., Spacco, J., Pugh, W.: Evaluating and tuning a static analysis to find null pointer bugs. SIGSOFT Softw. Eng. Notes 31(1), 13–19 (2006)CrossRefGoogle Scholar
  12. 12.
    Hubert, L., Jensen, T., Pichardie, D.: Semantic foundations and inference of non-null annotations. Research Report 6482, INRIA (March 2008)Google Scholar
  13. 13.
    Kawahito, M., Komatsu, H., Nakatani, T.: Effective null pointer check elimination utilizing hardware trap. SIGPLAN Not. 35(11), 139–149 (2000)CrossRefGoogle Scholar
  14. 14.
    Leino, K.R.M., Saxe, J.B., Stata, R.: ESC/Java user’s manual. Compaq Systems Research Center, technical note 2000-002 edition (October 2000)Google Scholar
  15. 15.
    Male, C., Pearce, D.J., Potanin, A., Dymnikov, C.: Java bytecode verification for @NonNull types. In: Proc. of the Conference on Compiler Construction (CC 2008), Springer, Heidelberg (2008)Google Scholar
  16. 16.
    Vallée-Rai, R., Co, P., Gagnon, E., Hendren, L., Lam, P., Sundaresan, V.: Soot — a Java bytecode optimization framework. In: CASCON 1999: Proc. of the 1999 conference of the Centre for Advanced Studies on Collaborative research, p. 13. IBM Press (1999)Google Scholar

Copyright information

© Springer-Verlag Berlin Heidelberg 2008

Authors and Affiliations

  • Laurent Hubert
    • 1
  • Thomas Jensen
    • 1
  • David Pichardie
    • 2
  1. 1.CNRS/IRISAFrance
  2. 2.INRIA Rennes - Bretagne Atlantique/IRISAFrance

Personalised recommendations