In this self-paced tutorial, you will learn to use the Checker Framework to improve code quality. In particular, the Checker Framework will give a compile-time guarantee that certain run-time errors cannot occur.
Install the Checker Framework.
Be sure that running javac -version produces an output string that contains jsr308.
Follow the instructions for an example use of the Nullness Checker.
We will find and correct errors in how the Search.java. application uses regular expressions. Currently, when the user provides invalid inputs, the program crashes with a stack trace, which is offputting and uninformative to users. The Search.java application is incorrect in that it does not validate user input. You will correct this problem.
Download Search.java.
Type check Search.java by running the following command, using the Checker Framework's javac:
javac -processor checkers.regex.RegexChecker Search.java
The Regex Checker finds the error — the missing validation. Correct the problem by adding proper validation, and verify that your solution is correct by re-running the Regex Checker until it issues no errors.
TODO: Give away the answer, by supplying a link that gives the missing validation lines, for use by users who get stuck.
You will write your own declarative type checker to ensure encrypted communication!
Demo application: EncryptionDemo.java.
In the session we will write a new Encrypted annotation. You compile it like any other Java class:
javac .../Encrypted.java
You then use the Basic Checker to check the demo program, like so:
$CHECKERS/binary/javac -processor checkers.basic.BasicChecker -Aquals=encrypted.quals.Encrypted .../EncryptionDemo.java
[It is sometimes necessary to provide the location of the annotation class on the bootclasspath. Use the "-Xbootclasspath/p:yourpath" parameter for this.]
As a first demonstration, we will use the Personal Blog demonstration. You can download the project here. Unzip it into a directory. An Ant build file is there. In Eclipse, you can import the folder as a new project.
A pluggable type system extends a language's built-in type system to confer additional compile-time guarantees. We will explain the theory and practice of pluggable types. The material is relevant for researchers who wish to apply type theory, and for anyone who wishes to increase confidence in their code. After this session, you will have the knowledge to: analyze a problem to determine whether pluggable type-checking is appropriate; design a domain-specific type system; implement a simple type-checker (in as little as 4 lines of code!); scale a simple type-checker to more sophisticated properties; and better appreciate both object-oriented types and flexible verification techniques.
While the theory is general, our hands-on exercises will use a state-of-the-art system, the Checker Framework, that works for the Java language, scales to millions of lines of code, and is being adopted in the research and industrial communities. Such a framework enables researchers to easily evaluate their type systems in the context of a widely-used industrial language, Java. It enables non-researchers to verify their code in a lightweight way and to create custom analyses. And it enables students to better appreciate type system concepts.
We will:
Audience participation is desired! We expect the audience to come prepared with a laptop with a working Java environment (Eclipse optional).
Werner Dietl and Michael D. Ernst, University of Washington.
Last updated: July 22, 2012