3261N/A * Copyright (c) 1996, 2010, Oracle and/or its affiliates. All rights reserved. 0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 0N/A * This code is free software; you can redistribute it and/or modify it 0N/A * under the terms of the GNU General Public License version 2 only, as 2362N/A * published by the Free Software Foundation. Oracle designates this 0N/A * particular file as subject to the "Classpath" exception as provided 2362N/A * by Oracle in the LICENSE file that accompanied this code. 0N/A * This code is distributed in the hope that it will be useful, but WITHOUT 0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 0N/A * version 2 for more details (a copy is included in the LICENSE file that 0N/A * accompanied this code). 0N/A * You should have received a copy of the GNU General Public License version 0N/A * 2 along with this work; if not, write to the Free Software Foundation, 0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 2362N/A * or visit www.oracle.com if you need additional information or have any 0N/A * {@code Constructor} provides information about, and access to, a single 0N/A * constructor for a class. 0N/A * <p>{@code Constructor} permits widening conversions to occur when matching the 0N/A * actual parameters to newInstance() with the underlying 0N/A * constructor's formal parameters, but throws an 0N/A * {@code IllegalArgumentException} if a narrowing conversion would occur. 0N/A * @param <T> the class in which the constructor is declared 0N/A * @see java.lang.Class 0N/A * @see java.lang.Class#getConstructors() 0N/A * @see java.lang.Class#getConstructor(Class[]) 0N/A * @see java.lang.Class#getDeclaredConstructors() 0N/A * @author Kenneth Russell 0N/A * @author Nakul Saraiya 0N/A // Generics and annotations support 0N/A // generic info repository; lazily initialized 0N/A // Generics infrastructure 0N/A // Accessor for factory 0N/A // create scope and factory 0N/A // Accessor for generic info repository 0N/A // lazily initialize repository if necessary 0N/A // create and cache generic info repository 0N/A // For sharing of ConstructorAccessors. This branching structure 0N/A // is currently only two levels deep (i.e., one root Constructor 0N/A // and potentially many Constructor objects pointing to it.) 0N/A * Package-private constructor used by ReflectAccess to enable 0N/A * instantiation of these objects in Java code from the java.lang 0N/A * package via sun.reflect.LangReflectAccess. 0N/A * Package-private routine (exposed to java.lang.Class via 0N/A * ReflectAccess) which returns a copy of this Constructor. The copy's 0N/A * "root" field points to this Constructor. 0N/A // This routine enables sharing of ConstructorAccessor objects 0N/A // among Constructor objects which refer to the same underlying 0N/A // method in the VM. (All of this contortion is only necessary 0N/A // because of the "accessibility" bit in AccessibleObject, 0N/A // which implicitly requires that new java.lang.reflect 0N/A // objects be fabricated for each reflective call on Class 0N/A // Might as well eagerly propagate this if already present 0N/A * Returns the {@code Class} object representing the class that declares 0N/A * the constructor represented by this {@code Constructor} object. 0N/A * Returns the name of this constructor, as a string. This is 2745N/A * the binary name of the constructor's declaring class. 0N/A * Returns the Java language modifiers for the constructor 0N/A * represented by this {@code Constructor} object, as an integer. The 0N/A * {@code Modifier} class should be used to decode the modifiers. 0N/A * Returns an array of {@code TypeVariable} objects that represent the 0N/A * type variables declared by the generic declaration represented by this 0N/A * {@code GenericDeclaration} object, in declaration order. Returns an 0N/A * array of length 0 if the underlying generic declaration declares no type 0N/A * @return an array of {@code TypeVariable} objects that represent 0N/A * the type variables declared by this generic declaration 0N/A * @throws GenericSignatureFormatError if the generic 0N/A * signature of this generic declaration does not conform to 4008N/A * <cite>The Java™ Virtual Machine Specification</cite> 0N/A * Returns an array of {@code Class} objects that represent the formal 0N/A * parameter types, in declaration order, of the constructor 0N/A * represented by this {@code Constructor} object. Returns an array of 0N/A * length 0 if the underlying constructor takes no parameters. 0N/A * @return the parameter types for the constructor this object 0N/A * Returns an array of {@code Type} objects that represent the formal 0N/A * parameter types, in declaration order, of the method represented by 0N/A * this {@code Constructor} object. Returns an array of length 0 if the 0N/A * underlying method takes no parameters. 0N/A * <p>If a formal parameter type is a parameterized type, 0N/A * the {@code Type} object returned for it must accurately reflect 0N/A * the actual type parameters used in the source code. 0N/A * <p>If a formal parameter type is a type variable or a parameterized 0N/A * type, it is created. Otherwise, it is resolved. 0N/A * @return an array of {@code Type}s that represent the formal 0N/A * parameter types of the underlying method, in declaration order 0N/A * @throws GenericSignatureFormatError 0N/A * if the generic method signature does not conform to the format 4008N/A * <cite>The Java™ Virtual Machine Specification</cite> 0N/A * @throws TypeNotPresentException if any of the parameter 0N/A * types of the underlying method refers to a non-existent type 0N/A * @throws MalformedParameterizedTypeException if any of 0N/A * the underlying method's parameter types refer to a parameterized 0N/A * type that cannot be instantiated for any reason 0N/A * Returns an array of {@code Class} objects that represent the types 0N/A * of exceptions declared to be thrown by the underlying constructor 0N/A * represented by this {@code Constructor} object. Returns an array of 0N/A * length 0 if the constructor declares no exceptions in its {@code throws} clause. 0N/A * @return the exception types declared as being thrown by the 0N/A * constructor this object represents 0N/A * Returns an array of {@code Type} objects that represent the 0N/A * exceptions declared to be thrown by this {@code Constructor} object. 0N/A * Returns an array of length 0 if the underlying method declares 0N/A * no exceptions in its {@code throws} clause. 0N/A * <p>If an exception type is a type variable or a parameterized 0N/A * type, it is created. Otherwise, it is resolved. 0N/A * @return an array of Types that represent the exception types 0N/A * thrown by the underlying method 0N/A * @throws GenericSignatureFormatError 0N/A * if the generic method signature does not conform to the format 4008N/A * <cite>The Java™ Virtual Machine Specification</cite> 0N/A * @throws TypeNotPresentException if the underlying method's 0N/A * {@code throws} clause refers to a non-existent type declaration 0N/A * @throws MalformedParameterizedTypeException if 0N/A * the underlying method's {@code throws} clause refers to a 0N/A * parameterized type that cannot be instantiated for any reason 0N/A * Compares this {@code Constructor} against the specified object. 0N/A * Returns true if the objects are the same. Two {@code Constructor} objects are 0N/A * the same if they were declared by the same class and have the 0N/A * same formal parameter types. 0N/A /* Avoid unnecessary cloning */ 0N/A * Returns a hashcode for this {@code Constructor}. The hashcode is 0N/A * the same as the hashcode for the underlying constructor's 0N/A * declaring class name. 0N/A * Returns a string describing this {@code Constructor}. The string is 0N/A * formatted as the constructor access modifiers, if any, 0N/A * followed by the fully-qualified name of the declaring class, 0N/A * followed by a parenthesized, comma-separated list of the 0N/A * constructor's formal parameter types. For example: 0N/A * public java.util.Hashtable(int,float) 0N/A * <p>The only possible modifiers for constructors are the access 0N/A * modifiers {@code public}, {@code protected} or 0N/A * {@code private}. Only one of these may appear, or none if the 0N/A * constructor has default (package) access. 0N/A return "<" + e +
">";
0N/A * Returns a string describing this {@code Constructor}, 0N/A * including type parameters. The string is formatted as the 0N/A * constructor access modifiers, if any, followed by an 0N/A * angle-bracketed comma separated list of the constructor's type 0N/A * parameters, if any, followed by the fully-qualified name of the 0N/A * declaring class, followed by a parenthesized, comma-separated 0N/A * list of the constructor's generic formal parameter types. 0N/A * If this constructor was declared to take a variable number of 0N/A * arguments, instead of denoting the last parameter as 0N/A * "<tt><i>Type</i>[]</tt>", it is denoted as 0N/A * "<tt><i>Type</i>...</tt>". 0N/A * A space is used to separate access modifiers from one another 0N/A * and from the type parameters or return type. If there are no 0N/A * type parameters, the type parameter list is elided; if the type 0N/A * parameter list is present, a space separates the list from the 0N/A * class name. If the constructor is declared to throw 0N/A * exceptions, the parameter list is followed by a space, followed 0N/A * by the word "{@code throws}" followed by a 0N/A * comma-separated list of the thrown exception types. 0N/A * <p>The only possible modifiers for constructors are the access 0N/A * modifiers {@code public}, {@code protected} or 0N/A * {@code private}. Only one of these may appear, or none if the 0N/A * constructor has default (package) access. 0N/A * @return a string describing this {@code Constructor}, 0N/A * include type parameters 0N/A // Class objects can't occur here; no need to test 0N/A // and call Class.getName(). 0N/A return "<" + e +
">";
0N/A * Uses the constructor represented by this {@code Constructor} object to 0N/A * create and initialize a new instance of the constructor's 0N/A * declaring class, with the specified initialization parameters. 0N/A * Individual parameters are automatically unwrapped to match 0N/A * primitive formal parameters, and both primitive and reference 0N/A * parameters are subject to method invocation conversions as necessary. 0N/A * <p>If the number of formal parameters required by the underlying constructor 0N/A * is 0, the supplied {@code initargs} array may be of length 0 or null. 0N/A * <p>If the constructor's declaring class is an inner class in a 0N/A * non-static context, the first argument to the constructor needs 4008N/A * to be the enclosing instance; see section 15.9.3 of 4008N/A * <cite>The Java™ Language Specification</cite>. 0N/A * <p>If the required access and argument checks succeed and the 0N/A * instantiation will proceed, the constructor's declaring class 0N/A * is initialized if it has not already been initialized. 0N/A * <p>If the constructor completes normally, returns the newly 0N/A * created and initialized instance. 0N/A * @param initargs array of objects to be passed as arguments to 0N/A * the constructor call; values of primitive types are wrapped in 0N/A * a wrapper object of the appropriate type (e.g. a {@code float} 0N/A * in a {@link java.lang.Float Float}) 0N/A * @return a new object created by calling the constructor 0N/A * this object represents 0N/A * @exception IllegalAccessException if this {@code Constructor} object 3896N/A * is enforcing Java language access control and the underlying 0N/A * constructor is inaccessible. 0N/A * @exception IllegalArgumentException if the number of actual 0N/A * and formal parameters differ; if an unwrapping 0N/A * conversion for primitive arguments fails; or if, 0N/A * after possible unwrapping, a parameter value 0N/A * cannot be converted to the corresponding formal 0N/A * parameter type by a method invocation conversion; if 0N/A * this constructor pertains to an enum type. 0N/A * @exception InstantiationException if the class that declares the 0N/A * underlying constructor represents an abstract class. 0N/A * @exception InvocationTargetException if the underlying constructor 0N/A * throws an exception. 0N/A * @exception ExceptionInInitializerError if the initialization provoked 0N/A * by this method fails. 0N/A * Returns {@code true} if this constructor was declared to take 0N/A * a variable number of arguments; returns {@code false} 0N/A * @return {@code true} if an only if this constructor was declared to 0N/A * take a variable number of arguments. 0N/A * Returns {@code true} if this constructor is a synthetic 0N/A * constructor; returns {@code false} otherwise. 0N/A * @return true if and only if this constructor is a synthetic 4008N/A * constructor as defined by 4008N/A * <cite>The Java™ Language Specification</cite>. 0N/A // NOTE that there is no synchronization used here. It is correct 0N/A // (though not efficient) to generate more than one 0N/A // ConstructorAccessor for a given Constructor. However, avoiding 0N/A // synchronization will probably make the implementation more 0N/A // First check to see if one has been created yet, and take it 3903N/A // Otherwise fabricate one and propagate it up to the root 0N/A // Returns ConstructorAccessor for this Constructor object, not 0N/A // looking up the chain to the root 0N/A // Sets the ConstructorAccessor for this Constructor object and 0N/A // (recursively) its root 0N/A * @throws NullPointerException {@inheritDoc} 0N/A * Returns an array of arrays that represent the annotations on the formal 0N/A * parameters, in declaration order, of the method represented by 0N/A * this {@code Constructor} object. (Returns an array of length zero if the 0N/A * underlying method is parameterless. If the method has one or more 0N/A * parameters, a nested array of length zero is returned for each parameter 0N/A * with no annotations.) The annotation objects contained in the returned 0N/A * arrays are serializable. The caller of this method is free to modify 0N/A * the returned arrays; it will have no effect on the arrays returned to 0N/A * @return an array of arrays that represent the annotations on the formal 0N/A * parameters, in declaration order, of the method represented by this 0N/A * Constructor object 0N/A ;
// Can't do reliable parameter counting 0N/A // Check for the enclosing instance parameter for 0N/A // non-static member classes 0N/A "Parameter annotations don't match number of parameters");