Top Description Fields Constructors Methods
org.jboss.jandex

public final Class MethodInfo

extends Object
implements Declaration, Descriptor, GenericSignature
Class Inheritance
All Implemented Interfaces
org.jboss.jandex.GenericSignature, org.jboss.jandex.Descriptor, org.jboss.jandex.Declaration, org.jboss.jandex.AnnotationTarget
Imports
java.io.UnsupportedEncodingException, java.lang.reflect.Modifier, java.util.ArrayList, .Arrays, .Collections, .List, java.util.function.Function

Represents a Java method, constructor, or static initializer.

Jandex makes reasonable attempts to not include implicitly declared (aka mandated) and synthetic parameters in parameters(), parameterTypes(), parameterName(int), parameterType(int) and parametersCount(). However, descriptorParameterTypes() and descriptorParametersCount() may be used to obtain information about all parameters, including mandated and synthetic.

As an exception to the rule above, in case of well known methods where no parameter is declared explicitly, the implicitly declared parameters are included. This currently applies to the implicitly declared parameters of:

Thread-Safety

This class is immutable and can be shared between threads without safe publication.
Author
Jason T. Greene

Field Summary

Modifier and TypeField and Description
private ClassInfo
pack-priv static final String[]
private MethodInternal

Constructor Summary

AccessConstructor and Description
pack-priv
pack-priv
MethodInfo(ClassInfo clazz, MethodInternal methodInternal)

pack-priv
MethodInfo(ClassInfo clazz, byte[] name, byte[][] parameterNames, Type[] parameterTypes, Type returnType, short flags)

pack-priv
MethodInfo(ClassInfo clazz, byte[] name, byte[][] parameterNames, Type[] parameterTypes, Type returnType, short flags, Type[] typeParameters, Type[] exceptions)

Method Summary

Modifier and TypeMethod and Description
public final AnnotationInstance

Returns:

the annotation instance, or null if not found
annotation
(DotName
name of the annotation type to look for, must not be null
name
)

Implements org.jboss.jandex.AnnotationTarget.annotation.

Returns the annotation instance with given name declared on this method, any of its parameters or any type within its signature.
public final List<AnnotationInstance>

Returns:

immutable list of annotation instances, never null
annotations
(DotName
name of the annotation type, must not be null
name
)

Implements org.jboss.jandex.AnnotationTarget.annotations.

Returns the annotation instances with given name declared on this method, any of its parameters or any type within its signature.
public final List<AnnotationInstance>

Returns:

immutable list of annotation instances, never null
annotations
()

Implements org.jboss.jandex.AnnotationTarget.annotations.

Returns the annotation instances declared on this method, any of its parameters or any type within its signature.
public final List<AnnotationInstance>

Returns:

immutable list of annotation instances, never null
annotationsWithRepeatable
(DotName
name of the annotation type, must not be null
name
,
IndexView
index used to obtain the annotation type, must not be null
index
)

Implements org.jboss.jandex.AnnotationTarget.annotationsWithRepeatable.

Returns the annotation instances with given name declared on this method, any of its parameters or any type within its signature.
public final Type[]

Returns:

an array copy contain parameter types
args
()

Deprecated use parameterTypes()
Returns an array of parameter types in declaration order.
public final ClassInfo
asClass()

Implements org.jboss.jandex.AnnotationTarget.asClass.

Casts and returns this target as a ClassInfo if it is of kind CLASS
public final FieldInfo
asField()

Implements org.jboss.jandex.AnnotationTarget.asField.

Casts and returns this target as a FieldInfo if it is of kind FIELD
public final MethodInfo
asMethod()

Implements org.jboss.jandex.AnnotationTarget.asMethod.

Casts and returns this target as a MethodInfo if it is of kind METHOD
public final MethodParameterInfo
asMethodParameter()

Implements org.jboss.jandex.AnnotationTarget.asMethodParameter.

