<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<!--NewPage-->
<html>
<head>
<!-- Generated by javadoc on Wed Jul 28 01:21:15 GMT 1999 -->
<title>
  Class java.lang.reflect.Method
</title>
</head>
<body>
<a name="_top_"></a>
<pre>
<a href="packages.html">All Packages</a>  <a href="tree.html">Class Hierarchy</a>  <a href="Package-java.lang.reflect.html">This Package</a>  <a href="java.lang.reflect.Field.html#_top_">Previous</a>  <a href="java.lang.reflect.Modifier.html#_top_">Next</a>  <a href="AllNames.html">Index</a></pre>
<hr>
<h1>
  Class java.lang.reflect.Method
</h1>
<pre>
<a href="java.lang.Object.html#_top_">java.lang.Object</a>
   |
   +----java.lang.reflect.Method
</pre>
<hr>
<dl>
  <dt> public final class <b>Method</b>
  <dt> extends <a href="java.lang.Object.html#_top_">Object</a>
  <dt> implements <a href="java.lang.reflect.Member.html#_top_">Member</a>
</dl>
A Method provides information about, and access to, a single method
 on a class or interface.  The reflected method may be a class method
 or an instance method (including an abstract method).
 <p>A Method permits widening conversions to occur when matching the
 actual parameters to invokewith the underlying method's formal
 parameters, but it throws an IllegalArgumentException if a
 narrowing conversion would occur.
<p>
<dl>
    <dt> <b>See Also:</b>
    <dd> <a href="java.lang.reflect.Member.html#_top_">Member</a>, <a href="java.lang.Class.html#_top_">Class</a>, <a href="java.lang.Class.html#getMethods()">getMethods</a>, <a href="java.lang.Class.html#getMethod()">getMethod</a>, <a href="java.lang.Class.html#getDeclaredMethods()">getDeclaredMethods</a>, <a href="java.lang.Class.html#getDeclaredMethod()">getDeclaredMethod</a>
</dl>
<hr>
<a name="index"></a>
<h2>
  <img src="images/method-index.gif" width=207 height=38 alt="Method Index">
</h2>
<dl>
  <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#equals(java.lang.Object)"><b>equals</b></a>(Object)
  <dd>  Compares this Method against the specified object.
  <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#getDeclaringClass()"><b>getDeclaringClass</b></a>()
  <dd>  Returns the Class object representing the class or interface
 that declares the method represented by this Method object.
  <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#getExceptionTypes()"><b>getExceptionTypes</b></a>()
  <dd>  Returns an array of Class objects that represent the types of
 the checked exceptions thrown by the underlying method
 represented by this Method object.
  <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#getModifiers()"><b>getModifiers</b></a>()
  <dd>  Returns the Java language modifiers for the method represented
 by this Method object, as an integer.
  <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#getName()"><b>getName</b></a>()
  <dd>  Returns the name of the method represented by this Method
 object, as a String.
  <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#getParameterTypes()"><b>getParameterTypes</b></a>()
  <dd>  Returns an array of Class objects that represent the formal
 parameter types, in declaration order, of the method
 represented by this Method object.
  <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#getReturnType()"><b>getReturnType</b></a>()
  <dd>  Returns a Class object that represents the formal return type
 of the method represented by this Method object.
  <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#hashCode()"><b>hashCode</b></a>()
  <dd>  Returns a hashcode for this Method.
  <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#invoke(java.lang.Object, java.lang.Object[])"><b>invoke</b></a>(Object, Object[])
  <dd>  Invokes the underlying method represented by this Method
 object, on the specified object with the specified parameters.
  <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#toString()"><b>toString</b></a>()
  <dd>  Returns a string describing this Method.
</dl>
<a name="methods"></a>
<h2>
  <img src="images/methods.gif" width=151 height=38 alt="Methods">
</h2>
<a name="getDeclaringClass()"><img src="images/red-ball.gif" width=12 height=12 alt=" o "></a>
<a name="getDeclaringClass"><b>getDeclaringClass</b></a>
<pre>
 public <a href="java.lang.Class.html#_top_">Class</a> getDeclaringClass()
</pre>
<dl>
  <dd> Returns the Class object representing the class or interface
 that declares the method represented by this Method object.
<p>
</dl>
<a name="getName()"><img src="images/red-ball.gif" width=12 height=12 alt=" o "></a>
<a name="getName"><b>getName</b></a>
<pre>
 public <a href="java.lang.String.html#_top_">String</a> getName()
