Community
Participate
Working Groups
I believe there would be value in allowing to externally annotate (EEA) a package of a library with @NonNullByDefault. If this is already possible today and I'm not getting it, could you elaborate how one does this? I've tried the Ctrl-1 on the package name and keyword declaration in a Some.class, as well as on the package-info.class, and neither do anything. For example, the Google Guava authors seem to assume @NonNull for most of their code (and they do use @Nullable occasionally), so instead of annotating method after method return value with @NonNull, it would be cool if I could externally annotate their package. (FYI The Guava packages do have a javax.annotation.ParametersAreNonnullByDefault which one could "interpret" as a secondary annotation for @NonNullByDefault, if though that's not exactly the same semantics.)
Not supported. I initially assumed, that eea should spell out each annotation individually (which could still be generated by some tool, of course). I see some room for improvement now, but I'm reluctant to increase the number of lookups needed to read one class. So, as a compromise I could see a per-class @NNBD stored in an .eea file.
> which could still be generated by some tool, of course Yeah, if JDT core will not add this, then that's another solution to this problem (as it IS a PITA to manually annotate something like Guava or even the JDK...) - a tool which reads e.g. *.java sources, sees a package-info.java with a @NonNullByDefault package, then scans the classpath to find that package, and creates the full EEA for every field and every method in class of that package. If I have the time, perhaps I'll build this feature into https://github.com/lastnpe/external-annotations-esperanto, some day.. > So, as a compromise I could see a per-class @NNBD stored in an .eea file. That could be useful as well.