Class Indexer
- java.lang.Object
-
- org.jboss.jandex.Indexer
-
public final class Indexer extends java.lang.Object
Analyzes and indexes the annotation and key structural information of a set of classes. The indexer will purposefully skip any class that is not Java 5 or later. It will also do a basic/quick structural scan on any class it determines does not have annotations.The Indexer operates on input streams that point to class file data. Input streams do not need to be buffered, as the indexer already does this. There is also no limit to the number of class file streams the indexer can process, other than available memory.
The Indexer attempts to minimize the final memory state of the index, but to do this it must maintain additional in-process state (intern tables etc) until the index is complete.
Numerous optimizations are taken during indexing to attempt to minimize the CPU and I/O cost, however, the Java class file format was not designed for partial searching, which ultimately limits the efficiency of processing them.
Thread-Safety This class is not thread-safe can not be shared between threads. The index it produces however is thread-safe.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static class
Indexer.BooleanHolder
private static class
Indexer.InnerClassInfo
private static class
Indexer.IntegerHolder
private static class
Indexer.NameAndType
private static class
Indexer.PathElement
private static class
Indexer.PathElementStack
private static class
Indexer.TmpObjects
private static class
Indexer.TypeAnnotationState
-
Field Summary
Fields Modifier and Type Field Description private static byte[]
ANNOTATION_DEFAULT
private static int
ANNOTATION_DEFAULT_LEN
private java.util.HashMap<DotName,java.util.List<AnnotationInstance>>
classAnnotations
private java.util.Map<DotName,ClassInfo>
classes
private int
classSignatureIndex
private static byte[]
CODE
private static int
CODE_LEN
private static int
CONSTANT_CLASS
private static int
CONSTANT_DOUBLE
private static int
CONSTANT_DYNAMIC
private static int
CONSTANT_FIELDREF
private static int
CONSTANT_FLOAT
private static int
CONSTANT_INTEGER
private static int
CONSTANT_INTERFACEMETHODREF
private static int
CONSTANT_INVOKEDYNAMIC
private static int
CONSTANT_LONG
private static int
CONSTANT_METHODHANDLE
private static int
CONSTANT_METHODREF
private static int
CONSTANT_METHODTYPE
private static int
CONSTANT_MODULE
private static int
CONSTANT_NAMEANDTYPE
private static int
CONSTANT_PACKAGE
private static int
CONSTANT_STRING
private static int
CONSTANT_UTF8
private byte[]
constantPool
private byte[]
constantPoolAnnoAttrributes
private int[]
constantPoolOffsets
private int
constantPoolSize
private ClassInfo
currentClass
private java.util.ArrayList<AnnotationInstance>
elementAnnotations
private static byte[]
ENCLOSING_METHOD
private static int
ENCLOSING_METHOD_LEN
private static byte[]
EXCEPTIONS
private static int
EXCEPTIONS_LEN
private java.util.List<FieldInfo>
fields
private static int
HAS_ANNOTATION_DEFAULT
private static int
HAS_CODE
private static int
HAS_ENCLOSING_METHOD
private static int
HAS_EXCEPTIONS
private static int
HAS_INNER_CLASSES
private static int
HAS_LOCAL_VARIABLE_TABLE
private static int
HAS_METHOD_PARAMETERS
private static int
HAS_MODULE
private static int
HAS_MODULE_MAIN_CLASS
private static int
HAS_MODULE_PACKAGES
private static int
HAS_PERMITTED_SUBCLASSES
private static int
HAS_RECORD
private static int
HAS_RUNTIME_ANNOTATION
private static int
HAS_RUNTIME_INVISIBLE_ANNOTATION
private static int
HAS_RUNTIME_INVISIBLE_PARAM_ANNOTATION
private static int
HAS_RUNTIME_INVISIBLE_TYPE_ANNOTATION
private static int
HAS_RUNTIME_PARAM_ANNOTATION
private static int
HAS_RUNTIME_TYPE_ANNOTATION
private static int
HAS_SIGNATURE
private java.util.Map<DotName,java.util.List<ClassInfo>>
implementors
private static byte[]
INNER_CLASSES
private static int
INNER_CLASSES_LEN
private java.util.Map<DotName,Indexer.InnerClassInfo>
innerClasses
private static byte[]
LOCAL_VARIABLE_TABLE
private static int
LOCAL_VARIABLE_TABLE_LEN
private java.util.Map<DotName,java.util.List<AnnotationInstance>>
masterAnnotations
private static byte[]
METHOD_PARAMETERS
private static int
METHOD_PARAMETERS_LEN
private java.util.IdentityHashMap<MethodInfo,MethodParamList>
methodParams
private java.util.List<MethodInfo>
methods
private static byte[]
MODULE
private static int
MODULE_LEN
private static byte[]
MODULE_MAIN_CLASS
private static int
MODULE_MAIN_CLASS_LEN
private static byte[]
MODULE_PACKAGES
private static int
MODULE_PACKAGES_LEN
private DotName
moduleMainClass
private java.util.List<DotName>
modulePackages
private java.util.Map<DotName,ModuleInfo>
modules
private NameTable
names
private static byte[]
PERMITTED_SUBCLASSES
private static int
PERMITTED_SUBCLASSES_LEN
private static byte[]
RECORD
private static int
RECORD_LEN
private java.util.List<RecordComponentInfo>
recordComponents
private static byte[]
RUNTIME_ANNOTATIONS
private static int
RUNTIME_ANNOTATIONS_LEN
private static byte[]
RUNTIME_INVISIBLE_ANNOTATIONS
private static int
RUNTIME_INVISIBLE_ANNOTATIONS_LEN
private static byte[]
RUNTIME_INVISIBLE_PARAM_ANNOTATIONS
private static int
RUNTIME_INVISIBLE_PARAM_ANNOTATIONS_LEN
private static byte[]
RUNTIME_INVISIBLE_TYPE_ANNOTATIONS
private static int
RUNTIME_INVISIBLE_TYPE_ANNOTATIONS_LEN
private static byte[]
RUNTIME_PARAM_ANNOTATIONS
private static int
RUNTIME_PARAM_ANNOTATIONS_LEN
private static byte[]
RUNTIME_TYPE_ANNOTATIONS
private static int
RUNTIME_TYPE_ANNOTATIONS_LEN
private static byte[]
SIGNATURE
private static int
SIGNATURE_LEN
private GenericSignatureParser
signatureParser
private java.util.IdentityHashMap<AnnotationTarget,java.lang.Object>
signaturePresent
private java.util.List<java.lang.Object>
signatures
private java.util.Map<DotName,java.util.List<ClassInfo>>
subclasses
private java.util.Map<DotName,java.util.List<ClassInfo>>
subinterfaces
private Indexer.TmpObjects
tmpObjects
private java.util.IdentityHashMap<AnnotationTarget,java.util.List<Indexer.TypeAnnotationState>>
typeAnnotations
private java.util.Map<DotName,java.util.Set<ClassInfo>>
users
-
Constructor Summary
Constructors Constructor Description Indexer()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private void
addImplementor(DotName interfaceName, ClassInfo currentClass)
private void
addSubclass(DotName superName, ClassInfo currentClass)
private void
addSubinterface(DotName superName, ClassInfo currentClass)
private void
adjustMethodParameters()
private void
applySignatures()
private int
bitsToInt(byte[] pool, int pos)
private long
bitsToLong(byte[] pool, int pos)
private java.util.ArrayDeque<Indexer.InnerClassInfo>
buildClassesQueue(Type type)
Returns a list ofIndexer.InnerClassInfo
s representing types enclosing giventype
.private java.util.Map<DotName,Type>
buildOwnerMap(Type type)
Index
complete()
Completes, finalizes, and returns the index after zero or more calls toindex()
.private static java.lang.String
convertClassFieldDescriptor(java.lang.String descriptor)
private ParameterizedType
convertParameterized(Type oType)
private static Type[]
copyTypeParameters(AnnotationTarget target)
private DotName
decodeClassEntry(int index)
private DotName
decodeDotNameEntry(int index, int constantType, java.lang.String typeName, char delim)
private double
decodeDoubleEntry(int index)
private float
decodeFloatEntry(int index)
private int
decodeIntegerEntry(int index)
private long
decodeLongEntry(int index)
private DotName
decodeModuleEntry(int index)
private Indexer.NameAndType
decodeNameAndTypeEntry(int index)
private java.lang.String
decodeOptionalUtf8Entry(int index)
private DotName
decodePackageEntry(int index)
private java.lang.String
decodeUtf8Entry(int index)
private byte[]
decodeUtf8EntryAsBytes(int index)
private Type
deepCopyTypeIfNeeded(Type type)
Whentype
contains no type variable references, returnstype
.private TypeVariable
findTypeParameter(Type[] typeParameters, java.lang.String identifier)
Finds and returns a type variable with givenidentifier
among giventypeParameters
.private static Type[]
getTypeParameters(AnnotationTarget target)
private java.lang.String
getTypeVariableIdentifier(Type typeVariable)
private boolean
hasAnonymousEncloser(Indexer.TypeAnnotationState typeAnnotationState)
private boolean
hasLocalEncloser(Indexer.TypeAnnotationState typeAnnotationState)
void
index(java.io.InputStream stream)
Analyze and index the class file data present in given inputstream
.ClassInfo
index$$bridge(java.io.InputStream stream)
void
indexClass(java.lang.Class<?> clazz)
Analyze and index the class file data of givenclazz
.ClassInfo
indexClass$$bridge(java.lang.Class<?> clazz)
ClassSummary
indexWithSummary(java.io.InputStream stream)
Analyze and index the class file data present in given inputstream
.private void
initClassFields()
private void
initIndexMaps()
private byte[]
intern(byte[] bytes)
private java.lang.String
intern(java.lang.String string)
private Type
intern(Type type)
private Type[]
intern(Type[] type)
private boolean
isBridge(MethodInfo methodInfo)
private static boolean
isEnumConstructor(MethodInfo method)
private boolean
isInnerConstructor(MethodInfo method)
private boolean
isJDK11OrNewer(java.io.DataInputStream stream)
private static boolean
match(byte[] target, int offset, byte[] expected)
private static int
minLength(int oldLength, int minGrowth)
private static int
newLength(int oldLength, int minGrowth, int prefGrowth)
private DotName
outermostAnnotableTypeName(Type type)
Returns the name of the outermost type that encloses giventype
and on which type annotations are admissible.private void
parseClassSignature(java.lang.String signature, ClassInfo clazz)
private void
parseFieldSignature(java.lang.String signature, FieldInfo field)
private Type[]
parseMethodArgs(java.lang.String descriptor, Indexer.IntegerHolder pos)
private void
parseMethodSignature(java.lang.String signature, MethodInfo method)
private void
parseRecordComponentSignature(java.lang.String signature, RecordComponentInfo recordComponent)
private Type
parseType(java.lang.String descriptor)
private Type
parseType(java.lang.String descriptor, Indexer.IntegerHolder pos)
private void
patchTypeVariableReferences(Type type, java.util.Deque<TypeVariable> typeVarStack, AnnotationTarget parametricEncloser)
Patches all type variable references contained in giventype
.private int
popNestedDepth(Indexer.PathElementStack elements)
private AnnotationInstance
processAnnotation(java.io.DataInputStream data, AnnotationTarget target, boolean visible)
private void
processAnnotationDefault(java.io.DataInputStream data, MethodInfo target)
private AnnotationValue
processAnnotationElementValue(java.lang.String name, java.io.DataInputStream data)
private void
processAnnotations(java.io.DataInputStream data, AnnotationTarget target, boolean visible)
private void
processAttributes(java.io.DataInputStream data, AnnotationTarget target)
private void
processClassInfo(java.io.DataInputStream data)
private void
processCode(java.io.DataInputStream data, MethodInfo target)
private boolean
processConstantPool(java.io.DataInputStream stream)
private void
processEnclosingMethod(java.io.DataInputStream data, ClassInfo target)
private void
processExceptions(java.io.DataInputStream data, MethodInfo target)
private void
processFieldInfo(java.io.DataInputStream data)
private void
processInnerClasses(java.io.DataInputStream data, ClassInfo target)
private void
processLocalVariableTable(java.io.DataInputStream data, MethodInfo target)
private void
processMethodInfo(java.io.DataInputStream data)
private void
processMethodParameters(java.io.DataInputStream data, MethodInfo target)
private void
processModule(java.io.DataInputStream data, ClassInfo target)
private java.util.List<ModuleInfo.ExportedPackageInfo>
processModuleExports(java.io.DataInputStream data)
private void
processModuleMainClass(java.io.DataInputStream data, ClassInfo target)
private java.util.List<ModuleInfo.OpenedPackageInfo>
processModuleOpens(java.io.DataInputStream data)
private void
processModulePackages(java.io.DataInputStream data, ClassInfo target)
private java.util.List<ModuleInfo.ProvidedServiceInfo>
processModuleProvides(java.io.DataInputStream data)
private java.util.List<ModuleInfo.RequiredModuleInfo>
processModuleRequires(java.io.DataInputStream data)
private java.util.List<DotName>
processModuleUses(java.io.DataInputStream data)
private void
processPermittedSubclasses(java.io.DataInputStream data, ClassInfo target)
private void
processRecordComponents(java.io.DataInputStream data)
private void
processSignature(java.io.DataInputStream data, AnnotationTarget target)
private java.util.ArrayList<Indexer.PathElement>
processTargetPath(java.io.DataInputStream data, Indexer.BooleanHolder genericsRequired, Indexer.BooleanHolder bridgeIncompatible)
private Indexer.TypeAnnotationState
processTypeAnnotation(java.io.DataInputStream data, AnnotationTarget target, boolean visible)
private void
processTypeAnnotations(java.io.DataInputStream data, AnnotationTarget target, boolean visible)
private Type
propagateOneTypeParameterBound(Type type, Type[] allTypeParams, AnnotationTarget target)
private void
propagateTypeParameterBounds()
private void
propagateTypeParameterBounds(AnnotationTarget target, java.util.Deque<TypeVariable> sharedTypeVarStack)
private void
propagateTypeVariables()
private Type
propagateTypeVariables(Type type, AnnotationTarget parametricEncloser)
private Type
rebuildNestedType(Type last, java.util.ArrayDeque<Indexer.InnerClassInfo> classes, Type type, int depth, Indexer.TypeAnnotationState typeAnnotationState)
private void
recordAnnotation(java.util.Map<DotName,java.util.List<AnnotationInstance>> classAnnotations, DotName annotation, AnnotationInstance instance)
private void
recordUsedClass(DotName usedClass)
private void
recordUsedType(Type type)
private void
resolveTypeAnnotation(AnnotationTarget target, Indexer.TypeAnnotationState typeAnnotationState)
private void
resolveTypeAnnotations()
private TypeVariable
resolveTypeParameter(AnnotationTarget target, java.lang.String identifier)
Resolves a given type variableidentifier
against given parametrictarget
(either a method or a class).private Type
resolveTypePath(Type type, Indexer.TypeAnnotationState typeAnnotationState)
private void
resolveUsers()
private void
retargetTypeAnnotations(AnnotationTarget parametricEncloser, Type oldType, Type newType)
private Type
searchNestedType(Type type, int depth, Indexer.TypeAnnotationState typeAnnotationState)
private Type
searchTypePath(Type type, Indexer.TypeAnnotationState typeAnnotationState)
private static void
setTypeParameters(AnnotationTarget target, Type[] typeParameters)
private static byte[]
sizeToFit(byte[] buf, int needed, int offset, int remainingEntries)
private boolean
skipBridge(Indexer.TypeAnnotationState typeAnnotationState, MethodInfo method)
private static void
skipFully(java.io.InputStream s, long n)
private void
skipTargetPath(java.io.DataInputStream data)
private boolean
targetsArray(Indexer.TypeAnnotationState typeAnnotationState)
private void
updateTypeTarget(AnnotationTarget enclosingTarget, Indexer.TypeAnnotationState typeAnnotationState)
private void
updateTypeTargets()
private void
verifyMagic(java.io.DataInputStream stream)
-
-
-
Field Detail
-
CONSTANT_CLASS
private static final int CONSTANT_CLASS
- See Also:
- Constant Field Values
-
CONSTANT_FIELDREF
private static final int CONSTANT_FIELDREF
- See Also:
- Constant Field Values
-
CONSTANT_METHODREF
private static final int CONSTANT_METHODREF
- See Also:
- Constant Field Values
-
CONSTANT_INTERFACEMETHODREF
private static final int CONSTANT_INTERFACEMETHODREF
- See Also:
- Constant Field Values
-
CONSTANT_STRING
private static final int CONSTANT_STRING
- See Also:
- Constant Field Values
-
CONSTANT_INTEGER
private static final int CONSTANT_INTEGER
- See Also:
- Constant Field Values
-
CONSTANT_FLOAT
private static final int CONSTANT_FLOAT
- See Also:
- Constant Field Values
-
CONSTANT_LONG
private static final int CONSTANT_LONG
- See Also:
- Constant Field Values
-
CONSTANT_DOUBLE
private static final int CONSTANT_DOUBLE
- See Also:
- Constant Field Values
-
CONSTANT_NAMEANDTYPE
private static final int CONSTANT_NAMEANDTYPE
- See Also:
- Constant Field Values
-
CONSTANT_UTF8
private static final int CONSTANT_UTF8
- See Also:
- Constant Field Values
-
CONSTANT_INVOKEDYNAMIC
private static final int CONSTANT_INVOKEDYNAMIC
- See Also:
- Constant Field Values
-
CONSTANT_METHODHANDLE
private static final int CONSTANT_METHODHANDLE
- See Also:
- Constant Field Values
-
CONSTANT_METHODTYPE
private static final int CONSTANT_METHODTYPE
- See Also:
- Constant Field Values
-
CONSTANT_MODULE
private static final int CONSTANT_MODULE
- See Also:
- Constant Field Values
-
CONSTANT_PACKAGE
private static final int CONSTANT_PACKAGE
- See Also:
- Constant Field Values
-
CONSTANT_DYNAMIC
private static final int CONSTANT_DYNAMIC
- See Also:
- Constant Field Values
-
RUNTIME_ANNOTATIONS
private static final byte[] RUNTIME_ANNOTATIONS
-
RUNTIME_PARAM_ANNOTATIONS
private static final byte[] RUNTIME_PARAM_ANNOTATIONS
-
RUNTIME_TYPE_ANNOTATIONS
private static final byte[] RUNTIME_TYPE_ANNOTATIONS
-
ANNOTATION_DEFAULT
private static final byte[] ANNOTATION_DEFAULT
-
SIGNATURE
private static final byte[] SIGNATURE
-
EXCEPTIONS
private static final byte[] EXCEPTIONS
-
INNER_CLASSES
private static final byte[] INNER_CLASSES
-
ENCLOSING_METHOD
private static final byte[] ENCLOSING_METHOD
-
METHOD_PARAMETERS
private static final byte[] METHOD_PARAMETERS
-
LOCAL_VARIABLE_TABLE
private static final byte[] LOCAL_VARIABLE_TABLE
-
CODE
private static final byte[] CODE
-
MODULE
private static final byte[] MODULE
-
MODULE_PACKAGES
private static final byte[] MODULE_PACKAGES
-
MODULE_MAIN_CLASS
private static final byte[] MODULE_MAIN_CLASS
-
RECORD
private static final byte[] RECORD
-
RUNTIME_INVISIBLE_ANNOTATIONS
private static final byte[] RUNTIME_INVISIBLE_ANNOTATIONS
-
RUNTIME_INVISIBLE_PARAM_ANNOTATIONS
private static final byte[] RUNTIME_INVISIBLE_PARAM_ANNOTATIONS
-
RUNTIME_INVISIBLE_TYPE_ANNOTATIONS
private static final byte[] RUNTIME_INVISIBLE_TYPE_ANNOTATIONS
-
PERMITTED_SUBCLASSES
private static final byte[] PERMITTED_SUBCLASSES
-
RUNTIME_ANNOTATIONS_LEN
private static final int RUNTIME_ANNOTATIONS_LEN
-
RUNTIME_PARAM_ANNOTATIONS_LEN
private static final int RUNTIME_PARAM_ANNOTATIONS_LEN
-
RUNTIME_TYPE_ANNOTATIONS_LEN
private static final int RUNTIME_TYPE_ANNOTATIONS_LEN
-
ANNOTATION_DEFAULT_LEN
private static final int ANNOTATION_DEFAULT_LEN
-
SIGNATURE_LEN
private static final int SIGNATURE_LEN
-
EXCEPTIONS_LEN
private static final int EXCEPTIONS_LEN
-
INNER_CLASSES_LEN
private static final int INNER_CLASSES_LEN
-
ENCLOSING_METHOD_LEN
private static final int ENCLOSING_METHOD_LEN
-
METHOD_PARAMETERS_LEN
private static final int METHOD_PARAMETERS_LEN
-
LOCAL_VARIABLE_TABLE_LEN
private static final int LOCAL_VARIABLE_TABLE_LEN
-
CODE_LEN
private static final int CODE_LEN
-
MODULE_LEN
private static final int MODULE_LEN
-
MODULE_PACKAGES_LEN
private static final int MODULE_PACKAGES_LEN
-
MODULE_MAIN_CLASS_LEN
private static final int MODULE_MAIN_CLASS_LEN
-
RECORD_LEN
private static final int RECORD_LEN
-
RUNTIME_INVISIBLE_ANNOTATIONS_LEN
private static final int RUNTIME_INVISIBLE_ANNOTATIONS_LEN
-
RUNTIME_INVISIBLE_PARAM_ANNOTATIONS_LEN
private static final int RUNTIME_INVISIBLE_PARAM_ANNOTATIONS_LEN
-
RUNTIME_INVISIBLE_TYPE_ANNOTATIONS_LEN
private static final int RUNTIME_INVISIBLE_TYPE_ANNOTATIONS_LEN
-
PERMITTED_SUBCLASSES_LEN
private static final int PERMITTED_SUBCLASSES_LEN
-
HAS_RUNTIME_ANNOTATION
private static final int HAS_RUNTIME_ANNOTATION
- See Also:
- Constant Field Values
-
HAS_RUNTIME_PARAM_ANNOTATION
private static final int HAS_RUNTIME_PARAM_ANNOTATION
- See Also:
- Constant Field Values
-
HAS_RUNTIME_TYPE_ANNOTATION
private static final int HAS_RUNTIME_TYPE_ANNOTATION
- See Also:
- Constant Field Values
-
HAS_SIGNATURE
private static final int HAS_SIGNATURE
- See Also:
- Constant Field Values
-
HAS_EXCEPTIONS
private static final int HAS_EXCEPTIONS
- See Also:
- Constant Field Values
-
HAS_INNER_CLASSES
private static final int HAS_INNER_CLASSES
- See Also:
- Constant Field Values
-
HAS_ENCLOSING_METHOD
private static final int HAS_ENCLOSING_METHOD
- See Also:
- Constant Field Values
-
HAS_ANNOTATION_DEFAULT
private static final int HAS_ANNOTATION_DEFAULT
- See Also:
- Constant Field Values
-
HAS_METHOD_PARAMETERS
private static final int HAS_METHOD_PARAMETERS
- See Also:
- Constant Field Values
-
HAS_LOCAL_VARIABLE_TABLE
private static final int HAS_LOCAL_VARIABLE_TABLE
- See Also:
- Constant Field Values
-
HAS_CODE
private static final int HAS_CODE
- See Also:
- Constant Field Values
-
HAS_MODULE
private static final int HAS_MODULE
- See Also:
- Constant Field Values
-
HAS_MODULE_PACKAGES
private static final int HAS_MODULE_PACKAGES
- See Also:
- Constant Field Values
-
HAS_MODULE_MAIN_CLASS
private static final int HAS_MODULE_MAIN_CLASS
- See Also:
- Constant Field Values
-
HAS_RECORD
private static final int HAS_RECORD
- See Also:
- Constant Field Values
-
HAS_RUNTIME_INVISIBLE_ANNOTATION
private static final int HAS_RUNTIME_INVISIBLE_ANNOTATION
- See Also:
- Constant Field Values
-
HAS_RUNTIME_INVISIBLE_PARAM_ANNOTATION
private static final int HAS_RUNTIME_INVISIBLE_PARAM_ANNOTATION
- See Also:
- Constant Field Values
-
HAS_RUNTIME_INVISIBLE_TYPE_ANNOTATION
private static final int HAS_RUNTIME_INVISIBLE_TYPE_ANNOTATION
- See Also:
- Constant Field Values
-
HAS_PERMITTED_SUBCLASSES
private static final int HAS_PERMITTED_SUBCLASSES
- See Also:
- Constant Field Values
-
constantPoolSize
private int constantPoolSize
-
constantPool
private byte[] constantPool
-
constantPoolOffsets
private int[] constantPoolOffsets
-
constantPoolAnnoAttrributes
private byte[] constantPoolAnnoAttrributes
-
currentClass
private ClassInfo currentClass
-
classAnnotations
private java.util.HashMap<DotName,java.util.List<AnnotationInstance>> classAnnotations
-
elementAnnotations
private java.util.ArrayList<AnnotationInstance> elementAnnotations
-
signaturePresent
private java.util.IdentityHashMap<AnnotationTarget,java.lang.Object> signaturePresent
-
signatures
private java.util.List<java.lang.Object> signatures
-
classSignatureIndex
private int classSignatureIndex
-
innerClasses
private java.util.Map<DotName,Indexer.InnerClassInfo> innerClasses
-
typeAnnotations
private java.util.IdentityHashMap<AnnotationTarget,java.util.List<Indexer.TypeAnnotationState>> typeAnnotations
-
methods
private java.util.List<MethodInfo> methods
-
fields
private java.util.List<FieldInfo> fields
-
recordComponents
private java.util.List<RecordComponentInfo> recordComponents
-
methodParams
private java.util.IdentityHashMap<MethodInfo,MethodParamList> methodParams
-
modulePackages
private java.util.List<DotName> modulePackages
-
moduleMainClass
private DotName moduleMainClass
-
masterAnnotations
private java.util.Map<DotName,java.util.List<AnnotationInstance>> masterAnnotations
-
modules
private java.util.Map<DotName,ModuleInfo> modules
-
names
private NameTable names
-
signatureParser
private GenericSignatureParser signatureParser
-
tmpObjects
private final Indexer.TmpObjects tmpObjects
-
-
Method Detail
-
match
private static boolean match(byte[] target, int offset, byte[] expected)
-
sizeToFit
private static byte[] sizeToFit(byte[] buf, int needed, int offset, int remainingEntries)
-
newLength
private static int newLength(int oldLength, int minGrowth, int prefGrowth)
-
minLength
private static int minLength(int oldLength, int minGrowth)
-
skipFully
private static void skipFully(java.io.InputStream s, long n) throws java.io.IOException
- Throws:
java.io.IOException
-
initIndexMaps
private void initIndexMaps()
-
initClassFields
private void initClassFields()
-
processMethodInfo
private void processMethodInfo(java.io.DataInputStream data) throws java.io.IOException
- Throws:
java.io.IOException
-
processFieldInfo
private void processFieldInfo(java.io.DataInputStream data) throws java.io.IOException
- Throws:
java.io.IOException
-
processRecordComponents
private void processRecordComponents(java.io.DataInputStream data) throws java.io.IOException
- Throws:
java.io.IOException
-
processPermittedSubclasses
private void processPermittedSubclasses(java.io.DataInputStream data, ClassInfo target) throws java.io.IOException
- Throws:
java.io.IOException
-
processAttributes
private void processAttributes(java.io.DataInputStream data, AnnotationTarget target) throws java.io.IOException
- Throws:
java.io.IOException
-
processModule
private void processModule(java.io.DataInputStream data, ClassInfo target) throws java.io.IOException
- Throws:
java.io.IOException
-
processModuleRequires
private java.util.List<ModuleInfo.RequiredModuleInfo> processModuleRequires(java.io.DataInputStream data) throws java.io.IOException
- Throws:
java.io.IOException
-
processModuleExports
private java.util.List<ModuleInfo.ExportedPackageInfo> processModuleExports(java.io.DataInputStream data) throws java.io.IOException
- Throws:
java.io.IOException
-
processModuleOpens
private java.util.List<ModuleInfo.OpenedPackageInfo> processModuleOpens(java.io.DataInputStream data) throws java.io.IOException
- Throws:
java.io.IOException
-
processModuleUses
private java.util.List<DotName> processModuleUses(java.io.DataInputStream data) throws java.io.IOException
- Throws:
java.io.IOException
-
processModuleProvides
private java.util.List<ModuleInfo.ProvidedServiceInfo> processModuleProvides(java.io.DataInputStream data) throws java.io.IOException
- Throws:
java.io.IOException
-
processModulePackages
private void processModulePackages(java.io.DataInputStream data, ClassInfo target) throws java.io.IOException
- Throws:
java.io.IOException
-
processModuleMainClass
private void processModuleMainClass(java.io.DataInputStream data, ClassInfo target) throws java.io.IOException
- Throws:
java.io.IOException
-
processCode
private void processCode(java.io.DataInputStream data, MethodInfo target) throws java.io.IOException
- Throws:
java.io.IOException
-
processAnnotationDefault
private void processAnnotationDefault(java.io.DataInputStream data, MethodInfo target) throws java.io.IOException
- Throws:
java.io.IOException
-
processAnnotations
private void processAnnotations(java.io.DataInputStream data, AnnotationTarget target, boolean visible) throws java.io.IOException
- Throws:
java.io.IOException
-
processInnerClasses
private void processInnerClasses(java.io.DataInputStream data, ClassInfo target) throws java.io.IOException
- Throws:
java.io.IOException
-
processMethodParameters
private void processMethodParameters(java.io.DataInputStream data, MethodInfo target) throws java.io.IOException
- Throws:
java.io.IOException
-
processLocalVariableTable
private void processLocalVariableTable(java.io.DataInputStream data, MethodInfo target) throws java.io.IOException
- Throws:
java.io.IOException
-
processEnclosingMethod
private void processEnclosingMethod(java.io.DataInputStream data, ClassInfo target) throws java.io.IOException
- Throws:
java.io.IOException
-
processTypeAnnotations
private void processTypeAnnotations(java.io.DataInputStream data, AnnotationTarget target, boolean visible) throws java.io.IOException
- Throws:
java.io.IOException
-
processTypeAnnotation
private Indexer.TypeAnnotationState processTypeAnnotation(java.io.DataInputStream data, AnnotationTarget target, boolean visible) throws java.io.IOException
- Throws:
java.io.IOException
-
adjustMethodParameters
private void adjustMethodParameters()
-
isInnerConstructor
private boolean isInnerConstructor(MethodInfo method)
-
isEnumConstructor
private static boolean isEnumConstructor(MethodInfo method)
-
resolveTypeAnnotations
private void resolveTypeAnnotations()
-
resolveUsers
private void resolveUsers() throws java.io.IOException
- Throws:
java.io.IOException
-
recordUsedType
private void recordUsedType(Type type)
-
recordUsedClass
private void recordUsedClass(DotName usedClass)
-
updateTypeTargets
private void updateTypeTargets()
-
getTypeParameters
private static Type[] getTypeParameters(AnnotationTarget target)
-
copyTypeParameters
private static Type[] copyTypeParameters(AnnotationTarget target)
-
setTypeParameters
private static void setTypeParameters(AnnotationTarget target, Type[] typeParameters)
-
resolveTypeAnnotation
private void resolveTypeAnnotation(AnnotationTarget target, Indexer.TypeAnnotationState typeAnnotationState)
-
skipBridge
private boolean skipBridge(Indexer.TypeAnnotationState typeAnnotationState, MethodInfo method)
-
isBridge
private boolean isBridge(MethodInfo methodInfo)
-
targetsArray
private boolean targetsArray(Indexer.TypeAnnotationState typeAnnotationState)
-
resolveTypePath
private Type resolveTypePath(Type type, Indexer.TypeAnnotationState typeAnnotationState)
-
popNestedDepth
private int popNestedDepth(Indexer.PathElementStack elements)
-
updateTypeTarget
private void updateTypeTarget(AnnotationTarget enclosingTarget, Indexer.TypeAnnotationState typeAnnotationState)
-
searchTypePath
private Type searchTypePath(Type type, Indexer.TypeAnnotationState typeAnnotationState)
-
rebuildNestedType
private Type rebuildNestedType(Type last, java.util.ArrayDeque<Indexer.InnerClassInfo> classes, Type type, int depth, Indexer.TypeAnnotationState typeAnnotationState)
-
convertParameterized
private ParameterizedType convertParameterized(Type oType)
-
searchNestedType
private Type searchNestedType(Type type, int depth, Indexer.TypeAnnotationState typeAnnotationState)
-
hasAnonymousEncloser
private boolean hasAnonymousEncloser(Indexer.TypeAnnotationState typeAnnotationState)
-
hasLocalEncloser
private boolean hasLocalEncloser(Indexer.TypeAnnotationState typeAnnotationState)
-
outermostAnnotableTypeName
private DotName outermostAnnotableTypeName(Type type)
Returns the name of the outermost type that encloses giventype
and on which type annotations are admissible. This is either the nearest enclosingstatic
nested class, or the enclosing top-level class. Iftype
is not a nested type, returs its name.This could easily be implemented by calling
buildClassesQueue(Type)
and looking at the first element. The only difference is that the present implementation doesn't allocate and is probably a little faster.
-
buildClassesQueue
private java.util.ArrayDeque<Indexer.InnerClassInfo> buildClassesQueue(Type type)
Returns a list ofIndexer.InnerClassInfo
s representing types enclosing giventype
. Only types on which type annotations are admissible are present in the result. That is, the first element of the list represents the outermost type on which type annotations are admissible, and the last element of the list is anInnerClassInfo
representingtype
itself. Returns an empty list iftype
is not a nested type.
-
processTargetPath
private java.util.ArrayList<Indexer.PathElement> processTargetPath(java.io.DataInputStream data, Indexer.BooleanHolder genericsRequired, Indexer.BooleanHolder bridgeIncompatible) throws java.io.IOException
- Throws:
java.io.IOException
-
skipTargetPath
private void skipTargetPath(java.io.DataInputStream data) throws java.io.IOException
- Throws:
java.io.IOException
-
processExceptions
private void processExceptions(java.io.DataInputStream data, MethodInfo target) throws java.io.IOException
- Throws:
java.io.IOException
-
processSignature
private void processSignature(java.io.DataInputStream data, AnnotationTarget target) throws java.io.IOException
- Throws:
java.io.IOException
-
applySignatures
private void applySignatures()
-
parseClassSignature
private void parseClassSignature(java.lang.String signature, ClassInfo clazz)
-
parseFieldSignature
private void parseFieldSignature(java.lang.String signature, FieldInfo field)
-
parseMethodSignature
private void parseMethodSignature(java.lang.String signature, MethodInfo method)
-
parseRecordComponentSignature
private void parseRecordComponentSignature(java.lang.String signature, RecordComponentInfo recordComponent)
-
processAnnotation
private AnnotationInstance processAnnotation(java.io.DataInputStream data, AnnotationTarget target, boolean visible) throws java.io.IOException
- Throws:
java.io.IOException
-
recordAnnotation
private void recordAnnotation(java.util.Map<DotName,java.util.List<AnnotationInstance>> classAnnotations, DotName annotation, AnnotationInstance instance)
-
intern
private java.lang.String intern(java.lang.String string)
-
intern
private byte[] intern(byte[] bytes)
-
processAnnotationElementValue
private AnnotationValue processAnnotationElementValue(java.lang.String name, java.io.DataInputStream data) throws java.io.IOException
- Throws:
java.io.IOException
-
processClassInfo
private void processClassInfo(java.io.DataInputStream data) throws java.io.IOException
- Throws:
java.io.IOException
-
isJDK11OrNewer
private boolean isJDK11OrNewer(java.io.DataInputStream stream) throws java.io.IOException
- Throws:
java.io.IOException
-
verifyMagic
private void verifyMagic(java.io.DataInputStream stream) throws java.io.IOException
- Throws:
java.io.IOException
-
decodeClassEntry
private DotName decodeClassEntry(int index) throws java.io.IOException
- Throws:
java.io.IOException
-
decodeModuleEntry
private DotName decodeModuleEntry(int index) throws java.io.IOException
- Throws:
java.io.IOException
-
decodePackageEntry
private DotName decodePackageEntry(int index) throws java.io.IOException
- Throws:
java.io.IOException
-
decodeDotNameEntry
private DotName decodeDotNameEntry(int index, int constantType, java.lang.String typeName, char delim) throws java.io.IOException
- Throws:
java.io.IOException
-
decodeOptionalUtf8Entry
private java.lang.String decodeOptionalUtf8Entry(int index) throws java.io.IOException
- Throws:
java.io.IOException
-
decodeUtf8Entry
private java.lang.String decodeUtf8Entry(int index) throws java.io.IOException
- Throws:
java.io.IOException
-
decodeUtf8EntryAsBytes
private byte[] decodeUtf8EntryAsBytes(int index)
-
decodeNameAndTypeEntry
private Indexer.NameAndType decodeNameAndTypeEntry(int index) throws java.io.IOException
- Throws:
java.io.IOException
-
bitsToInt
private int bitsToInt(byte[] pool, int pos)
-
bitsToLong
private long bitsToLong(byte[] pool, int pos)
-
decodeIntegerEntry
private int decodeIntegerEntry(int index)
-
decodeLongEntry
private long decodeLongEntry(int index)
-
decodeFloatEntry
private float decodeFloatEntry(int index)
-
decodeDoubleEntry
private double decodeDoubleEntry(int index)
-
convertClassFieldDescriptor
private static java.lang.String convertClassFieldDescriptor(java.lang.String descriptor)
-
parseMethodArgs
private Type[] parseMethodArgs(java.lang.String descriptor, Indexer.IntegerHolder pos)
-
parseType
private Type parseType(java.lang.String descriptor)
-
parseType
private Type parseType(java.lang.String descriptor, Indexer.IntegerHolder pos)
-
processConstantPool
private boolean processConstantPool(java.io.DataInputStream stream) throws java.io.IOException
- Throws:
java.io.IOException
-
indexClass
public void indexClass(java.lang.Class<?> clazz) throws java.io.IOException
Analyze and index the class file data of givenclazz
. Each call adds information to the final complete index.- Parameters:
clazz
- a previously-loaded class- Throws:
java.io.IOException
- if the class file data is corrupt or the underlying stream failsjava.lang.IllegalArgumentException
- ifclazz
isnull
-
indexClass$$bridge
public ClassInfo indexClass$$bridge(java.lang.Class<?> clazz) throws java.io.IOException
- Throws:
java.io.IOException
-
index
public void index(java.io.InputStream stream) throws java.io.IOException
Analyze and index the class file data present in given inputstream
. Each call adds information to the final complete index. Closing the input stream is the caller's responsibility.- Parameters:
stream
- the class bytecode to index, must not benull
- Throws:
java.io.IOException
- if the class file data is corrupt or the stream failsjava.lang.IllegalArgumentException
- ifstream
isnull
-
index$$bridge
public ClassInfo index$$bridge(java.io.InputStream stream) throws java.io.IOException
- Throws:
java.io.IOException
-
indexWithSummary
public ClassSummary indexWithSummary(java.io.InputStream stream) throws java.io.IOException
Analyze and index the class file data present in given inputstream
. Each call adds information to the final complete index. Closing the input stream is the caller's responsibility.For reporting progress in batch indexers, this variant of
index
returns a summary of the just-indexed class.- Parameters:
stream
- the class bytecode to index, must not benull
- Returns:
- a summary of the just-indexed class
- Throws:
java.io.IOException
- if the class file data is corrupt or the stream failsjava.lang.IllegalArgumentException
- ifstream
isnull
-
complete
public Index complete()
Completes, finalizes, and returns the index after zero or more calls toindex()
. Future calls toindex()
will result in a new index.- Returns:
- the master index for all scanned class streams
-
propagateTypeParameterBounds
private void propagateTypeParameterBounds()
-
propagateTypeParameterBounds
private void propagateTypeParameterBounds(AnnotationTarget target, java.util.Deque<TypeVariable> sharedTypeVarStack)
-
propagateOneTypeParameterBound
private Type propagateOneTypeParameterBound(Type type, Type[] allTypeParams, AnnotationTarget target)
-
deepCopyTypeIfNeeded
private Type deepCopyTypeIfNeeded(Type type)
Whentype
contains no type variable references, returnstype
. Whentype
does contain type variable references, returns a deep copy with each reference replaced by a new one. In that case, the newly created references must be patched by the caller.When called from outside,
type
must be a type variable.
-
patchTypeVariableReferences
private void patchTypeVariableReferences(Type type, java.util.Deque<TypeVariable> typeVarStack, AnnotationTarget parametricEncloser)
Patches all type variable references contained in giventype
. ThetypeVarStack
is used to track enclosing type variables when traversing the structure of the type; when called from outside, it must be empty and must not be used anywhere else. TheparametricEncloser
is thetype
's nearest enclosing annotation target that may have type parameters, that is, the nearest enclosing method or class.
-
findTypeParameter
private TypeVariable findTypeParameter(Type[] typeParameters, java.lang.String identifier)
Finds and returns a type variable with givenidentifier
among giventypeParameters
. Returnsnull
when none exists.
-
resolveTypeParameter
private TypeVariable resolveTypeParameter(AnnotationTarget target, java.lang.String identifier)
Resolves a given type variableidentifier
against given parametrictarget
(either a method or a class). That is, if thetarget
has a type parameter with matching identifier, returns it; otherwise, resolvesidentifier
againsttarget
's nearest enclosing method or class. Returnsnull
if the identifier can't be resolved.
-
getTypeVariableIdentifier
private java.lang.String getTypeVariableIdentifier(Type typeVariable)
-
propagateTypeVariables
private void propagateTypeVariables()
-
propagateTypeVariables
private Type propagateTypeVariables(Type type, AnnotationTarget parametricEncloser)
-
retargetTypeAnnotations
private void retargetTypeAnnotations(AnnotationTarget parametricEncloser, Type oldType, Type newType)
-
-