Casts and returns this target as a MethodParameterInfo if it is of kind METHOD_PARAMETER
public final RecordComponentInfo
asRecordComponent()

Implements org.jboss.jandex.AnnotationTarget.asRecordComponent.

Casts and returns this target as a RecordComponentInfo if it is of kind RECORD_COMPONENT
public final TypeTarget
asType()

Implements org.jboss.jandex.AnnotationTarget.asType.

Casts and returns this target as a TypeTarget if it is of kind TYPE
pack-priv final Type[]
pack-priv final Type[]
public static MethodInfo

Returns:

a mock method
create
(ClassInfo
the class declaring the field
clazz
,
String
the name of the field
name
,
Type[]
a read only array containing the types of each parameter in parameter order
parameterTypes
,
Type
the return value type
returnType
,
short
the method attributes
flags
)

Construct a new mock Method instance.

public static MethodInfo

Returns:

a mock method
create
(ClassInfo
the class declaring the field
clazz
,
String
the name of the field
name
,
Type[]
a read only array containing the types of each parameter in parameter order
parameterTypes
,
Type
the return value type
returnType
,
short
the method attributes
flags
,
TypeVariable[]
the generic type parameters for this method
typeParameters
,
Type[]
the exceptions declared as thrown by this method
exceptions
)

Construct a new mock Method instance.

public static MethodInfo

Returns:

a mock method
create
(ClassInfo
the class declaring the field
clazz
,
String
the name of the field
name
,
String[]
the names of the method parameter
parameterNames
,
Type[]
a read only array containing the types of each parameter in parameter order
parameterTypes
,
Type
the return value type
returnType
,
short
the method attributes
flags
,
TypeVariable[]
the generic type parameters for this method
typeParameters
,
Type[]
the exceptions declared as thrown by this method
exceptions
)

Construct a new mock Method instance.

public AnnotationInstance

Returns:

the annotation instance, or null if not found
declaredAnnotation
(DotName
name of the annotation type to look for, must not be null
name
)

Implements org.jboss.jandex.AnnotationTarget.declaredAnnotation.

Returns the annotation instance with given name declared on this method.
public List<AnnotationInstance>

Returns:

immutable list of annotation instances, never null
declaredAnnotations
()

Implements org.jboss.jandex.AnnotationTarget.declaredAnnotations.

Returns the annotation instances declared on this method.
public List<AnnotationInstance>

Returns:

immutable list of annotation instances, never null
declaredAnnotationsWithRepeatable
(DotName
name of the annotation type, must not be null
name
,
IndexView
index used to obtain the annotation type, must not be null
index
)

Implements org.jboss.jandex.AnnotationTarget.declaredAnnotationsWithRepeatable.

Returns the annotation instances with given name declared on this method.
public final ClassInfo

Returns:

the declaring class
declaringClass
()

Returns the class that declared this method

public AnnotationValue

Returns:

default annotation value if available, otherwise null
defaultValue
()

Returns the default annotation value if this method represents an annotation member with a default value.

public String

Returns:

the bytecode descriptor of this method
descriptor
(Function<String, Type>
a substitution function from type variable identifiers to types
typeVariableSubstitution
)

Implements org.jboss.jandex.Descriptor.descriptor.

Returns a bytecode descriptor of this method.
public final int

Returns:

the number of all parameters present on this method
descriptorParametersCount
()

Returns the number of all parameters present on this method, based on the method descriptor.

public final List<Type>
descriptorParameterTypes()

Returns a list of types of all parameters present on this method, based on the method descriptor.

public boolean
equals(Object
the reference object with which to compare.
o
)

Overrides java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.
public final List<Type>

Returns:

immutable list of throwable classes thrown by this method
exceptions
()

Returns the list of throwable classes declared to be thrown by this method.

public final short

Returns:

the access flags of this method
flags
()

Returns the access fields of this method.

public String

Returns:

a generic signature of this method with type variables substituted, never null
genericSignature
(Function<String, Type>
a substitution function from type variable identifiers to types
typeVariableSubstitution
)

