Ability to define default type qualifiers that only apply to for public/protected methods?

Skip to first unread message

Bill Pugh

Jan 22, 2009, 12:12:14 PM1/22/09
to jsr...@googlegroups.com
From my previous email:
> I've been trying to apply JSR-305 nullness annotations at Google.
> That effort has led to me two thoughts, one of which I'm fairly
> confident about and the other of which I want feedback on. I'll
> separate them into two messages to keep any threads distinct.

This is the one I want feedback on.

In Google collections, the documentation at the package level that
parameters are nonnull by default was only intended to apply to public/
protected methods. The package documentation doesn't need to document
internal methods. Furthermore, the @Nullable annotation was rarely if
ever applied to methods with private or package access.

So this was the area where I had to do the most cleanup: applying
@Nullable annotations to the appropriate parameters of private and
package methods. I had similar issues with java.util.concurrent.

The question is: Should we provide a way to specify a package level
annotation that specifies, for example, a default type qualifier
annotation for parameters of only the public and protected methods,
without specifying a default for the private and package methods.

There are lots of details, and we'd need a specific proposal for
syntax, etc. I've got some ideas, but I'm not even sure I want to
argue for the idea.

Pro: Allows specification of intent closer to common current practice
Cons: Complicates things, doesn't really take that much more work to
provide annotations for the private/package methods


Brian Goetz

Jan 30, 2009, 3:12:30 PM1/30/09
to jsr...@googlegroups.com
We're treading dangerously close to AOP-territory here.

I think relying on visibility to determine eligibility for default annotations
is extremely fragile, even if it is convenient.
Reply all
Reply to author
0 new messages