1 *java.lang.reflect.Constructor* *Constructor* Constructor provides information a
3 public final class Constructor<T>
4 extends |java.lang.reflect.AccessibleObject|
5 implements |java.lang.reflect.GenericDeclaration|
6 |java.lang.reflect.Member|
8 |java.lang.reflect.Constructor_Description|
9 |java.lang.reflect.Constructor_Fields|
10 |java.lang.reflect.Constructor_Constructors|
11 |java.lang.reflect.Constructor_Methods|
13 ================================================================================
15 *java.lang.reflect.Constructor_Methods*
16 |java.lang.reflect.Constructor.equals(Object)|Compares this Constructor against
17 |java.lang.reflect.Constructor.getAnnotation(Class<T>)|
18 |java.lang.reflect.Constructor.getDeclaredAnnotations()|
19 |java.lang.reflect.Constructor.getDeclaringClass()|Returns the Class object rep
20 |java.lang.reflect.Constructor.getExceptionTypes()|Returns an array of Class ob
21 |java.lang.reflect.Constructor.getGenericExceptionTypes()|Returns an array of T
22 |java.lang.reflect.Constructor.getGenericParameterTypes()|Returns an array of T
23 |java.lang.reflect.Constructor.getModifiers()|Returns the Java language modifie
24 |java.lang.reflect.Constructor.getName()|Returns the name of this constructor,
25 |java.lang.reflect.Constructor.getParameterAnnotations()|Returns an array of ar
26 |java.lang.reflect.Constructor.getParameterTypes()|Returns an array of Class ob
27 |java.lang.reflect.Constructor.getTypeParameters()|Returns an array of TypeVari
28 |java.lang.reflect.Constructor.hashCode()|Returns a hashcode for this Construct
29 |java.lang.reflect.Constructor.isSynthetic()|Returns true if this constructor i
30 |java.lang.reflect.Constructor.isVarArgs()|Returns true if this constructor was
31 |java.lang.reflect.Constructor.newInstance(Object...)|Uses the constructor repr
32 |java.lang.reflect.Constructor.toGenericString()|Returns a string describing th
33 |java.lang.reflect.Constructor.toString()|Returns a string describing this Cons
35 *java.lang.reflect.Constructor_Description*
37 Constructor provides information about, and access to, a single constructor for
40 Constructor permits widening conversions to occur when matching the actual
41 parameters to newInstance() with the underlying constructor's formal
42 parameters, but throws an IllegalArgumentException if a narrowing conversion
47 *java.lang.reflect.Constructor.equals(Object)*
49 public boolean equals(java.lang.Object obj)
51 Compares this Constructor against the specified object. Returns true if the
52 objects are the same. Two Constructor objects are the same if they were
53 declared by the same class and have the same formal parameter types.
57 *java.lang.reflect.Constructor.getAnnotation(Class<T>)*
59 public |T| getAnnotation(java.lang.Class<T> annotationClass)
65 *java.lang.reflect.Constructor.getDeclaredAnnotations()*
67 public |java.lang.annotation.Annotation|[] getDeclaredAnnotations()
73 *java.lang.reflect.Constructor.getDeclaringClass()*
75 public |java.lang.Class|<T> getDeclaringClass()
77 Returns the Class object representing the class that declares the constructor
78 represented by this Constructor object.
82 *java.lang.reflect.Constructor.getExceptionTypes()*
84 public |java.lang.Class|[] getExceptionTypes()
86 Returns an array of Class objects that represent the types of exceptions
87 declared to be thrown by the underlying constructor represented by this
88 Constructor object. Returns an array of length 0 if the constructor declares no
89 exceptions in its throws clause.
93 Returns: the exception types declared as being thrown by the constructor this object
96 *java.lang.reflect.Constructor.getGenericExceptionTypes()*
98 public |java.lang.reflect.Type|[] getGenericExceptionTypes()
100 Returns an array of Type objects that represent the exceptions declared to be
101 thrown by this Constructor object. Returns an array of length 0 if the
102 underlying method declares no exceptions in its throws clause.
104 If an exception type is a parameterized type, the Type object returned for it
105 must accurately reflect the actual type parameters used in the source code.
107 If an exception type is a type variable or a parameterized type, it is created.
108 Otherwise, it is resolved.
112 Returns: an array of Types that represent the exception types thrown by the underlying
115 *java.lang.reflect.Constructor.getGenericParameterTypes()*
117 public |java.lang.reflect.Type|[] getGenericParameterTypes()
119 Returns an array of Type objects that represent the formal parameter types, in
120 declaration order, of the method represented by this Constructor object.
121 Returns an array of length 0 if the underlying method takes no parameters.
123 If a formal parameter type is a parameterized type, the Type object returned
124 for it must accurately reflect the actual type parameters used in the source
127 If a formal parameter type is a type variable or a parameterized type, it is
128 created. Otherwise, it is resolved.
132 Returns: an array of Types that represent the formal parameter types of the underlying
133 method, in declaration order
135 *java.lang.reflect.Constructor.getModifiers()*
137 public int getModifiers()
139 Returns the Java language modifiers for the constructor represented by this
140 Constructor object, as an integer. The Modifier class should be used to decode
145 *java.lang.reflect.Constructor.getName()*
147 public |java.lang.String| getName()
149 Returns the name of this constructor, as a string. This is always the same as
150 the simple name of the constructor's declaring class.
154 *java.lang.reflect.Constructor.getParameterAnnotations()*
156 public |java.lang.annotation.Annotation|[][] getParameterAnnotations()
158 Returns an array of arrays that represent the annotations on the formal
159 parameters, in declaration order, of the method represented by this Constructor
160 object. (Returns an array of length zero if the underlying method is
161 parameterless. If the method has one or more parameters, a nested array of
162 length zero is returned for each parameter with no annotations.) The annotation
163 objects contained in the returned arrays are serializable. The caller of this
164 method is free to modify the returned arrays; it will have no effect on the
165 arrays returned to other callers.
169 Returns: an array of arrays that represent the annotations on the formal parameters, in
170 declaration order, of the method represented by this Constructor
173 *java.lang.reflect.Constructor.getParameterTypes()*
175 public |java.lang.Class|[] getParameterTypes()
177 Returns an array of Class objects that represent the formal parameter types, in
178 declaration order, of the constructor represented by this Constructor object.
179 Returns an array of length 0 if the underlying constructor takes no parameters.
183 Returns: the parameter types for the constructor this object represents
185 *java.lang.reflect.Constructor.getTypeParameters()*
187 public |java.lang.reflect.TypeVariable|[] getTypeParameters()
189 Returns an array of TypeVariable objects that represent the type variables
190 declared by the generic declaration represented by this GenericDeclaration
191 object, in declaration order. Returns an array of length 0 if the underlying
192 generic declaration declares no type variables.
196 Returns: an array of TypeVariable objects that represent the type variables declared by
197 this generic declaration
199 *java.lang.reflect.Constructor.hashCode()*
201 public int hashCode()
203 Returns a hashcode for this Constructor. The hashcode is the same as the
204 hashcode for the underlying constructor's declaring class name.
208 *java.lang.reflect.Constructor.isSynthetic()*
210 public boolean isSynthetic()
212 Returns true if this constructor is a synthetic constructor; returns false
217 Returns: true if and only if this constructor is a synthetic constructor as defined by
218 the Java Language Specification.
220 *java.lang.reflect.Constructor.isVarArgs()*
222 public boolean isVarArgs()
224 Returns true if this constructor was declared to take a variable number of
225 arguments; returns false otherwise.
229 Returns: true if an only if this constructor was declared to take a variable number of
232 *java.lang.reflect.Constructor.newInstance(Object...)*
234 public |T| newInstance(java.lang.Object[] initargs)
235 throws |java.lang.IllegalAccessException|
236 |java.lang.IllegalArgumentException|
237 |java.lang.InstantiationException|
238 |java.lang.reflect.InvocationTargetException|
240 Uses the constructor represented by this Constructor object to create and
241 initialize a new instance of the constructor's declaring class, with the
242 specified initialization parameters. Individual parameters are automatically
243 unwrapped to match primitive formal parameters, and both primitive and
244 reference parameters are subject to method invocation conversions as necessary.
246 If the number of formal parameters required by the underlying constructor is 0,
247 the supplied initargs array may be of length 0 or null.
249 If the constructor's declaring class is an inner class in a non-static context,
250 the first argument to the constructor needs to be the enclosing instance; see
251 The Java Language Specification, section 15.9.3.
253 If the required access and argument checks succeed and the instantiation will
254 proceed, the constructor's declaring class is initialized if it has not already
257 If the constructor completes normally, returns the newly created and
258 initialized instance.
261 initargs - array of objects to be passed as arguments to the constructor call; values of
262 primitive types are wrapped in a wrapper object of the appropriate type
263 (e.g. a float in a {@link java.lang.Float Float})
265 Returns: a new object created by calling the constructor this object represents
267 *java.lang.reflect.Constructor.toGenericString()*
269 public |java.lang.String| toGenericString()
271 Returns a string describing this Constructor, including type parameters. The
272 string is formatted as the constructor access modifiers, if any, followed by an
273 angle-bracketed comma separated list of the constructor's type parameters, if
274 any, followed by the fully-qualified name of the declaring class, followed by a
275 parenthesized, comma-separated list of the constructor's generic formal
276 parameter types. A space is used to separate access modifiers from one another
277 and from the type parameters or return type. If there are no type parameters,
278 the type parameter list is elided; if the type parameter list is present, a
279 space separates the list from the class name. If the constructor is declared to
280 throw exceptions, the parameter list is followed by a space, followed by the
281 word throws followed by a comma-separated list of the thrown exception types.
283 The only possible modifiers for constructors are the access modifiers public,
284 protected or private. Only one of these may appear, or none if the constructor
285 has default (package) access.
289 Returns: a string describing this Constructor, include type parameters
291 *java.lang.reflect.Constructor.toString()*
293 public |java.lang.String| toString()
295 Returns a string describing this Constructor. The string is formatted as the
296 constructor access modifiers, if any, followed by the fully-qualified name of
297 the declaring class, followed by a parenthesized, comma-separated list of the
298 constructor's formal parameter types. For example:
300 public java.util.Hashtable(int,float)
302 The only possible modifiers for constructors are the access modifiers public,
303 protected or private. Only one of these may appear, or none if the constructor
304 has default (package) access.