Implements org.jboss.jandex.GenericSignature.genericSignature.

Returns a generic signature of this method, possibly without any generic-related information.
public final boolean

Returns:

true if the annotation is present, false otherwise
hasAnnotation
(DotName
name of the annotation type to look for, must not be null
name
)

Implements org.jboss.jandex.AnnotationTarget.hasAnnotation.

Returns whether an annotation instance with given name is declared on this method, its parameters or any type within its signature.
public boolean

Returns:

true if the annotation is present, false otherwise
hasDeclaredAnnotation
(DotName
name of the annotation type to look for, must not be null
name
)

Implements org.jboss.jandex.AnnotationTarget.hasDeclaredAnnotation.

Returns whether an annotation instance with given name is declared on this method.
public int
hashCode()

Overrides java.lang.Object.hashCode.

Returns a hash code value for the object.
public boolean

Returns:

true if this method is a bridge method as defined by the JLS, false otherwise
isBridge
()

public boolean

Returns:

true if this method is a constructor
isConstructor
()

public boolean

Returns:

true if this method is a default interface method, false otherwise
isDefault
()

A default method is a public non-abstract non-static method declared in an interface.

public boolean

Returns:

true if this method is a static initializer
isStaticInitializer
()

public boolean

Returns:

true if this method is a synthetic method
isSynthetic
()

public final AnnotationTarget.Kind
kind()

Implements org.jboss.jandex.AnnotationTarget.kind.

Returns the kind of object this target represents.
pack-priv final MethodInternal
public final String

Returns:

the name of the method
name
()

Returns the name of this method

public final String

Returns:

the name of the given parameter, or null if not known
parameterName
(int
the parameter index, zero-based
i
)

Returns the name of the given parameter.

public final List<MethodParameterInfo>

Returns:

immutable list of parameter types of this method, never null
parameters
()

Returns a list of parameters declared on this method, in declaration order.

public final int

Returns:

the number of parameters this method declares
parametersCount
()

Returns the number of parameters this method declares.

public final Type

Returns:

the type of the given parameter
parameterType
(int
the parameter index, zero-based
i
)

Returns the type of the given parameter.

public final List<Type>

Returns:

immutable list of parameter types of this method, never null
parameterTypes
()

Returns a list of types of parameters declared on this method, in declaration order.

public final Type

Returns:

the receiver type of this method
receiverType
()

Returns the receiver type of this method (a declaration of the "this" reference), if specified.

public boolean

Returns:

whether this method must have a generic signature
requiresGenericSignature
()

Implements org.jboss.jandex.GenericSignature.requiresGenericSignature.

Returns whether this method must have a generic signature.
public final Type

Returns:

the type of this method's return value
returnType
()

Returns this method's return parameter type.

pack-priv void
pack-priv final void
pack-priv void
pack-priv void
setExceptions(Type[] exceptions)

pack-priv final void
pack-priv void
setParameters(Type[] parameters)

pack-priv void
setReceiverType(Type receiverType)

pack-priv void
setReturnType(Type returnType)

pack-priv void
setTypeParameters(Type[] typeParameters)

public String

Returns:

a string representation of this method
toString
()

Overrides java.lang.Object.toString.

Returns a string representation describing this method.
pack-priv final Type[]
public final List<TypeVariable>

Returns:

immutable list of generic type parameters for this method, or an empty list if none
typeParameters
()

Returns the generic type parameters defined by this method.

Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAllwaitwaitwait

Field Detail

clazzback to summary
private ClassInfo clazz
EMPTY_PARAMETER_NAMESback to summary
pack-priv static final String[] EMPTY_PARAMETER_NAMES
methodInternalback to summary
private MethodInternal methodInternal

Constructor Detail

