Null-value constraints in Java code, plugin

Hi, I've been working on a way to use non-null types in Java 5.0 using annotations.
This is being implemented partly as an IDEA plugin. I thought some of you
might be interested in its development and I recently gave a presentation
to my college's research group, so I'll post the slides that I made for that

An example of code using this functionality is:

String maybeNull() { return null; }

void x() {
@NonNull String s = maybeNull(); // error
String p = "";
@NonNull String r = p; // safe

@NonNull String notNullBad() {
return maybeNull(); // error

@NonNull String notNull() {
return ""; // safe

void noNullParams(@NonNull String s) { }

void y() {
@NonNull String s = notNull(); // safe
noNullParams(null); // error
noNullParams(notNull()); // safe
noNullParams(""); // safe

Everywhere marked with "// error" produces a red underline in the editor,
and will produce errors at compile time.

I don't have a usable version of the plugin to release yet (currently it
has some huge memory leak that prevents use for more than a few minutes),
but I'll be releasing something soon.

1 comment
Comment actions Permalink

Sounds great. I'm eagerly awaiting more news on this.

Are you still doing the precondition-checking code generation? That
doesn't seem critical to me. Just having the errors show up in IDEA would be
a major advantage.

Either way, good luck. Hope you get it done in time for your college thingy.



Please sign in to leave a comment.