java.lang.Object | ||
↳ | java.lang.reflect.AccessibleObject | |
↳ | java.lang.reflect.Constructor<T> |
This class represents a constructor. Information about the constructor can be accessed, and the constructor can be invoked dynamically.
[Expand]
Inherited Constants | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From interface
java.lang.reflect.Member
|
Fields | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
accessFlags | Bits encoding access (e.g. | ||||||||||
declaringClass | Method's declaring class | ||||||||||
declaringClassOfOverriddenMethod | Overriden method's declaring class (same as declaringClass unless declaringClass is a proxy class) | ||||||||||
dexMethodIndex | The method index of this method within its defining dex file |
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Returns true if
other has the same declaring class and parameters
as this constructor.
| |||||||||||
Returns, for this element, the annotation with the specified type, or
null if no annotation with the specified type is present
(including inherited annotations).
| |||||||||||
Returns, for this element, the annotation with the specified type, or
null if no annotation with the specified type is present
(including inherited annotations).
| |||||||||||
Returns, for this element, an array containing all annotations (including
inherited annotations).
| |||||||||||
Returns, for this element, all annotations that are explicitly declared
(not inherited).
| |||||||||||
Returns the class that declares this constructor.
| |||||||||||
Returns the exception types as an array of
Class instances.
| |||||||||||
Returns the exception types as an array of
Type instances.
| |||||||||||
Returns the generic parameter types as an array of
Type
instances, in declaration order.
| |||||||||||
Returns the modifiers for this constructor.
| |||||||||||
Returns the name of this constructor.
| |||||||||||
Returns an array of arrays that represent the annotations of the formal
parameters of this constructor.
| |||||||||||
Returns an array of the
Class objects associated with the
parameter types of this constructor.
| |||||||||||
Returns the declared type parameters in declaration order.
| |||||||||||
Returns an integer hash code for this object.
Equivalent to | |||||||||||
Indicates whether or not this element has an annotation with the
specified annotation type (including inherited annotations).
| |||||||||||
Returns true if this constructor is synthetic (artificially introduced by the compiler).
| |||||||||||
Returns true if this constructor takes a variable number of arguments.
| |||||||||||
Returns a new instance of the declaring class, initialized by dynamically
invoking the constructor represented by this
Constructor object.
| |||||||||||
Attempts to set the accessible flag.
| |||||||||||
Returns the string representation of the constructor's declaration,
including the type parameters.
| |||||||||||
Returns a string containing a concise, human-readable description of this
constructor.
|
Protected Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
java.lang.reflect.AccessibleObject
| |||||||||||
From class
java.lang.Object
| |||||||||||
From interface
java.lang.reflect.AnnotatedElement
| |||||||||||
From interface
java.lang.reflect.GenericDeclaration
| |||||||||||
From interface
java.lang.reflect.Member
|
Bits encoding access (e.g. public, private) as well as other runtime specific flags
Overriden method's declaring class (same as declaringClass unless declaringClass is a proxy class)
The method index of this method within its defining dex file
Returns true if other
has the same declaring class and parameters
as this constructor.
other | the object to compare this instance with. |
---|
true
if the specified object is equal to this Object
; false
otherwise.Returns, for this element, the annotation with the specified type, or
null
if no annotation with the specified type is present
(including inherited annotations).
annotationClass | the type of the annotation to search for |
---|
null
Returns, for this element, the annotation with the specified type, or
null
if no annotation with the specified type is present
(including inherited annotations).
annotationType | the type of the annotation to search for |
---|
null
Returns, for this element, an array containing all annotations (including inherited annotations). If there are no annotations present, this method returns a zero length array.
Returns, for this element, all annotations that are explicitly declared (not inherited). If there are no declared annotations present, this method returns a zero length array.
Returns the class that declares this constructor.
Returns the exception types as an array of Class
instances. If
this constructor has no declared exceptions, an empty array will be
returned.
Returns the exception types as an array of Type
instances. If
this constructor has no declared exceptions, an empty array will be
returned.
GenericSignatureFormatError | if the generic constructor signature is invalid |
---|---|
TypeNotPresentException | if any exception type points to a missing type |
MalformedParameterizedTypeException | if any exception type points to a type that cannot be instantiated for some reason |
Returns the generic parameter types as an array of Type
instances, in declaration order. If this constructor has no generic
parameters, an empty array is returned.
GenericSignatureFormatError | if the generic constructor signature is invalid |
---|---|
TypeNotPresentException | if any parameter type points to a missing type |
MalformedParameterizedTypeException | if any parameter type points to a type that cannot be instantiated for some reason |
Returns the modifiers for this constructor. The Modifier
class
should be used to decode the result.
Returns the name of this constructor.
Returns an array of arrays that represent the annotations of the formal parameters of this constructor. If there are no parameters on this constructor, then an empty array is returned. If there are no annotations set, then an array of empty arrays is returned.
Annotation
instances
Returns an array of the Class
objects associated with the
parameter types of this constructor. If the constructor was declared with
no parameters, an empty array will be returned.
Returns the declared type parameters in declaration order. If there are no type parameters, this method returns a zero length array.
Returns an integer hash code for this object. By contract, any two
objects for which equals(Object)
returns true
must return
the same hash code value. This means that subclasses of Object
usually override both methods or neither method.
Note that hash values must not change over time unless information used in equals comparisons also changes.
See Writing a correct
hashCode
method
if you intend implementing your own hashCode
method.
Equivalent to getDeclaringClass().getName().hashCode()
.
Indicates whether or not this element has an annotation with the specified annotation type (including inherited annotations).
annotationType | the type of the annotation to search for |
---|
true
if the annotation exists, false
otherwiseReturns true if this constructor is synthetic (artificially introduced by the compiler).
Returns true if this constructor takes a variable number of arguments.
Returns a new instance of the declaring class, initialized by dynamically
invoking the constructor represented by this Constructor
object.
This reproduces the effect of new declaringClass(arg1, arg2, ... ,
argN)
This method performs the following:
AccessibleObject
) and this constructor is not accessible from the
current context, an IllegalAccessException is thrown.Constructor
object is
then invoked. If an exception is thrown during the invocation, it is
caught and wrapped in an InvocationTargetException. This exception is
then thrown. If the invocation completes normally, the newly initialized
object is returned.
args | the arguments to the constructor |
---|
InstantiationException | if the class cannot be instantiated |
---|---|
IllegalAccessException | if this constructor is not accessible |
IllegalArgumentException | if an incorrect number of arguments are passed, or an argument could not be converted by a widening conversion |
InvocationTargetException | if an exception was thrown by the invoked constructor |
Attempts to set the accessible flag. Setting this to true prevents IllegalAccessExceptions
.
Returns the string representation of the constructor's declaration, including the type parameters.
Returns a string containing a concise, human-readable description of this constructor. The format of the string is:
public String(byte[],String) throws UnsupportedEncodingException