APIdia Launch Partner
Top Description Fields Constructors Methods
java.lang.reflect

public final Class Parameter

extends Object
implements AnnotatedElement
Class Inheritance
All Implemented Interfaces
java.lang.reflect.AnnotatedElement
Imports
java.lang.annotation.*, java.util.HashMap, .Map, .Set, .Objects, sun.reflect.annotation.AnnotationSupport

Information about method parameters. A Parameter provides information about method parameters, including its name and modifiers. It also provides an alternate means of obtaining attributes for the parameter.
Since
1.8

Field Summary

Modifier and TypeField and Description
private transient Map<Class<? extends Annotation>, Annotation>
private final Executable
private final int
private final int
private final String
private transient volatile Class<?>
private transient volatile Type

Constructor Summary

AccessConstructor and Description
pack-priv
Parameter(String
The name of the parameter, or null if absent
name
,
int
The modifier flags for the parameter.
modifiers
,
Executable
The executable which defines this parameter.
executable
,
int
The index of the parameter.
index
)

Package-private constructor for Parameter.

Method Summary

Modifier and TypeMethod and Description
public Set<AccessFlag>

Returns:

an unmodifiable set of the access flags for the parameter represented by this object, possibly empty
accessFlags
()

Returns an unmodifiable set of the access flags for the parameter represented by this object, possibly empty.

private synchronized Map<Class<? extends Annotation>, Annotation>
public boolean

Returns:

Whether or not this is equal to the argument.
equals
(Object
The object to compare.
obj
)

Overrides java.lang.Object.equals.

Compares based on the executable and the index.

public AnnotatedType

Returns:

an AnnotatedType object representing the use of a type to specify the type of the formal parameter represented by this Parameter
getAnnotatedType
()

Returns an AnnotatedType object that represents the use of a type to specify the type of the formal parameter represented by this Parameter.

public <T extends Annotation> T
getAnnotation(Class<T> annotationClass)

Implements java.lang.reflect.AnnotatedElement.getAnnotation.

Returns this element's annotation for the specified type if such an annotation is present, else null.

public Annotation[]
getAnnotations()

Implements java.lang.reflect.AnnotatedElement.getAnnotations.

Returns annotations that are present on this element.

public <T extends Annotation> T[]
getAnnotationsByType(Class<T> annotationClass)

Overrides default java.lang.reflect.AnnotatedElement.getAnnotationsByType.

Returns annotations that are associated with this element.

public <T extends Annotation> T
getDeclaredAnnotation(Class<T> annotationClass)

Overrides default java.lang.reflect.AnnotatedElement.getDeclaredAnnotation.

Returns this element's annotation for the specified type if such an annotation is directly present, else null.

public Annotation[]
getDeclaredAnnotations()

Implements java.lang.reflect.AnnotatedElement.getDeclaredAnnotations.

Returns annotations that are directly present on this element.

public <T extends Annotation> T[]
getDeclaredAnnotationsByType(Class<T> annotationClass)

Overrides default java.lang.reflect.AnnotatedElement.getDeclaredAnnotationsByType.

Returns this element's annotation(s) for the specified type if such annotations are either directly present or indirectly present.

public Executable

Returns:

the Executable declaring this parameter
getDeclaringExecutable
()

Returns the Executable declaring this parameter.

public int

Returns:

the Java language modifiers for the parameter represented by this object
getModifiers
()

Returns the Java language modifiers for the parameter represented by this object.

public String

Returns:

The name of the parameter, either provided by the class file or synthesized if the class file does not provide a name.
getName
()

Returns the name of the parameter.

public Type

Returns:

a Type object identifying the parameterized type of the parameter represented by this object
getParameterizedType
()

Returns a Type object that identifies the parameterized type for the parameter represented by this Parameter object.

pack-priv String
public Class<?>

Returns:

a Class object identifying the declared type of the parameter represented by this object
getType
()

Returns a Class object that identifies the declared type for the parameter represented by this Parameter object.

public int

Returns:

A hash code based on the executable's hash code.
hashCode
()

Overrides java.lang.Object.hashCode.

Returns a hash code based on the executable's hash code and the index.

public boolean

Returns:

true if and only if this parameter is implicitly declared as defined by The Java Language Specification.
isImplicit
()

Returns true if this parameter is implicitly declared in source code; returns false otherwise.

public boolean

Returns:

true if and only if the parameter has a name according to the class file.
isNamePresent
()

Returns true if the parameter has a name according to the class file; returns false otherwise.

public boolean

Returns:

true if and only if this parameter is a synthetic construct as defined by The Java Language Specification.
isSynthetic
()