MethodInfoback to summary
pack-priv MethodInfo()
MethodInfoback to summary
pack-priv MethodInfo(ClassInfo clazz, MethodInternal methodInternal)
MethodInfoback to summary
pack-priv MethodInfo(ClassInfo clazz, byte[] name, byte[][] parameterNames, Type[] parameterTypes, Type returnType, short flags)
MethodInfoback to summary
pack-priv MethodInfo(ClassInfo clazz, byte[] name, byte[][] parameterNames, Type[] parameterTypes, Type returnType, short flags, Type[] typeParameters, Type[] exceptions)

Method Detail

annotationback to summary
public final AnnotationInstance annotation(DotName name)

Implements org.jboss.jandex.AnnotationTarget.annotation.

Returns the annotation instance with given name declared on this method, any of its parameters or any type within its signature. The target() method of the returned annotation instance may be used to determine the exact location of the annotation instance.

The following is a non-exhaustive list of examples of annotations returned by this method:

@MyMethodAnnotation
public void foo() {...}

public void foo(@MyParamAnnotation int param) {...}

public void foo(List<@MyTypeAnnotation String> list) {...}

public <@MyTypeAnnotation T> void foo(T t) {...}

In case an annotation with given name occurs more than once, the result of this method is not deterministic. For such situations, annotations(DotName) is preferable.

Parameters
name:DotName

name of the annotation type to look for, must not be null

Returns:AnnotationInstance

the annotation instance, or null if not found

Since
3.0
See Also
annotations(DotName)
annotationsback to summary
public final List<AnnotationInstance> annotations(DotName name)

Implements org.jboss.jandex.AnnotationTarget.annotations.

Returns the annotation instances with given name declared on this method, any of its parameters or any type within its signature. The target() method of the returned annotation instances may be used to determine the exact location of the respective annotation instance.

The following is a non-exhaustive list of examples of annotations returned by this method:

@MyMethodAnnotation
public void foo() {...}

public void foo(@MyParamAnnotation int param) {...}

public void foo(List<@MyTypeAnnotation String> list) {...}

public <@MyTypeAnnotation T> void foo(T t) {...}
Parameters
name:DotName

name of the annotation type, must not be null

Returns:List<AnnotationInstance>

immutable list of annotation instances, never null

See Also
annotationsWithRepeatable(DotName, IndexView), annotations()
annotationsback to summary
public final List<AnnotationInstance> annotations()

Implements org.jboss.jandex.AnnotationTarget.annotations.

Returns the annotation instances declared on this method, any of its parameters or any type within its signature. The target() method of the returned annotation instances may be used to determine the exact location of the respective annotation instance.

The following is a non-exhaustive list of examples of annotations returned by this method:

@MyMethodAnnotation
public void foo() {...}

public void foo(@MyParamAnnotation int param) {...}

public void foo(List<@MyTypeAnnotation String> list) {...}

public <@AnotherTypeAnnotation T> void foo(T t) {...}
Returns:List<AnnotationInstance>

immutable list of annotation instances, never null

annotationsWithRepeatableback to summary
public final List<AnnotationInstance> annotationsWithRepeatable(DotName name, IndexView index)

Implements org.jboss.jandex.AnnotationTarget.annotationsWithRepeatable.

Returns the annotation instances with given name declared on this method, any of its parameters or any type within its signature. The target() method of the returned annotation instances may be used to determine the exact location of the respective annotation instance.

If the specified annotation is repeatable, the result also contains all values from the container annotation instance. In this case, the AnnotationInstance#target() returns the target of the container annotation instance.

Parameters
name:DotName

name of the annotation type, must not be null

index:IndexView

index used to obtain the annotation type, must not be null

Returns:List<AnnotationInstance>

immutable list of annotation instances, never null

Exceptions
IllegalArgumentException:
if the index is null, if the index does not contain the annotation type or if name does not identify an annotation type
See Also
annotations(DotName), annotations()
argsback to summary
public final Type[] args()

Deprecated

use parameterTypes()

Returns an array of parameter types in declaration order. Jandex makes reasonable attempts to not include implicitly declared (aka mandated) and synthetic parameters.

