Annotation Interface HasQualifierParameter


@Inherited @Documented @Retention(RUNTIME) @Target({TYPE,PACKAGE}) public @interface HasQualifierParameter
This is a declaration annotation that applies to type declarations and packages. On a type, it means that the class conceptually takes a type qualifier parameter, though there is nowhere to write it because the class hard-codes a Java basetype rather than taking a type parameter. Writing HasQualifierParameter on a package is the same as writing it on each class in that package.

Written on a type declaration

Writing @HasQualifierParameter on a type declaration has two effects.

  1. Invariant subtyping is used for occurrences of the type: no two occurrences of the type with different qualifiers have a subtyping relationship.
  2. The polymorphic qualifier is the default for all occurrences of that type in its own compilation unit, including as the receiver, as another formal parameter, or as a return type.
Here is an example of the effect of invariant subtyping. Suppose we have the following declaration:
  @HasQualifierParameter
   class StringBuffer { ... }
 
Then @Tainted StringBuffer is unrelated to @Untainted StringBuffer.

The type hierarchy looks like this:


                       @Tainted Object
                      /       |       \
                     /        |       @Tainted Date
                   /          |               |
                  /           |               |
                 /   @Untainted Object       |
                /             |       \       |
  @Tainted StringBuffer      |      @Untainted Date
             |                |
             |      @Untainted StringBuffer
             |                |
  @Tainted MyStringBuffer    |
                              |
                    @Untainted MyStringBuffer
 

When a type is @HasQualifierParameter, all its subtypes are as well. That is, the @HasQualifierParameter annotation is inherited by subtypes.

Written on a package

When @HasQualifierParameter is written on a package, it is equivalent to writing that annotation on each class in the package or in a sub-package. It can be disabled on a specific class and its subclasses by writing @NoQualifierParameter on that class. This annotation may not be written on the same class as NoQualifierParameter for the same hierarchy.

See Also:
  • Required Element Summary

    Required Elements
    Modifier and Type
    Required Element
    Description
    Class<? extends Annotation>[]
    Class of the top qualifier for the hierarchy for which this class has a qualifier parameter.
  • Element Details

    • value

      Class<? extends Annotation>[] value
      Class of the top qualifier for the hierarchy for which this class has a qualifier parameter.
      Returns:
      the value