Returns true if this parameter is neither implicitly nor explicitly declared in source code; returns false otherwise.

public boolean

Returns:

true if an only if this parameter represents a variable argument list.
isVarArgs
()

Returns true if this parameter represents a variable argument list; returns false otherwise.

public String

Returns:

A string representation of the parameter and associated information.
toString
()

Overrides java.lang.Object.toString.

Returns a string describing this parameter.

Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAllwaitwaitwait

Field Detail

declaredAnnotationsback to summary
private transient Map<Class<? extends Annotation>, Annotation> declaredAnnotations
executableback to summary
private final Executable executable
indexback to summary
private final int index
modifiersback to summary
private final int modifiers
nameback to summary
private final String name
parameterClassCacheback to summary
private transient volatile Class<?> parameterClassCache
parameterTypeCacheback to summary
private transient volatile Type parameterTypeCache

Constructor Detail

Parameterback to summary
pack-priv Parameter(String name, int modifiers, Executable executable, int index)

Package-private constructor for Parameter. If method parameter data is present in the classfile, then the JVM creates Parameter objects directly. If it is absent, however, then Executable uses this constructor to synthesize them.

Parameters
name:String

The name of the parameter, or null if absent

modifiers:int

The modifier flags for the parameter.

executable:Executable

The executable which defines this parameter.

index:int

The index of the parameter.

Method Detail

accessFlagsback to summary
public Set<AccessFlag> accessFlags()

Returns an unmodifiable set of the access flags for the parameter represented by this object, possibly empty.

Returns:Set<AccessFlag>

an unmodifiable set of the access flags for the parameter represented by this object, possibly empty

Since
20
Java Virtual Machine Specification
4.7.24 The MethodParameters Attribute
See Also
getModifiers()
declaredAnnotationsback to summary
private synchronized Map<Class<? extends Annotation>, Annotation> declaredAnnotations()
equalsback to summary
public boolean equals(Object obj)

Overrides java.lang.Object.equals.

Compares based on the executable and the index.

Parameters
obj:Object

The object to compare.

Returns:boolean

Whether or not this is equal to the argument.

Annotations
@Override
getAnnotatedTypeback to summary
public AnnotatedType getAnnotatedType()

Returns an AnnotatedType object that represents the use of a type to specify the type of the formal parameter represented by this Parameter.

Returns:AnnotatedType

an AnnotatedType object representing the use of a type to specify the type of the formal parameter represented by this Parameter

getAnnotationback to summary
public <T extends Annotation> T getAnnotation(Class<T> annotationClass)

Implements java.lang.reflect.AnnotatedElement.getAnnotation.

Doc from java.lang.reflect.AnnotatedElement.getAnnotation.

Returns this element's annotation for the specified type if such an annotation is present, else null.

Note that any annotation returned by this method is a declaration annotation.

Annotations
@Override
Exceptions
NullPointerException:
if the given annotation class is null
getAnnotationsback to summary
public Annotation[] getAnnotations()

Implements java.lang.reflect.AnnotatedElement.getAnnotations.

Doc from java.lang.reflect.AnnotatedElement.getAnnotations.

Returns annotations that are present on this element. If there are no annotations present on this element, the return value is an array of length 0. The caller of this method is free to modify the returned array; it will have no effect on the arrays returned to other callers.

Note that any annotations returned by this method are declaration annotations.

Annotations
@Override
getAnnotationsByTypeback to summary
public <T extends Annotation> T[] getAnnotationsByType(Class<T> annotationClass)

Overrides default java.lang.reflect.AnnotatedElement.getAnnotationsByType.

Doc from java.lang.reflect.AnnotatedElement.getAnnotationsByType.

Returns annotations that are associated with this element. If there are no annotations associated with this element, the return value is an array of length 0. The difference between this method and getAnnotation(Class) is that this method detects if its argument is a repeatable annotation type (JLS 9.6), and if so, attempts to find one or more annotations of that type by "looking through" a container annotation. The caller of this method is free to modify the returned array; it will have no effect on the arrays returned to other callers.

Note that any annotations returned by this method are declaration annotations.

Annotations
@Override
Exceptions
NullPointerException:
if the given annotation class is null
getDeclaredAnnotationback to summary
public <T extends Annotation> T getDeclaredAnnotation(Class<T> annotationClass)

Overrides default java.lang.reflect.AnnotatedElement.getDeclaredAnnotation.

Doc from java.lang.reflect.AnnotatedElement.getDeclaredAnnotation.

Returns this element's annotation for the specified type if such an annotation is directly present, else null. This method ignores inherited annotations. (Returns null if no annotations are directly present on this element.)