This method performs a defensive array copy per call, and should be avoided. Instead, the parameterTypes() method should be used.

Returns:Type[]

an array copy contain parameter types

Annotations
@Deprecated
asClassback to summary
public final ClassInfo asClass()

Implements org.jboss.jandex.AnnotationTarget.asClass.

Doc from org.jboss.jandex.AnnotationTarget.asClass.

Casts and returns this target as a ClassInfo if it is of kind CLASS

Returns:ClassInfo

this instance cast to a class

Annotations
@Override
asFieldback to summary
public final FieldInfo asField()

Implements org.jboss.jandex.AnnotationTarget.asField.

Doc from org.jboss.jandex.AnnotationTarget.asField.

Casts and returns this target as a FieldInfo if it is of kind FIELD

Returns:FieldInfo

this instance cast to a field

Annotations
@Override
asMethodback to summary
public final MethodInfo asMethod()

Implements org.jboss.jandex.AnnotationTarget.asMethod.

Doc from org.jboss.jandex.AnnotationTarget.asMethod.

Casts and returns this target as a MethodInfo if it is of kind METHOD

Returns:MethodInfo

this instance cast to a method

Annotations
@Override
asMethodParameterback to summary
public final MethodParameterInfo asMethodParameter()

Implements org.jboss.jandex.AnnotationTarget.asMethodParameter.

Doc from org.jboss.jandex.AnnotationTarget.asMethodParameter.

Casts and returns this target as a MethodParameterInfo if it is of kind METHOD_PARAMETER

Returns:MethodParameterInfo

this instance cast to a method parameter

Annotations
@Override
asRecordComponentback to summary
public final RecordComponentInfo asRecordComponent()

Implements org.jboss.jandex.AnnotationTarget.asRecordComponent.

Doc from org.jboss.jandex.AnnotationTarget.asRecordComponent.

Casts and returns this target as a RecordComponentInfo if it is of kind RECORD_COMPONENT

Returns:RecordComponentInfo

this instance cast to a record component

Annotations
@Override
asTypeback to summary
public final TypeTarget asType()

Implements org.jboss.jandex.AnnotationTarget.asType.

Doc from org.jboss.jandex.AnnotationTarget.asType.

Casts and returns this target as a TypeTarget if it is of kind TYPE

Returns:TypeTarget

this instance cast to a type target

Annotations
@Override
copyExceptionsback to summary
pack-priv final Type[] copyExceptions()
copyParametersback to summary
pack-priv final Type[] copyParameters()
createback to summary
public static MethodInfo create(ClassInfo clazz, String name, Type[] parameterTypes, Type returnType, short flags)

Construct a new mock Method instance.

Parameters
clazz:ClassInfo

the class declaring the field

name:String

the name of the field

parameterTypes:Type[]

a read only array containing the types of each parameter in parameter order

returnType:Type

the return value type

flags:short

the method attributes

Returns:MethodInfo

a mock method

createback to summary
public static MethodInfo create(ClassInfo clazz, String name, Type[] parameterTypes, Type returnType, short flags, TypeVariable[] typeParameters, Type[] exceptions)

Construct a new mock Method instance.

Parameters
clazz:ClassInfo

the class declaring the field

name:String

the name of the field

parameterTypes:Type[]

a read only array containing the types of each parameter in parameter order

returnType:Type

the return value type

flags:short

the method attributes

typeParameters:TypeVariable[]

the generic type parameters for this method

exceptions:Type[]

the exceptions declared as thrown by this method

Returns:MethodInfo

a mock method

Since
2.1
createback to summary
public static MethodInfo create(ClassInfo clazz, String name, String[] parameterNames, Type[] parameterTypes, Type returnType, short flags, TypeVariable[] typeParameters, Type[] exceptions)

Construct a new mock Method instance.

Parameters
clazz:ClassInfo

the class declaring the field

name:String

the name of the field

parameterNames:String[]

the names of the method parameter

