java.lang.reflect.Constructor Maven / Gradle / Ivy
/*
This is not an official specification document, and usage is restricted.
NOTICE
(c) 2005-2007 Sun Microsystems, Inc. All Rights Reserved.
Neither this file nor any files generated from it describe a complete
specification, and they may only be used as described below. For
example, no permission is given for you to incorporate this file, in
whole or in part, in an implementation of a Java specification.
Sun Microsystems Inc. owns the copyright in this file and it is provided
to you for informative, as opposed to normative, use. The file and any
files generated from it may be used to generate other informative
documentation, such as a unified set of documents of API signatures for
a platform that includes technologies expressed as Java APIs. The file
may also be used to produce "compilation stubs," which allow
applications to be compiled and validated for such platforms.
Any work generated from this file, such as unified javadocs or compiled
stub files, must be accompanied by this notice in its entirety.
This work corresponds to the API signatures of JSR 219: Foundation
Profile 1.1. In the event of a discrepency between this work and the
JSR 219 specification, which is available at
http://www.jcp.org/en/jsr/detail?id=219, the latter takes precedence.
*/
package java.lang.reflect;
/**
* 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.
*
* @see Member
* @see java.lang.Class
* @see java.lang.Class#getConstructors()
* @see java.lang.Class#getConstructor(Class[])
* @see java.lang.Class#getDeclaredConstructors()
*
* @author Nakul Saraiya
*/
public final class Constructor extends AccessibleObject implements Member
{
/*
* This hidden constructor does not necessarily correspond to
* a constructor in the original source file -- it keeps javadoc
* from generating an inappropriate default constructor.
*/
private Constructor() { }
/**
* Returns the Class
object representing the class that declares
* the constructor represented by this Constructor
object.
*/
public Class getDeclaringClass() {
return null;
}
/**
* Returns the name of this constructor, as a string. This is
* always the same as the simple name of the constructor's declaring
* class.
*/
public String getName() {
return null;
}
/**
* Returns the Java language modifiers for the constructor
* represented by this Constructor
object, as an integer. The
* Modifier
class should be used to decode the modifiers.
*
* @see Modifier
*/
public int getModifiers() {
return 0;
}
/**
* Returns an array of Class
objects that represent the formal
* parameter types, in declaration order, of the constructor
* represented by this Constructor
object. Returns an array of
* length 0 if the underlying constructor takes no parameters.
*
* @return the parameter types for the constructor this object
* represents
*/
public Class[] getParameterTypes() {
return null;
}
/**
* Returns an array of Class
objects that represent the types of
* of exceptions declared to be thrown by the underlying constructor
* represented by this Constructor
object. Returns an array of
* length 0 if the constructor declares no exceptions in its throws
clause.
*
* @return the exception types declared as being thrown by the
* constructor this object represents
*/
public Class[] getExceptionTypes() {
return null;
}
/**
* Compares this Constructor
against the specified object.
* Returns true if the objects are the same. Two Constructor
objects are
* the same if they were declared by the same class and have the
* same formal parameter types.
*/
public boolean equals(Object obj) {
return false;
}
/**
* Returns a hashcode for this Constructor
. The hashcode is
* the same as the hashcode for the underlying constructor's
* declaring class name.
*/
public int hashCode() {
return 0;
}
/**
* Returns a string describing this Constructor
. The string is
* formatted as the constructor access modifiers, if any,
* followed by the fully-qualified name of the declaring class,
* followed by a parenthesized, comma-separated list of the
* constructor's formal parameter types. For example:
*
* public java.util.Hashtable(int,float)
*
*
* The only possible modifiers for constructors are the access
* modifiers public, protected or
* private. Only one of these may appear, or none if the
* constructor has default (package) access.
*/
public String toString() {
return null;
}
/**
* Uses the constructor represented by this Constructor
object to
* create and initialize a new instance of the constructor's
* declaring class, with the specified initialization parameters.
* Individual parameters are automatically unwrapped to match
* primitive formal parameters, and both primitive and reference
* parameters are subject to method invocation conversions as necessary.
*
*
If the number of formal parameters required by the underlying constructor
* is 0, the supplied initargs
array may be of length 0 or null.
*
*
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.
*
* @param initargs array 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 float
* in a {@link java.lang.Float Float})
*
* @return a new object created by calling the constructor
* this object represents
*
* @exception IllegalAccessException if this Constructor
object
* enforces Java language access control and the underlying
* constructor is inaccessible.
* @exception IllegalArgumentException if the number of actual
* and formal parameters differ; if an unwrapping
* conversion for primitive arguments fails; or if,
* after possible unwrapping, a parameter value
* cannot be converted to the corresponding formal
* parameter type by a method invocation conversion.
* @exception InstantiationException if the class that declares the
* underlying constructor represents an abstract class.
* @exception InvocationTargetException if the underlying constructor
* throws an exception.
* @exception ExceptionInInitializerError if the initialization provoked
* by this method fails.
*/
public Object newInstance(Object[] initargs)
throws InstantiationException, IllegalAccessException,
IllegalArgumentException, InvocationTargetException
{
return null;
}
}