Class BinaryStubData.TypePathStep

java.lang.Object
org.checkerframework.framework.stub.BinaryStubData.TypePathStep
Enclosing class:
BinaryStubData

public static class BinaryStubData.TypePathStep extends Object
A single step in a type-annotation path, describing how to navigate from a base type to the component type that carries the annotation. The encoding mirrors the JVM's type-annotation path encoding defined in JVMS §4.7.20.2.
  • Field Details

    • KIND_ARRAY

      public static final byte KIND_ARRAY
      Constant for an array component path step (JVMS §4.7.20.2: 0). Defined once in BinaryStubWriter.TYPE_PATH_KIND_ARRAY.
      See Also:
    • KIND_INNER_TYPE

      public static final byte KIND_INNER_TYPE
      Constant for a nested type path step (JVMS §4.7.20.2: 1). Defined once in BinaryStubWriter.TYPE_PATH_KIND_INNER_TYPE.
      See Also:
    • KIND_WILDCARD

      public static final byte KIND_WILDCARD
      Constant for a wildcard bound path step (JVMS §4.7.20.2: 2). Defined once in BinaryStubWriter.TYPE_PATH_KIND_WILDCARD.
      See Also:
    • KIND_TYPE_ARGUMENT

      public static final byte KIND_TYPE_ARGUMENT
      Constant for a type argument path step (JVMS §4.7.20.2: 3). Defined once in BinaryStubWriter.TYPE_PATH_KIND_TYPE_ARGUMENT.
      See Also:
    • WILDCARD_BOUND_EXTENDS

      public static final byte WILDCARD_BOUND_EXTENDS
      Constant for an extends bound in a wildcard (repurposed argIndex). Defined once in BinaryStubWriter.TYPE_PATH_WILDCARD_BOUND_EXTENDS.
      See Also:
    • WILDCARD_BOUND_SUPER

      public static final byte WILDCARD_BOUND_SUPER
      Constant for a super bound in a wildcard (repurposed argIndex). Defined once in BinaryStubWriter.TYPE_PATH_WILDCARD_BOUND_SUPER.
      See Also:
    • kind

      public final byte kind
      The kind of path step: KIND_ARRAY = array component, KIND_INNER_TYPE = nested type, KIND_WILDCARD = wildcard bound, KIND_TYPE_ARGUMENT = type argument. Only 4 values are ever defined, so a signed byte is used as-is: no value this field takes needs the sign bit, so there is no unsigned/signed distinction to make here (contrast argIndex).

      KIND_INNER_TYPE is reserved so the numbering matches JVMS §4.7.20.2, but is never written and never resolved. BinaryStubWriter#extractTypeAnnotations descends into a type's own type arguments, not into those of its scope, so an annotation on a type argument of an enclosing type -- the @D of Outer<@D X>.Inner<T> -- is dropped rather than encoded with a nested-type step. That is not a divergence: AnnotationFileParser#annotate's DECLARED case reads only ClassOrInterfaceType.getTypeArguments() and never getScope() or AnnotatedDeclaredType.getEnclosingType(), so the text parser drops the same annotation. BinaryStubReader#resolvePath therefore rejects kind KIND_INNER_TYPE outright.

    • argIndex

      public final byte argIndex
      For kind 3 (type argument), the zero-based index of the type argument. For kind 2 (wildcard bound), repurposed to distinguish an extends bound (0) from a super bound (1): JVMS leaves this byte unused for wildcard bounds (a real wildcard has only one structurally possible bound), but CF's AnnotatedWildcardType always synthesizes both bounds, so #resolvePath needs this to know which one a given path step is for. Unused (0) for other kinds. Stored as a signed byte to match the 1-byte width of JVMS's type_argument_index (a u1, so its wire value ranges over 0-255); a value of 128 or greater is stored as a negative byte and must be reinterpreted as unsigned (& 0xFF) wherever it is widened to int for use (see BinaryStubReader#resolvePath). Left as byte rather than widened to int: one TypePathStep exists per path step of every type annotation in the annotated JDK, so widening every instance's fields would multiply that memory cost for a value that is realistically always a small, single-digit index.
  • Constructor Details