Please add more options for finer-grained control over which annotations are
applied to which program elements by default.
Here are two requested features:
* target annotations at fields without targeting methods or the enclosing class
* target based on a combination of modifiers (visibility, static or not, final or not)
This would be especially useful for classes that hold untrusted data parsed
from JSON or XML.
This is what the extended @DefaultQualifier API could look like when used in a
package-info.java file:
@DefaultQualifiers({
@DefaultQualifier(value = Nullable.class, targets = {
@Location({ PUBLIC, NON_FINAL, FIELDS }),
@Location({ VOLATILE, FIELDS })
}),
@DefaultQualifier(value=NonNull.class, targets = {
@Location({ PUBLIC, STATIC, FINAL, FIELDS })
})
})
package some.component;
import static checkers.quals.DefaultLocation.*;
import checkers.nullness.quals.NonNull;
import checkers.nullness.quals.Nullable;
import checkers.quals.DefaultQualifier;
import checkers.quals.DefaultQualifiers;
import checkers.quals.Location;
That package-info.java file would override the default annotations to be set
like this:
class ContrivedExamplePerson {
public static final String JOB_1 = "koodari"; // @NonNull
static volatile Boolean isValidationComplete; // @Nullable
public final String recordType = "minimum"; // not overridden
public String name; // @Nullable
public String occupation; // @Nullable
}
Original issue reported on code.google.com by timo.kin...@gmail.com on 9 Feb 2013 at 1:42
Original issue reported on code.google.com by
timo.kin...@gmail.com
on 9 Feb 2013 at 1:42