You might remember my post about JSR-666 from April, where I asked whether the funny proposals to extend Java (for example, by adding a yoda keyword) were just a joke or a thinly veiled statement about the dangers of trying to shoehorn features into Java. So imagine my surprise when I saw another horrific JSR; but this time it isn’t a joke.

JSR-308 is a proposal to add annotations for types. It sounds harmless enough, right? But take a look at this sample code of the proposal in action:

Map<@NonNull String, @NonEmpty List<@Readonly Document>> files;
// Now imagine the code you'd have to write to instantiate one of these...  =P

I got that right from the JSR page. I shudder at the thought of having to maintain Java code with these new annotations littered all over the place. While I appreciate that they would enhance Java’s type system and possibly prevent some annoying bugs, I’m not sure if the added functionality is worth the added complexity. While it is fair to argue that your favourite IDE will handle it for you, I still think that is too much information to be processed in my head every time I look at such a declaration. I feel that Java already makes the programmer jump through too many syntactic hoops to get things done and this sounds like a proposal to add more hoops.

If this makes it into a future version of Java, I might well be convinced to jump. The inclusion of this new kind of annotation would be solid evidence that Java is on a path to madness.

Tags: ,