< prev index next >

src/java.base/share/classes/java/lang/reflect/Method.java

Print this page


   1 /*
   2  * Copyright (c) 1996, 2017, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


 491         sb.append(getDeclaringClass().getTypeName()).append('.');
 492         sb.append(getName());
 493     }
 494 
 495     /**
 496      * Invokes the underlying method represented by this {@code Method}
 497      * object, on the specified object with the specified parameters.
 498      * Individual parameters are automatically unwrapped to match
 499      * primitive formal parameters, and both primitive and reference
 500      * parameters are subject to method invocation conversions as
 501      * necessary.
 502      *
 503      * <p>If the underlying method is static, then the specified {@code obj}
 504      * argument is ignored. It may be null.
 505      *
 506      * <p>If the number of formal parameters required by the underlying method is
 507      * 0, the supplied {@code args} array may be of length 0 or null.
 508      *
 509      * <p>If the underlying method is an instance method, it is invoked
 510      * using dynamic method lookup as documented in The Java Language
 511      * Specification, Second Edition, section 15.12.4.4; in particular,
 512      * overriding based on the runtime type of the target object will occur.
 513      *
 514      * <p>If the underlying method is static, the class that declared
 515      * the method is initialized if it has not already been initialized.
 516      *
 517      * <p>If the method completes normally, the value it returns is
 518      * returned to the caller of invoke; if the value has a primitive
 519      * type, it is first appropriately wrapped in an object. However,
 520      * if the value has the type of an array of a primitive type, the
 521      * elements of the array are <i>not</i> wrapped in objects; in
 522      * other words, an array of primitive type is returned.  If the
 523      * underlying method return type is void, the invocation returns
 524      * null.
 525      *
 526      * @param obj  the object the underlying method is invoked from
 527      * @param args the arguments used for the method call
 528      * @return the result of dispatching the method represented by
 529      * this object on {@code obj} with parameters
 530      * {@code args}
 531      *
 532      * @exception IllegalAccessException    if this {@code Method} object


   1 /*
   2  * Copyright (c) 1996, 2018, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


 491         sb.append(getDeclaringClass().getTypeName()).append('.');
 492         sb.append(getName());
 493     }
 494 
 495     /**
 496      * Invokes the underlying method represented by this {@code Method}
 497      * object, on the specified object with the specified parameters.
 498      * Individual parameters are automatically unwrapped to match
 499      * primitive formal parameters, and both primitive and reference
 500      * parameters are subject to method invocation conversions as
 501      * necessary.
 502      *
 503      * <p>If the underlying method is static, then the specified {@code obj}
 504      * argument is ignored. It may be null.
 505      *
 506      * <p>If the number of formal parameters required by the underlying method is
 507      * 0, the supplied {@code args} array may be of length 0 or null.
 508      *
 509      * <p>If the underlying method is an instance method, it is invoked
 510      * using dynamic method lookup as documented in The Java Language
 511      * Specification, section 15.12.4.4; in particular,
 512      * overriding based on the runtime type of the target object may occur.
 513      *
 514      * <p>If the underlying method is static, the class that declared
 515      * the method is initialized if it has not already been initialized.
 516      *
 517      * <p>If the method completes normally, the value it returns is
 518      * returned to the caller of invoke; if the value has a primitive
 519      * type, it is first appropriately wrapped in an object. However,
 520      * if the value has the type of an array of a primitive type, the
 521      * elements of the array are <i>not</i> wrapped in objects; in
 522      * other words, an array of primitive type is returned.  If the
 523      * underlying method return type is void, the invocation returns
 524      * null.
 525      *
 526      * @param obj  the object the underlying method is invoked from
 527      * @param args the arguments used for the method call
 528      * @return the result of dispatching the method represented by
 529      * this object on {@code obj} with parameters
 530      * {@code args}
 531      *
 532      * @exception IllegalAccessException    if this {@code Method} object


< prev index next >