parameterTypes:Type[]

a read only array containing the types of each parameter in parameter order

returnType:Type

the return value type

flags:short

the method attributes

typeParameters:TypeVariable[]

the generic type parameters for this method

exceptions:Type[]

the exceptions declared as thrown by this method

Returns:MethodInfo

a mock method

Since
2.2
declaredAnnotationback to summary
public AnnotationInstance declaredAnnotation(DotName name)

Implements org.jboss.jandex.AnnotationTarget.declaredAnnotation.

Returns the annotation instance with given name declared on this method.

Unlike annotation(DotName), this method doesn't return annotations declared on the method parameters and types within the method signature.

Parameters
name:DotName

name of the annotation type to look for, must not be null

Returns:AnnotationInstance

the annotation instance, or null if not found

Annotations
@Override
Since
3.0
See Also
annotation(DotName)
declaredAnnotationsback to summary
public List<AnnotationInstance> declaredAnnotations()

Implements org.jboss.jandex.AnnotationTarget.declaredAnnotations.

Returns the annotation instances declared on this method.

Unlike annotations(), this method doesn't return annotations declared on the method parameters and types within the method signature.

Returns:List<AnnotationInstance>

immutable list of annotation instances, never null

Annotations
@Override
Since
3.0
See Also
annotations()
declaredAnnotationsWithRepeatableback to summary
public List<AnnotationInstance> declaredAnnotationsWithRepeatable(DotName name, IndexView index)

Implements org.jboss.jandex.AnnotationTarget.declaredAnnotationsWithRepeatable.

Returns the annotation instances with given name declared on this method.

If the specified annotation is repeatable, the result also contains all values from the container annotation instance. In this case, the AnnotationInstance#target() returns the target of the container annotation instance.

Unlike annotationsWithRepeatable(DotName, IndexView), this method doesn't return annotations declared on the method parameters and types within the method signature.

Parameters
name:DotName

name of the annotation type, must not be null

index:IndexView

index used to obtain the annotation type, must not be null

Returns:List<AnnotationInstance>

immutable list of annotation instances, never null

Annotations
@Override
Exceptions
IllegalArgumentException:
if the index is null, if the index does not contain the annotation type or if name does not identify an annotation type
Since
3.0
See Also
annotationsWithRepeatable(DotName, IndexView)
declaringClassback to summary
public final ClassInfo declaringClass()

Returns the class that declared this method

Returns:ClassInfo

the declaring class

defaultValueback to summary
public AnnotationValue defaultValue()

Returns the default annotation value if this method represents an annotation member with a default value. Otherwise null is returned

Returns:AnnotationValue

default annotation value if available, otherwise null

Since
2.1
descriptorback to summary
public String descriptor(Function<String, Type> typeVariableSubstitution)

Implements org.jboss.jandex.Descriptor.descriptor.

Returns a bytecode descriptor of this method.

Descriptors of type variables are substituted for descriptors of types provided by the substitution function typeVariableSubstitution. If the substitution function returns null for some type variable identifier, or if it returns the type variable itself, no substitution happens and the type variable descriptor is used unmodified.

Note that the return value does not come directly from bytecode. Jandex does not store the descriptor strings. Instead, the return value is reconstructed from the Jandex object model.

Parameters
typeVariableSubstitution:Function<String, Type>

Doc from org.jboss.jandex.Descriptor.descriptor.

a substitution function from type variable identifiers to types

Returns:String

the bytecode descriptor of this method

descriptorParametersCountback to summary
public final int descriptorParametersCount()

Returns the number of all parameters present on this method, based on the method descriptor. This always includes implicitly declared (aka mandated) and synthetic parameters.

Returns:int

the number of all parameters present on this method

descriptorParameterTypesback to summary
public final List<Type> descriptorParameterTypes()

Returns a list of types of all parameters present on this method, based on the method descriptor. This always includes implicitly declared (aka mandated) and synthetic parameters. These types are never annotated and their position in the list cannot be used to retrieve a name using parameterName(int) or look for annotations.