</pre>
<dl>
  <dd> Returns the name of the method represented by this Method
 object, as a String.
<p>
</dl>
<a name="getModifiers()"><img src="images/red-ball.gif" width=12 height=12 alt=" o "></a>
<a name="getModifiers"><b>getModifiers</b></a>
<pre>
 public native int getModifiers()
</pre>
<dl>
  <dd> Returns the Java language modifiers for the method represented
 by this Method object, as an integer. The Modifier class should
 be used to decode the modifiers.
<p>
  <dd><dl>
    <dt> <b>See Also:</b>
    <dd> <a href="java.lang.reflect.Modifier.html#_top_">Modifier</a>
  </dl></dd>
</dl>
<a name="getReturnType()"><img src="images/red-ball.gif" width=12 height=12 alt=" o "></a>
<a name="getReturnType"><b>getReturnType</b></a>
<pre>
 public <a href="java.lang.Class.html#_top_">Class</a> getReturnType()
</pre>
<dl>
  <dd> Returns a Class object that represents the formal return type
 of the method represented by this Method object.
<p>
</dl>
<a name="getParameterTypes()"><img src="images/red-ball.gif" width=12 height=12 alt=" o "></a>
<a name="getParameterTypes"><b>getParameterTypes</b></a>
<pre>
 public <a href="java.lang.Class.html#_top_">Class</a>[] getParameterTypes()
</pre>
<dl>
  <dd> Returns an array of Class objects that represent the formal
 parameter types, in declaration order, of the method
 represented by this Method object.  Returns an array of length
 0 if the underlying method takes no parameters.
<p>
</dl>
<a name="getExceptionTypes()"><img src="images/red-ball.gif" width=12 height=12 alt=" o "></a>
<a name="getExceptionTypes"><b>getExceptionTypes</b></a>
<pre>
 public <a href="java.lang.Class.html#_top_">Class</a>[] getExceptionTypes()
</pre>
<dl>
  <dd> Returns an array of Class objects that represent the types of
 the checked exceptions thrown by the underlying method
 represented by this Method object.  Returns an array of length
 0 if the method throws no checked exceptions.
<p>
</dl>
<a name="equals(java.lang.Object)"><img src="images/red-ball.gif" width=12 height=12 alt=" o "></a>
<a name="equals"><b>equals</b></a>
<pre>
 public boolean equals(<a href="java.lang.Object.html#_top_">Object</a> obj)
</pre>
<dl>
  <dd> Compares this Method against the specified object.  Returns
 true if the objects are the same.  Two Methods are the same if
 they were declared by the same class and have the same name
 and formal parameter types.
<p>
  <dd><dl>
    <dt> <b>Overrides:</b>
    <dd> <a href="java.lang.Object.html#equals(java.lang.Object)">equals</a> in class <a href="java.lang.Object.html#_top_">Object</a>
  </dl></dd>
</dl>
<a name="hashCode()"><img src="images/red-ball.gif" width=12 height=12 alt=" o "></a>
<a name="hashCode"><b>hashCode</b></a>
<pre>
 public int hashCode()
</pre>
<dl>
  <dd> Returns a hashcode for this Method.  The hashcode is computed
 as the exclusive-or of the hashcodes for the underlying
 method's declaring class name and the method's name.
<p>
  <dd><dl>
    <dt> <b>Overrides:</b>
    <dd> <a href="java.lang.Object.html#hashCode()">hashCode</a> in class <a href="java.lang.Object.html#_top_">Object</a>
  </dl></dd>
</dl>
<a name="toString()"><img src="images/red-ball.gif" width=12 height=12 alt=" o "></a>
<a name="toString"><b>toString</b></a>
<pre>
 public <a href="java.lang.String.html#_top_">String</a> toString()
</pre>
<dl>
  <dd> Returns a string describing this Method.  The string is
 formatted as the method access modifiers, if any, followed by
 the method return type, followed by a space, followed by the
 class declaring the method, followed by a period, followed by
 the method name, followed by a parenthesized, comma-separated
 list of the method's formal parameter types. If the method
 throws checked exceptions, the parameter list is followed by a
 space, followed by the word throws followed by a
 comma-separated list of the thrown exception types.
 For example:
 <pre>
    public boolean java.lang.Object.equals(java.lang.Object)
 </pre>
 <p>The access modifiers are placed in canonical order as
 specified by "The Java Language Specification".  This is
 <tt>public</tt>, <tt>protected</tt> or <tt>private</tt> first,
 and then other modifiers in the following order:
 <tt>abstract</tt>, <tt>static</tt>, <tt>final</tt>,
 <tt>synchronized</tt> <tt>native</tt>.
