Package org.objectweb.asm
Class TypePath
- java.lang.Object
-
- org.objectweb.asm.TypePath
-
public final class TypePath extends java.lang.ObjectThe path to a type argument, wildcard bound, array element type, or static inner type within an enclosing type.
-
-
Field Summary
Fields Modifier and Type Field Description static intARRAY_ELEMENTA type path step that steps into the element type of an array type.static intINNER_TYPEA type path step that steps into the nested type of a class type.static intTYPE_ARGUMENTA type path step that steps into a type argument of a generic type.private byte[]typePathContainerThe byte array where the 'type_path' structure - as defined in the Java Virtual Machine Specification (JVMS) - corresponding to this TypePath is stored.private inttypePathOffsetThe offset of the first byte of the type_path JVMS structure intypePathContainer.static intWILDCARD_BOUNDA type path step that steps into the bound of a wildcard type.
-
Constructor Summary
Constructors Constructor Description TypePath(byte[] typePathContainer, int typePathOffset)Constructs a new TypePath.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static TypePathfromString(java.lang.String typePath)Converts a type path in string form, in the format used bytoString(), into a TypePath object.intgetLength()Returns the length of this path, i.e.intgetStep(int index)Returns the value of the given step of this path.intgetStepArgument(int index)Returns the index of the type argument that the given step is stepping into.(package private) static voidput(TypePath typePath, ByteVector output)Puts the type_path JVMS structure corresponding to the given TypePath into the given ByteVector.java.lang.StringtoString()Returns a string representation of this type path.
-
-
-
Field Detail
-
ARRAY_ELEMENT
public static final int ARRAY_ELEMENT
A type path step that steps into the element type of an array type. SeegetStep(int).- See Also:
- Constant Field Values
-
INNER_TYPE
public static final int INNER_TYPE
A type path step that steps into the nested type of a class type. SeegetStep(int).- See Also:
- Constant Field Values
-
WILDCARD_BOUND
public static final int WILDCARD_BOUND
A type path step that steps into the bound of a wildcard type. SeegetStep(int).- See Also:
- Constant Field Values
-
TYPE_ARGUMENT
public static final int TYPE_ARGUMENT
A type path step that steps into a type argument of a generic type. SeegetStep(int).- See Also:
- Constant Field Values
-
typePathContainer
private final byte[] typePathContainer
The byte array where the 'type_path' structure - as defined in the Java Virtual Machine Specification (JVMS) - corresponding to this TypePath is stored. The first byte of the structure in this array is given bytypePathOffset.- See Also:
- JVMS 4.7.20.2
-
typePathOffset
private final int typePathOffset
The offset of the first byte of the type_path JVMS structure intypePathContainer.
-
-
Method Detail
-
getLength
public int getLength()
Returns the length of this path, i.e. its number of steps.- Returns:
- the length of this path.
-
getStep
public int getStep(int index)
Returns the value of the given step of this path.- Parameters:
index- an index between 0 andgetLength(), exclusive.- Returns:
- one of
ARRAY_ELEMENT,INNER_TYPE,WILDCARD_BOUND, orTYPE_ARGUMENT.
-
getStepArgument
public int getStepArgument(int index)
Returns the index of the type argument that the given step is stepping into. This method should only be used for steps whose value isTYPE_ARGUMENT.- Parameters:
index- an index between 0 andgetLength(), exclusive.- Returns:
- the index of the type argument that the given step is stepping into.
-
fromString
public static TypePath fromString(java.lang.String typePath)
Converts a type path in string form, in the format used bytoString(), into a TypePath object.- Parameters:
typePath- a type path in string form, in the format used bytoString(). May be null or empty.- Returns:
- the corresponding TypePath object, or null if the path is empty.
-
toString
public java.lang.String toString()
Returns a string representation of this type path.ARRAY_ELEMENTsteps are represented with '[',INNER_TYPEsteps with '.',WILDCARD_BOUNDsteps with '*' andTYPE_ARGUMENTsteps with their type argument index in decimal form followed by ';'.- Overrides:
toStringin classjava.lang.Object
-
put
static void put(TypePath typePath, ByteVector output)
Puts the type_path JVMS structure corresponding to the given TypePath into the given ByteVector.- Parameters:
typePath- a TypePath instance, or null for empty paths.output- where the type path must be put.
-
-