Constructor provides information about, and access to, a single
constructor for a class.
Constructor permits widening conversions to occur when matching the
actual parameters to newInstance() with the underlying
constructor's formal parameters, but throws an
IllegalArgumentException if a narrowing conversion would occur.
Member, java.lang.Class , java.lang.Class#getConstructors() , java.lang.Class#getConstructor(Class[]) , java.lang.Class#getDeclaredConstructors()
| Modifier and Type | Field and Description |
|---|---|
| private final byte[] | |
| private final Class | |
| private ConstructorAccessor | |
| private final Class | |
| private transient volatile ConstructorRepository | |
| private final int | |
| private final byte[] | |
| private final Class | |
| private Constructor | root
Constructors are mutable due to |
| private final transient String | |
| private final int |
| Access | Constructor and Description |
|---|---|
| pack-priv | Constructor(Class<T> declaringClass, Class<?>[] parameterTypes, Class<?>[] checkedExceptions, int modifiers, int slot, String signature, byte[] annotations, byte[] parameterAnnotations)
Package-private constructor used by ReflectAccess to enable instantiation of these objects in Java code from the java.lang package via jdk.internal.access.JavaLangReflectAccess. |
| Modifier and Type | Method and Description |
|---|---|
| private ConstructorAccessor | |
| pack-priv void | |
| pack-priv void | checkCanSetAccessible(Class<?> caller)
Overrides java. If the given AccessibleObject is a |
| pack-priv Constructor | copy()
Package-private routine (exposed to java.lang.Class via ReflectAccess) which returns a copy of this Constructor. |
| public boolean | equals(Object obj)
Overrides java. Compares this |
| public AnnotatedType | getAnnotatedReceiverType()
Overrides java. Returns an |
| public AnnotatedType | getAnnotatedReturnType()
Implements abstract java. Returns an |
| public <T extends Annotation> T | getAnnotation(Class<T> annotationClass)
Overrides java. Implements java. Returns this element's annotation for the specified type if such an annotation is present, else null. |
| pack-priv byte[] | getAnnotationBytes()
Implements abstract java. Accessor method to allow code sharing |
| pack-priv ConstructorAccessor | |
| public Annotation[] | getDeclaredAnnotations()
Overrides java. Implements java. Returns annotations that are directly present on this element. |
| public Class | getDeclaringClass()
Implements abstract java. Implements java. Returns the |
| public Class | getExceptionTypes()
Implements abstract java. Returns an array of |
| private GenericsFactory | |
| public Type[] | getGenericExceptionTypes()
Overrides java. Returns an array of |
| pack-priv ConstructorRepository | |
| public Type[] | getGenericParameterTypes()
Overrides java. Returns an array of |
| public int | getModifiers()
Implements abstract java. Implements java. Returns the Java language modifiers for the executable represented by this object. |
| public String | getName()
Implements abstract java. Implements java. Returns the name of this constructor, as a string. |
| public Annotation[][] | getParameterAnnotations()
Implements abstract java. Returns an array of arrays of |
| public int | getParameterCount()
Implements abstract java. Returns the number of formal parameters (whether explicitly declared or implicitly declared or neither) for the executable represented by this object. |
| public Class | getParameterTypes()
Implements abstract java. Returns an array of |
| pack-priv byte[] | |
| pack-priv byte[] | |
| pack-priv Constructor | getRoot()
Overrides java. Returns the root AccessibleObject; or null if this object is the root. |
| pack-priv Class | |
| pack-priv Class | |
| pack-priv String | |
| pack-priv int | |
| public TypeVariable | getTypeParameters()
Implements abstract java. Implements java. Returns an array of |
| pack-priv boolean | handleParameterNumberMismatch(int resultLength, Class<?>[] parameterTypes)
Implements abstract java.
|
| pack-priv boolean | hasGenericInformation()
Implements abstract java. Does the Executable have generic information. |
| public int | |
| public boolean | isSynthetic()
Overrides java. Implements java. Returns |
| public boolean | isVarArgs()
Overrides java. Returns |
| public T | Returns: a new object created by calling the constructor this object representsarray of objects to be passed as arguments to
the constructor call; values of primitive types are wrapped in
a wrapper object of the appropriate type (e.g. a initargs)float
in a Float)Uses the constructor represented by this |
| pack-priv T | |
| pack-priv Constructor | |
| public void | setAccessible(boolean flag)
Overrides java. Set the |
| pack-priv void | |
| pack-priv void | specificToGenericStringHeader(StringBuilder sb)
Implements abstract java. Generate toGenericString header information specific to a method or constructor. |
| pack-priv void | specificToStringHeader(StringBuilder sb)
Implements abstract java. Generate toString header information specific to a method or constructor. |
| public String | Returns: a string describing thisConstructor,
include type parametersOverrides java. Returns a string describing this |
| pack-priv String | toShortString()
Overrides java. Returns a short descriptive string to describe this object in log messages. |
| public String | Returns: a string describing thisConstructorOverrides java. Returns a string describing this |
| annotations | back to summary |
|---|---|
| private final byte[] annotations | |
| clazz | back to summary |
|---|---|
| private final Class<T> clazz | |
| constructorAccessor | back to summary |
|---|---|
| private ConstructorAccessor constructorAccessor
| |
| exceptionTypes | back to summary |
|---|---|
| private final Class<?>[] exceptionTypes | |
| genericInfo | back to summary |
|---|---|
| private transient volatile ConstructorRepository genericInfo | |
| modifiers | back to summary |
|---|---|
| private final int modifiers | |
| parameterAnnotations | back to summary |
|---|---|
| private final byte[] parameterAnnotations | |
| parameterTypes | back to summary |
|---|---|
| private final Class<?>[] parameterTypes | |
| root | back to summary |
|---|---|
| private Constructor<T> root Constructors are mutable due to | |
| signature | back to summary |
|---|---|
| private final transient String signature | |
| slot | back to summary |
|---|---|
| private final int slot | |
| Constructor | back to summary |
|---|---|
| pack-priv Constructor(Class<T> declaringClass, Class<?>[] parameterTypes, Class<?>[] checkedExceptions, int modifiers, int slot, String signature, byte[] annotations, byte[] parameterAnnotations) Package-private constructor used by ReflectAccess to enable instantiation of these objects in Java code from the java.lang package via jdk.internal.access.JavaLangReflectAccess. | |
| acquireConstructorAccessor | back to summary |
|---|---|
| private ConstructorAccessor acquireConstructorAccessor() | |
| appendModifiers | back to summary |
|---|---|
| pack-priv void appendModifiers(StringBuilder sb) Implements abstract java.
| |
| checkCanSetAccessible | back to summary |
|---|---|
| pack-priv void checkCanSetAccessible(Class<?> caller) Overrides java. Doc from java. If the given AccessibleObject is a
| |
| copy | back to summary |
|---|---|
| pack-priv Constructor Package-private routine (exposed to java.lang.Class via ReflectAccess) which returns a copy of this Constructor. The copy's "root" field points to this Constructor. | |
| equals | back to summary |
|---|---|
| public boolean equals(Object obj) Overrides java. Compares this | |
| getAnnotatedReceiverType | back to summary |
|---|---|
| public AnnotatedType getAnnotatedReceiverType() Overrides java. Doc from java. Returns an
| |
| getAnnotatedReturnType | back to summary |
|---|---|
| public AnnotatedType getAnnotatedReturnType() Implements abstract java. Doc from java. Returns an
| |
| getAnnotation | back to summary |
|---|---|
| public <T extends Annotation> T getAnnotation(Class<T> annotationClass) Overrides java. Implements java. Doc from java. Returns this element's annotation for the specified type if such an annotation is present, else null.
| |
| getAnnotationBytes | back to summary |
|---|---|
| pack-priv byte[] getAnnotationBytes() Implements abstract java. Doc from java. Accessor method to allow code sharing
| |
| getConstructorAccessor | back to summary |
|---|---|
| pack-priv ConstructorAccessor getConstructorAccessor() | |
| getDeclaredAnnotations | back to summary |
|---|---|
| public Annotation[] getDeclaredAnnotations() Overrides java. Implements java. Doc from java. 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.
| |
| getDeclaringClass | back to summary |
|---|---|
| public Class Implements abstract java. Implements java. Returns the
| |
| getExceptionTypes | back to summary |
|---|---|
| public Class Implements abstract java. Doc from java. Returns an array of
| |
| getFactory | back to summary |
|---|---|
| private GenericsFactory getFactory() | |
| getGenericExceptionTypes | back to summary |
|---|---|
| public Type[] getGenericExceptionTypes() Overrides java. Doc from java. Returns an array of If an exception type is a type variable or a parameterized type, it is created. Otherwise, it is resolved.
| |
| getGenericInfo | back to summary |
|---|---|
| pack-priv ConstructorRepository getGenericInfo() Implements abstract java.
| |
| getGenericParameterTypes | back to summary |
|---|---|
| public Type[] getGenericParameterTypes() Overrides java. Doc from java. Returns an array of If a formal parameter type is a parameterized type,
the If a formal parameter type is a type variable or a parameterized type, it is created. Otherwise, it is resolved.
| |
| getModifiers | back to summary |
|---|---|
| public int getModifiers() Implements abstract java. Implements java. Doc from java. Returns the Java language modifiers for the executable represented by this object.
| |
| getName | back to summary |
|---|---|
| public String getName() Implements abstract java. Implements java. Returns the name of this constructor, as a string. This is the binary name of the constructor's declaring class.
| |
| getParameterAnnotations | back to summary |
|---|---|
| public Annotation[][] getParameterAnnotations() Implements abstract java. Doc from java. Returns an array of arrays of Note that any annotations returned by this method are declaration annotations.
| |
| getParameterCount | back to summary |
|---|---|
| public int getParameterCount() Implements abstract java. Doc from java. Returns the number of formal parameters (whether explicitly declared or implicitly declared or neither) for the executable represented by this object.
| |
| getParameterTypes | back to summary |
|---|---|
| public Class Implements abstract java. Doc from java. Returns an array of
| |
| getRawAnnotations | back to summary |
|---|---|
| pack-priv byte[] getRawAnnotations() | |
| getRawParameterAnnotations | back to summary |
|---|---|
| pack-priv byte[] getRawParameterAnnotations() | |
| getRoot | back to summary |
|---|---|
| pack-priv Constructor Overrides java. Doc from java. Returns the root AccessibleObject; or null if this object is the root. All subclasses override this method.
| |
| getSharedExceptionTypes | back to summary |
|---|---|
| pack-priv Class Implements abstract java.
| |
| getSharedParameterTypes | back to summary |
|---|---|
| pack-priv Class Implements abstract java.
| |
| getSignature | back to summary |
|---|---|
| pack-priv String getSignature() | |
| getSlot | back to summary |
|---|---|
| pack-priv int getSlot() | |
| getTypeParameters | back to summary |
|---|---|
| public TypeVariable Implements abstract java. Implements java. Doc from java. Returns an array of
| |
| handleParameterNumberMismatch | back to summary |
|---|---|
| pack-priv boolean handleParameterNumberMismatch(int resultLength, Class<?>[] parameterTypes) Implements abstract java.
| |
| hasGenericInformation | back to summary |
|---|---|
| pack-priv boolean hasGenericInformation() Implements abstract java. Doc from java. Does the Executable have generic information.
| |
| hashCode | back to summary |
|---|---|
| public int hashCode() Overrides java. Returns a hashcode for this | |
| isSynthetic | back to summary |
|---|---|
| public boolean isSynthetic() Overrides java. Implements java. Doc from java. Returns
| |
| isVarArgs | back to summary |
|---|---|
| public boolean isVarArgs() Overrides java. Doc from java. Returns
| |
| newInstance | back to summary |
|---|---|
| public T newInstance(Object... initargs) throws InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException Uses the constructor represented by this If the number of formal parameters required by the underlying constructor
is 0, the supplied If the constructor's declaring class is an inner class in a non-static context, the first argument to the constructor needs to be the enclosing instance; see section 15.9.3 of The Java Language Specification. If the required access and argument checks succeed and the instantiation will proceed, the constructor's declaring class is initialized if it has not already been initialized. If the constructor completes normally, returns the newly created and initialized instance.
| |
| newInstanceWithCaller | back to summary |
|---|---|
| pack-priv T newInstanceWithCaller(Object[] args, boolean checkAccess, Class<?> caller) throws InstantiationException, IllegalAccessException, InvocationTargetException | |
| newWithAccessor | back to summary |
|---|---|
| pack-priv Constructor | |
| setAccessible | back to summary |
|---|---|
| public void setAccessible(boolean flag) Overrides java. Doc from java. Set the This method may be used by a caller in class
This method may be used by JNI code
with no caller class on the stack to enable access to a
This method cannot be used to enable access to private members, members with default (package) access, protected instance members, or protected constructors when the declaring class is in a different module to the caller and the package containing the declaring class is not open to the caller's module. A
| |
| setConstructorAccessor | back to summary |
|---|---|
| pack-priv void setConstructorAccessor(ConstructorAccessor accessor) | |
| specificToGenericStringHeader | back to summary |
|---|---|
| pack-priv void specificToGenericStringHeader(StringBuilder sb) Implements abstract java. Doc from java. Generate toGenericString header information specific to a method or constructor.
| |
| specificToStringHeader | back to summary |
|---|---|
| pack-priv void specificToStringHeader(StringBuilder sb) Implements abstract java. Doc from java. Generate toString header information specific to a method or constructor.
| |
| toGenericString | back to summary |
|---|---|
| public String toGenericString() Overrides java. Returns a string describing this The only possible modifiers for constructors are the access
modifiers
| |
| toShortString | back to summary |
|---|---|
| pack-priv String toShortString() Overrides java. Doc from java. Returns a short descriptive string to describe this object in log messages.
| |
| toString | back to summary |
|---|---|
| public String toString() Overrides java. Returns a string describing this
If the constructor is declared to throw exceptions, the
parameter list is followed by a space, followed by the word
" The only possible modifiers for constructors are the access
modifiers
| |