ABSTRACT
We have built the Index Checker, a type checker that issues warnings about array, list, and string accesses that are potentially unsafe. An example is shown in Figure 1. As with any sound tool, some of its warnings may be false positives. If the Index Checker issues no warning, then the programmer is guaranteed that no array access will cause an IndexOutOfBoundsException at run time (modulo suppressed warnings and unchecked code). The Index Checker ships with knowledge of Java APIs. The developer can optionally write a few type annotations in the program to make the Index Checker more precise. Our system includes five new type qualifiers, defined in Figure 2, that can be applied to integral types such as Java int. These are dependent types that indicate the relationship between the int and given arrays. Figures 3 and 4 show the relationship among these type qualifiers. The type system also contains a type qualifier for arrays, @MinLen, which is a lower bound on its length and permits use of literal integers to access the array or to construct a new array. The Index Checker is built upon the Checker Framework (http://CheckerFramework.org/).
- D. L. Detlefs, K. R. M. Leino, G. Nelson, and J. B. Saxe. Extended static checking. SRC Research Report 159, Compaq Systems Research Center, December 18, 1998.Google Scholar
- W. Dietl, S. Dietzel, M. D. Ernst, K. Mu¸slu, and T. Schiller. Building and using pluggable type-checkers. In ICSE’11, Proceedings of the 33rd International Conference on Software Engineering, pages 681–690, Waikiki, Hawaii, USA, May 25–27, 2011. Google ScholarDigital Library
- M. D. Ernst. Static and dynamic analysis: Synergy and duality. In WODA 2003: Workshop on Dynamic Analysis, pages 24–27, Portland, Oregon, May 9, 2003.Google Scholar
- D. Evans. Static detection of dynamic memory errors. In PLDI 1996, Proceedings of the SIGPLAN ’96 Conference on Programming Language Design and Implementation, pages 44–53, Philadelphia, PA, USA, May 21–24, 1996. Google ScholarDigital Library
- B. Hackett, M. Das, D. Wang, and Z. Yang. Modular checking for buffer overflows in the large. In ICSE’06, Proceedings of the 28th International Conference on Software Engineering, pages 232–241, Shanghai, China, May 24–26, 2006. Google ScholarDigital Library
- R. Hastings and B. Joyce. Purify: A tool for detecting memory leaks and access errors in C and C++ programs. In Proceedings of the Winter 1992 USENIX Conference, pages 125–138, San Francisco, CA, USA, January 20–24, 1992.Google Scholar
- D. Hovemeyer and W. Pugh. Finding bugs is easy. In Companion to Object-Oriented Programming Systems, Languages, and Applications (OOPSLA 2004), pages 132–136, Vancouver, BC, Canada, October 26–28, 2004. Google ScholarDigital Library
- K. R. M. Leino and G. Nelson. An extended static checker for Modula-3. In Compiler Construction: 7th International Conference, CC’98, pages 302–305, Lisbon, Portugal, April 1998. Google ScholarDigital Library
- N. Nethercote and J. Seward. Valgrind: A framework for heavyweight dynamic binary insrumentation. In PLDI 2007, Proceedings of the ACM SIGPLAN 2007 Conference on Programming Language Design and Implementation, pages 89–100, San Diego, CA, USA, June 11–13, 2007. Google ScholarDigital Library
- M. M. Papi, M. Ali, T. L. Correa Jr., J. H. Perkins, and M. D. Ernst. Practical pluggable types for Java. In ISSTA 2008, Proceedings of the 2008 International Symposium on Software Testing and Analysis, pages 201–212, Seattle, WA, USA, July 22–24, 2008. Google ScholarDigital Library
- N. Suzuki and K. Ishihata. Implementation of an array bound checker. In POPL ’77, Proceedings of the Fourth Annual ACM Symposium on Principles of Programming Languages, pages 132–143, Los Angeles, CA, January 17–19, 1977. Google ScholarDigital Library
- H. Xi and F. Pfenning. Eliminating array bound checking through dependent types. In PLDI 1998, Proceedings of the ACM SIGPLAN’98 Conference on Programming Language Design and Implementation, pages 249–257, Montreal, Canada, June 17–19 1998. Google ScholarDigital Library
Index Terms
- Enforcing correct array indexes with a type system
Recommendations
Compile-time type-checking for custom type qualifiers in Java
OOPSLA '07: Companion to the 22nd ACM SIGPLAN conference on Object-oriented programming systems and applications companionWe have created a system that enables programmers to add custom type qualifiers to the Java language in a backward-compatible way. The system allows programmers to write type qualifiers in their programs and to create compiler plug-ins that enforce the ...
Compile-time type-checking for custom type qualifiers in Java
OOPSLA '07: Companion to the 22nd ACM SIGPLAN conference on Object-oriented programming systems and applications companionWe have created a system that enables programmers to add custom type qualifiers to the Java language in a backward-compatible way. The system allows programmers to write type qualifiers in their programs and to create compiler plug-ins that enforce the ...
A practical type system and language for reference immutability
OOPSLA '04: Proceedings of the 19th annual ACM SIGPLAN conference on Object-oriented programming, systems, languages, and applicationsThis paper describes a type system that is capable of expressing and enforcing immutability constraints. The specific constraint expressed is that the abstract state of the object to which an immutable reference refers cannot be modified using that ...
Comments