Class BinaryStubData.TypePathStep
java.lang.Object
org.checkerframework.framework.stub.BinaryStubData.TypePathStep
- Enclosing class:
BinaryStubData
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 Summary
FieldsModifier and TypeFieldDescriptionfinal byteForkind3(type argument), the zero-based index of the type argument.final byteThe kind of path step:KIND_ARRAY= array component,KIND_INNER_TYPE= nested type,KIND_WILDCARD= wildcard bound,KIND_TYPE_ARGUMENT= type argument.static final byteConstant for an array component path step (JVMS §4.7.20.2: 0).static final byteConstant for a nested type path step (JVMS §4.7.20.2: 1).static final byteConstant for a type argument path step (JVMS §4.7.20.2: 3).static final byteConstant for a wildcard bound path step (JVMS §4.7.20.2: 2).static final byteConstant for an extends bound in a wildcard (repurposed argIndex).static final byteConstant for a super bound in a wildcard (repurposed argIndex). -
Constructor Summary
Constructors -
Method Summary
-
Field Details
-
KIND_ARRAY
public static final byte KIND_ARRAYConstant for an array component path step (JVMS §4.7.20.2: 0). Defined once inBinaryStubWriter.TYPE_PATH_KIND_ARRAY.- See Also:
-
KIND_INNER_TYPE
public static final byte KIND_INNER_TYPEConstant for a nested type path step (JVMS §4.7.20.2: 1). Defined once inBinaryStubWriter.TYPE_PATH_KIND_INNER_TYPE.- See Also:
-
KIND_WILDCARD
public static final byte KIND_WILDCARDConstant for a wildcard bound path step (JVMS §4.7.20.2: 2). Defined once inBinaryStubWriter.TYPE_PATH_KIND_WILDCARD.- See Also:
-
KIND_TYPE_ARGUMENT
public static final byte KIND_TYPE_ARGUMENTConstant for a type argument path step (JVMS §4.7.20.2: 3). Defined once inBinaryStubWriter.TYPE_PATH_KIND_TYPE_ARGUMENT.- See Also:
-
WILDCARD_BOUND_EXTENDS
public static final byte WILDCARD_BOUND_EXTENDSConstant for an extends bound in a wildcard (repurposed argIndex). Defined once inBinaryStubWriter.TYPE_PATH_WILDCARD_BOUND_EXTENDS.- See Also:
-
WILDCARD_BOUND_SUPER
public static final byte WILDCARD_BOUND_SUPERConstant for a super bound in a wildcard (repurposed argIndex). Defined once inBinaryStubWriter.TYPE_PATH_WILDCARD_BOUND_SUPER.- See Also:
-
kind
public final byte kindThe 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 signedbyteis used as-is: no value this field takes needs the sign bit, so there is no unsigned/signed distinction to make here (contrastargIndex).KIND_INNER_TYPEis reserved so the numbering matches JVMS §4.7.20.2, but is never written and never resolved.BinaryStubWriter#extractTypeAnnotationsdescends 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@DofOuter<@D X>.Inner<T>-- is dropped rather than encoded with a nested-type step. That is not a divergence:AnnotationFileParser#annotate'sDECLAREDcase reads onlyClassOrInterfaceType.getTypeArguments()and nevergetScope()orAnnotatedDeclaredType.getEnclosingType(), so the text parser drops the same annotation.BinaryStubReader#resolvePaththerefore rejects kindKIND_INNER_TYPEoutright. -
argIndex
public final byte argIndexForkind3(type argument), the zero-based index of the type argument. Forkind2(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'sAnnotatedWildcardTypealways synthesizes both bounds, so#resolvePathneeds this to know which one a given path step is for. Unused (0) for other kinds. Stored as a signedbyteto match the 1-byte width of JVMS'stype_argument_index(au1, so its wire value ranges over 0-255); a value of 128 or greater is stored as a negativebyteand must be reinterpreted as unsigned (& 0xFF) wherever it is widened tointfor use (seeBinaryStubReader#resolvePath). Left asbyterather than widened toint: oneTypePathStepexists 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
-
TypePathStep
public TypePathStep(byte kind, byte argIndex) Constructs a TypePathStep.- Parameters:
kind- the kind of path step (one ofKIND_ARRAY,KIND_INNER_TYPE,KIND_WILDCARD,KIND_TYPE_ARGUMENT)argIndex- forKIND_TYPE_ARGUMENT, the zero-based index of the type argument; forKIND_WILDCARD,WILDCARD_BOUND_EXTENDSorWILDCARD_BOUND_SUPER; unused (0) for other kinds
-