equalsback to summary
public boolean equals(Object o)

Overrides java.lang.Object.equals.

Doc from java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

The equals method implements an equivalence relation on non-null object references:

  • It is reflexive: for any non-null reference value x, x.equals(x) should return true.
  • It is symmetric: for any non-null reference values x and y, x.equals(y) should return true if and only if y.equals(x) returns true.
  • It is transitive: for any non-null reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true.
  • It is consistent: for any non-null reference values x and y, multiple invocations of x.equals(y) consistently return true or consistently return false, provided no information used in equals comparisons on the objects is modified.
  • For any non-null reference value x, x.equals(null) should return false.

An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes.

Parameters
o:Object

the reference object with which to compare.

Returns:boolean

true if this object is the same as the obj argument; false otherwise.

Annotations
@Override
exceptionsback to summary
public final List<Type> exceptions()

Returns the list of throwable classes declared to be thrown by this method. This method may return an empty list, but never null.

Returns:List<Type>

immutable list of throwable classes thrown by this method

flagsback to summary
public final short flags()

Returns the access fields of this method. Modifier can be used on this value.

Returns:short

the access flags of this method

genericSignatureback to summary
public String genericSignature(Function<String, Type> typeVariableSubstitution)

Implements org.jboss.jandex.GenericSignature.genericSignature.

Returns a generic signature of this method, possibly without any generic-related information. That is, produces a correct generic signature even if this method is not generic and does not use any type variables.

Signatures of type variables are substituted for signatures of types provided by the substitution function typeVariableSubstitution. If the substitution function returns null for some type variable identifier, no substitution happens and the type variable signature is used unmodified.

Note that the return value does not come directly from bytecode. Jandex does not store the signature strings. Instead, the return value is reconstructed from the Jandex object model.

Parameters
typeVariableSubstitution:Function<String, Type>

a substitution function from type variable identifiers to types

Returns:String

a generic signature of this method with type variables substituted, never null

Annotations
@Override
hasAnnotationback to summary
public final boolean hasAnnotation(DotName name)

Implements org.jboss.jandex.AnnotationTarget.hasAnnotation.

Returns whether an annotation instance with given name is declared on this method, its parameters or any type within its signature.

Parameters
name:DotName

name of the annotation type to look for, must not be null

Returns:boolean

true if the annotation is present, false otherwise

See Also
annotation(DotName)
hasDeclaredAnnotationback to summary
public boolean hasDeclaredAnnotation(DotName name)

Implements org.jboss.jandex.AnnotationTarget.hasDeclaredAnnotation.

Returns whether an annotation instance with given name is declared on this method.

Unlike hasAnnotation(DotName), this method ignores annotations declared on the method parameters and types within the method signature.

Parameters
name:DotName

name of the annotation type to look for, must not be null

Returns:boolean

true if the annotation is present, false otherwise

Annotations
@Override
Since
3.0
See Also
hasAnnotation(DotName)
hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Doc from java.lang.Object.hashCode.

Returns a hash code value for the object. This method is supported for the benefit of hash tables such as those provided by java.util.HashMap.

The general contract of hashCode is:

  • Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.
  • If two objects are equal according to the equals method, then calling the hashCode method on each of the two objects must produce the same integer result.
  • It is not required that if two objects are unequal according to the equals method, then calling the hashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hash tables.
Returns:int

a hash code value for this object.

Annotations
@Override
isBridgeback to summary
public boolean isBridge()
Returns:boolean

true if this method is a bridge method as defined by the JLS, false otherwise

isConstructorback to summary
public boolean isConstructor()
Returns:boolean

true if this method is a constructor

isDefaultback to summary
public boolean isDefault()

A default method is a public non-abstract non-static method declared in an interface.

Returns:boolean

true if this method is a default interface method, false otherwise

isStaticInitializerback to summary
public boolean isStaticInitializer()
Returns:boolean