Note that any annotation returned by this method is a declaration annotation.

Annotations
@Override
Exceptions
NullPointerException:
if the given annotation class is null
getDeclaredAnnotationsback to summary
public Annotation[] getDeclaredAnnotations()

Implements java.lang.reflect.AnnotatedElement.getDeclaredAnnotations.

Doc from java.lang.reflect.AnnotatedElement.getDeclaredAnnotations.

Returns annotations that are directly present on this element. This method ignores inherited annotations. If there are no annotations directly present on this element, the return value is an array of length 0. The caller of this method is free to modify the returned array; it will have no effect on the arrays returned to other callers.

Note that any annotations returned by this method are declaration annotations.

Annotations
@Override
getDeclaredAnnotationsByTypeback to summary
public <T extends Annotation> T[] getDeclaredAnnotationsByType(Class<T> annotationClass)

Overrides default java.lang.reflect.AnnotatedElement.getDeclaredAnnotationsByType.

Doc from java.lang.reflect.AnnotatedElement.getDeclaredAnnotationsByType.

Returns this element's annotation(s) for the specified type if such annotations are either directly present or indirectly present. This method ignores inherited annotations. If there are no specified annotations directly or indirectly present on this element, the return value is an array of length 0. The difference between this method and getDeclaredAnnotation(Class) is that this method detects if its argument is a repeatable annotation type (JLS 9.6), and if so, attempts to find one or more annotations of that type by "looking through" a container annotation if one is present. The caller of this method is free to modify the returned array; it will have no effect on the arrays returned to other callers.

Note that any annotations returned by this method are declaration annotations.

Annotations
@Override
Exceptions
NullPointerException:
if the given annotation class is null
getDeclaringExecutableback to summary
public Executable getDeclaringExecutable()

Returns the Executable declaring this parameter.

Returns:Executable

the Executable declaring this parameter

getModifiersback to summary
public int getModifiers()

Returns the Java language modifiers for the parameter represented by this object.

Returns:int

the Java language modifiers for the parameter represented by this object

Java Language Specification
8.4.1 Formal Parameters
See Also
Java programming language and JVM modeling in core reflection
getNameback to summary
public String getName()

Returns the name of the parameter. If the parameter's name is present, then this method returns the name provided by the class file. Otherwise, this method synthesizes a name of the form argN, where N is the index of the parameter in the descriptor of the method which declares the parameter.

Returns:String

The name of the parameter, either provided by the class file or synthesized if the class file does not provide a name.

getParameterizedTypeback to summary
public Type getParameterizedType()

Returns a Type object that identifies the parameterized type for the parameter represented by this Parameter object.

Returns:Type

a Type object identifying the parameterized type of the parameter represented by this object

getRealNameback to summary
pack-priv String getRealName()
getTypeback to summary
public Class<?> getType()

Returns a Class object that identifies the declared type for the parameter represented by this Parameter object.

Returns:Class<?>

a Class object identifying the declared type of the parameter represented by this object

hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Returns a hash code based on the executable's hash code and the index.

Returns:int

A hash code based on the executable's hash code.

Annotations
@Override
isImplicitback to summary
public boolean isImplicit()

Returns true if this parameter is implicitly declared in source code; returns false otherwise.

Returns:boolean

true if and only if this parameter is implicitly declared as defined by The Java Language Specification.

isNamePresentback to summary
public boolean isNamePresent()

Returns true if the parameter has a name according to the class file; returns false otherwise. Whether a parameter has a name is determined by the MethodParameters attribute of the method which declares the parameter.

Returns:boolean

true if and only if the parameter has a name according to the class file.

isSyntheticback to summary
public boolean isSynthetic()

Returns true if this parameter is neither implicitly nor explicitly declared in source code; returns false otherwise.

Returns:boolean

true if and only if this parameter is a synthetic construct as defined by The Java Language Specification.

Java Language Specification
13.1 The Form of a Binary
See Also
Java programming language and JVM modeling in core reflection
isVarArgsback to summary
public boolean isVarArgs()

Returns true if this parameter represents a variable argument list; returns false otherwise.

Returns:boolean

true if an only if this parameter represents a variable argument list.

toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Returns a string describing this parameter. The format is the modifiers for the parameter, if any, in canonical order as recommended by The Java Language Specification, followed by the fully-qualified type of the parameter (excluding the last [] if the parameter is variable arity), followed by "..." if the parameter is variable arity, followed by a space, followed by the name of the parameter.

Returns:String

A string representation of the parameter and associated information.

Annotations
@Override