<p>
  <dd><dl>
    <dt> <b>Overrides:</b>
    <dd> <a href="java.lang.Object.html#toString()">toString</a> in class <a href="java.lang.Object.html#_top_">Object</a>
  </dl></dd>
</dl>
<a name="invoke(java.lang.Object, java.lang.Object[])"><img src="images/red-ball.gif" width=12 height=12 alt=" o "></a>
<a name="invoke"><b>invoke</b></a>
<pre>
 public native <a href="java.lang.Object.html#_top_">Object</a> invoke(<a href="java.lang.Object.html#_top_">Object</a> obj,
                             <a href="java.lang.Object.html#_top_">Object</a> args[]) throws <a href="java.lang.IllegalAccessException.html#_top_">IllegalAccessException</a>, <a href="java.lang.IllegalArgumentException.html#_top_">IllegalArgumentException</a>, <a href="java.lang.reflect.InvocationTargetException.html#_top_">InvocationTargetException</a>
</pre>
<dl>
  <dd> Invokes the underlying method represented by this Method
 object, on the specified object with the specified parameters.
 Individual parameters are automatically unwrapped to match
 primitive formal parameters, and both primitive and reference
 parameters are subject to widening conversions as
 necessary. The value returned by the underlying method is
 automatically wrapped in an object if it has a primitive type.
 <p>Method invocation proceeds with the following steps, in order:
 <p>If the underlying method is static, then the specified object
 argument is ignored. It may be null.
 <p>Otherwise, the method is an instance method.  If the specified
 object argument is null, the invocation throws a
 NullPointerException.  Otherwise, if the specified object
 argument is not an instance of the class or interface declaring
 the underlying method, the invocation throws an
 IllegalArgumentException.
 <p>If this Method object enforces Java language access control and
 the underlying method is inaccessible, the invocation throws an
 IllegalAccessException.
 <p>If the number of actual parameters supplied via args is
 different from the number of formal parameters required by the
 underlying method, the invocation throws an
 IllegalArgumentException.
 <p>For each actual parameter in the supplied args array:
 <p>If the corresponding formal parameter has a primitive type, an
 unwrapping conversion is attempted to convert the object value
 to a value of a primitive type.  If this attempt fails, the
 invocation throws an IllegalArgumentException.
 <p>If, after possible unwrapping, the parameter value cannot be
 converted to the corresponding formal parameter type by an
 identity or widening conversion, the invocation throws an
 IllegalArgumentException.
 <p>If the underlying method is an instance method, it is invoked
 using dynamic method lookup as documented in The Java Language
 Specification, section 15.11.4.4; in particular, overriding
 based on the runtime type of the target object will occur.
 <p>If the underlying method is static, it is invoked as exactly
 the method on the declaring class.
 <p>Control transfers to the underlying method.  If the method
 completes abruptly by throwing an exception, the exception is
 placed in an InvocationTargetException and thrown in turn to
 the caller of invoke.
 <p>If the method completes normally, the value it returns is
 returned to the caller of invoke; if the value has a primitive
 type, it is first appropriately wrapped in an object. If the
 underlying method return type is void, the invocation returns
 null.
<p>
  <dd><dl>
    <dt> <b>Throws:</b> <a href="java.lang.IllegalAccessException.html#_top_">IllegalAccessException</a>
    <dd> if the underlying method
              is inaccessible.
    <dt> <b>Throws:</b> <a href="java.lang.IllegalArgumentException.html#_top_">IllegalArgumentException</a>
    <dd> if the number of actual and formal
              parameters differ, or if an unwrapping conversion fails.
    <dt> <b>Throws:</b> <a href="java.lang.reflect.InvocationTargetException.html#_top_">InvocationTargetException</a>
    <dd> if the underlying method
              throws an exception.
    <dt> <b>Throws:</b> <a href="java.lang.NullPointerException.html#_top_">NullPointerException</a>
    <dd> if the specified object is null.
  </dl></dd>
</dl>
<hr>
<pre>
<a href="packages.html">All Packages</a>  <a href="tree.html">Class Hierarchy</a>  <a href="Package-java.lang.reflect.html">This Package</a>  <a href="java.lang.reflect.Field.html#_top_">Previous</a>  <a href="java.lang.reflect.Modifier.html#_top_">Next</a>  <a href="AllNames.html">Index</a></pre>
</body>
</html>
