Compile-time type-checking for custom type qualifiers in Java

  • Authors:
  • Matthew M. Papi;Michael D. Ernst

  • Affiliations:
  • MIT Computer Science and Artificial Intelligence Lab, Cambridge, MA;MIT Computer Science and Artificial Intelligence Lab, Cambridge, MA

  • Venue:
  • Companion to the 22nd ACM SIGPLAN conference on Object-oriented programming systems and applications companion
  • Year:
  • 2007

Quantified Score

Hi-index 0.00

Visualization

Abstract

We 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 semantics of these qualifiers at compile time. The system builds on existing Java tools and APIs, and on JSR 308. As an example, we introduce a plug-in to Sun's Java compiler that uses our system to type-check the NonNull qualifier. Programmers can use the @NonNull annotation to prohibit an object reference from being null; then, by invoking a Java compiler with the NonNull plug-in, they can check for NonNull errors at compile time and rid their programs of null-pointer exceptions.