jspecify/jspecify

Remove `@Target(MODULE)` from `@NullUnmarked`?

Closed this issue · 3 comments

Seems like it can't serve any purpose and might confuse someone (who rightly thinks "but I thought it was the default").

That sounds sensible, and I like it a lot for an additional reason:

Removing MODULE would at least marginally decrease the chances that users would encounter the crash discussed in #302. In fact, if we imagine a world in which users use @NullMarked only at the class, package, and module levels, while perhaps using @NullUnmarked on individual methods, then removing MODULE would eliminate #302. In practice, I'm sure it wouldn't totally eliminate it. But it might help a lot.

The main counterargument I can see is that an enterprising organization might try to "flip the default" for now code so that all code is considered null-marked unless otherwise annotated :) Then they might theoretically want to unmark their already existing modules. But I'm inclined not to worry about that, thanks to some combination of:

  • For that to work, every tool that the organization uses would need to support "null-marked by default."
  • Some people don't make use of modules.
  • It doesn't seem that hard to put in place enforcement that all new modules are @NullMarked.
  • We might even look askance at the idea that code without @NullMarked should be treated as null-marked in general.

This is my askance look.

#351 did this and updated docs accordingly.