Skip to content
David Bürgin edited this page Nov 1, 2015 · 38 revisions

Setup

Let's set things up and get started. I'm assuming you have the following ready.

  • Java 8
  • Maven
  • a Unix-like environment -- though give or take some minor adjustments this tutorial should work on Windows, too

Get the code

From this repo.

git clone ...

Now is a good time to check if we're starting out all green. But before we do this let's make a first commit e7ab16a and upgrade to Java 8 . Run the install Maven goal to compile, test, and install the web app locally. Then start the web server

mvn install
mvn tomcat7:run

You should see the 'BUILD SUCCESS' message at some point. Then go to http://localhost:9966/petclinic/ and browse around to get familiar with the app.

This is the Pet clinic.

Hit Control-C to stop the web server, and turn the page for [next chapter].

Install the Checker Framework

Local installation in /opt.

Maven

We're going to do this slightly differently from the suggested installation at Checker Framework: compilation with checking is going to be separate from compilation for production.

The class files produced by the Checker Framework's compiler with annotation processing is different from the class files output by the standard compiler. Annotation processors already used in a project's build process may interfere with the Checker Framework's annotation processors: this is the case with the petclinic, which already uses annotation processing in the persistence layer -- I did not manage to run the code produced by the Checker Framework compiler.

Apart from that, it goes without saying that in many professional Java environments compiling with a different compiler is not an option. And if you're trying to convince your colleagues to get into checking, making it optional might actually be a boon.

Annotations

I like this experiment to be as unintrusive as possible. Instead of the Checker Framework's nullness annotations I'm going to use the ones from JSR 305. javax.annotation.Nullable is less powerful than its sibling org.checkerframework.checker.nullness.qual.Nullable though. Only the Checker Framework one supports usage as in List<@Nullable String>.

Anyway, I'm adding the relevant JAR in the dependencies section in commit 4f7f00c. (Don't worry about the missing <version>, Spring fills that in.)

Clone this wiki locally