true if this method is a static initializer

isSyntheticback to summary
public boolean isSynthetic()
Returns:boolean

true if this method is a synthetic method

kindback to summary
public final AnnotationTarget.Kind kind()

Implements org.jboss.jandex.AnnotationTarget.kind.

Doc from org.jboss.jandex.AnnotationTarget.kind.

Returns the kind of object this target represents.

Returns:AnnotationTarget.Kind

the target kind.

methodInternalback to summary
pack-priv final MethodInternal methodInternal()
nameback to summary
public final String name()

Returns the name of this method

Returns:String

the name of the method

parameterNameback to summary
public final String parameterName(int i)

Returns the name of the given parameter.

Parameters
i:int

the parameter index, zero-based

Returns:String

the name of the given parameter, or null if not known

parametersback to summary
public final List<MethodParameterInfo> parameters()

Returns a list of parameters declared on this method, in declaration order. Jandex makes reasonable attempts to not include implicitly declared (aka mandated) and synthetic parameters.

Returns:List<MethodParameterInfo>

immutable list of parameter types of this method, never null

parametersCountback to summary
public final int parametersCount()

Returns the number of parameters this method declares. Jandex makes reasonable attempts to not count implicitly declared (aka mandated) and synthetic parameters.

Returns:int

the number of parameters this method declares

parameterTypeback to summary
public final Type parameterType(int i)

Returns the type of the given parameter.

Parameters
i:int

the parameter index, zero-based

Returns:Type

the type of the given parameter

parameterTypesback to summary
public final List<Type> parameterTypes()

Returns a list of types of parameters declared on this method, in declaration order. Jandex makes reasonable attempts to not include implicitly declared (aka mandated) and synthetic parameters. Positions of types in this list may be used to retrieve a name using parameterName(int) or look for annotations.

Returns:List<Type>

immutable list of parameter types of this method, never null

receiverTypeback to summary
public final Type receiverType()

Returns the receiver type of this method (a declaration of the "this" reference), if specified. This is used to convey annotations on the "this" instance.

Returns:Type

the receiver type of this method

requiresGenericSignatureback to summary
public boolean requiresGenericSignature()

Implements org.jboss.jandex.GenericSignature.requiresGenericSignature.

Returns whether this method must have a generic signature. That is, whether the Java compiler when compiling this method had to emit the Signature bytecode attribute.

Returns:boolean

whether this method must have a generic signature

Annotations
@Override
returnTypeback to summary
public final Type returnType()

Returns this method's return parameter type. If this method has a void return, a special void type is returned. This method will never return null.

Returns:Type

the type of this method's return value

setAnnotationsback to summary
pack-priv void setAnnotations(List<AnnotationInstance> annotations)
setClassInfoback to summary
pack-priv final void setClassInfo(ClassInfo clazz)
setDefaultValueback to summary
pack-priv void setDefaultValue(AnnotationValue defaultValue)
setExceptionsback to summary
pack-priv void setExceptions(Type[] exceptions)
setMethodInternalback to summary
pack-priv final void setMethodInternal(MethodInternal methodInternal)
setParametersback to summary
pack-priv void setParameters(Type[] parameters)
setReceiverTypeback to summary
pack-priv void setReceiverType(Type receiverType)
setReturnTypeback to summary
pack-priv void setReturnType(Type returnType)
setTypeParametersback to summary
pack-priv void setTypeParameters(Type[] typeParameters)
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Returns a string representation describing this method. It is similar although not necessarily identical to a Java source code declaration of this method.

Returns:String

a string representation of this method

typeParameterArrayback to summary
pack-priv final Type[] typeParameterArray()
typeParametersback to summary
public final List<TypeVariable> typeParameters()

Returns the generic type parameters defined by this method. This list will contain resolved type variables which may reference other type parameters, including those declared by the enclosing class of this method.

Returns:List<TypeVariable>

immutable list of generic type parameters for this method, or an empty list if none