src/java.base/share/classes/java/lang/reflect/Method.java
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File 8076112 Sdiff src/java.base/share/classes/java/lang/reflect

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

Print this page




   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
  23  * questions.
  24  */
  25 
  26 package java.lang.reflect;
  27 

  28 import sun.reflect.CallerSensitive;
  29 import sun.reflect.MethodAccessor;
  30 import sun.reflect.Reflection;
  31 import sun.reflect.generics.repository.MethodRepository;
  32 import sun.reflect.generics.factory.CoreReflectionFactory;
  33 import sun.reflect.generics.factory.GenericsFactory;
  34 import sun.reflect.generics.scope.MethodScope;
  35 import sun.reflect.annotation.AnnotationType;
  36 import sun.reflect.annotation.AnnotationParser;
  37 import java.lang.annotation.Annotation;
  38 import java.lang.annotation.AnnotationFormatError;
  39 import java.nio.ByteBuffer;
  40 
  41 /**
  42  * A {@code Method} provides information about, and access to, a single method
  43  * on a class or interface.  The reflected method may be a class method
  44  * or an instance method (including an abstract method).
  45  *
  46  * <p>A {@code Method} permits widening conversions to occur when matching the
  47  * actual parameters to invoke with the underlying method's formal


 468      *              is enforcing Java language access control and the underlying
 469      *              method is inaccessible.
 470      * @exception IllegalArgumentException  if the method is an
 471      *              instance method and the specified object argument
 472      *              is not an instance of the class or interface
 473      *              declaring the underlying method (or of a subclass
 474      *              or implementor thereof); if the number of actual
 475      *              and formal parameters differ; if an unwrapping
 476      *              conversion for primitive arguments fails; or if,
 477      *              after possible unwrapping, a parameter value
 478      *              cannot be converted to the corresponding formal
 479      *              parameter type by a method invocation conversion.
 480      * @exception InvocationTargetException if the underlying method
 481      *              throws an exception.
 482      * @exception NullPointerException      if the specified object is null
 483      *              and the method is an instance method.
 484      * @exception ExceptionInInitializerError if the initialization
 485      * provoked by this method fails.
 486      */
 487     @CallerSensitive

 488     public Object invoke(Object obj, Object... args)
 489         throws IllegalAccessException, IllegalArgumentException,
 490            InvocationTargetException
 491     {
 492         if (!override) {
 493             if (!Reflection.quickCheckMemberAccess(clazz, modifiers)) {
 494                 Class<?> caller = Reflection.getCallerClass();
 495                 checkAccess(caller, clazz, obj, modifiers);
 496             }
 497         }
 498         MethodAccessor ma = methodAccessor;             // read volatile
 499         if (ma == null) {
 500             ma = acquireMethodAccessor();
 501         }
 502         return ma.invoke(obj, args);
 503     }
 504 
 505     /**
 506      * Returns {@code true} if this method is a bridge
 507      * method; returns {@code false} otherwise.




   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
  23  * questions.
  24  */
  25 
  26 package java.lang.reflect;
  27 
  28 import jdk.internal.HotSpotIntrinsicCandidate;
  29 import sun.reflect.CallerSensitive;
  30 import sun.reflect.MethodAccessor;
  31 import sun.reflect.Reflection;
  32 import sun.reflect.generics.repository.MethodRepository;
  33 import sun.reflect.generics.factory.CoreReflectionFactory;
  34 import sun.reflect.generics.factory.GenericsFactory;
  35 import sun.reflect.generics.scope.MethodScope;
  36 import sun.reflect.annotation.AnnotationType;
  37 import sun.reflect.annotation.AnnotationParser;
  38 import java.lang.annotation.Annotation;
  39 import java.lang.annotation.AnnotationFormatError;
  40 import java.nio.ByteBuffer;
  41 
  42 /**
  43  * A {@code Method} provides information about, and access to, a single method
  44  * on a class or interface.  The reflected method may be a class method
  45  * or an instance method (including an abstract method).
  46  *
  47  * <p>A {@code Method} permits widening conversions to occur when matching the
  48  * actual parameters to invoke with the underlying method's formal


 469      *              is enforcing Java language access control and the underlying
 470      *              method is inaccessible.
 471      * @exception IllegalArgumentException  if the method is an
 472      *              instance method and the specified object argument
 473      *              is not an instance of the class or interface
 474      *              declaring the underlying method (or of a subclass
 475      *              or implementor thereof); if the number of actual
 476      *              and formal parameters differ; if an unwrapping
 477      *              conversion for primitive arguments fails; or if,
 478      *              after possible unwrapping, a parameter value
 479      *              cannot be converted to the corresponding formal
 480      *              parameter type by a method invocation conversion.
 481      * @exception InvocationTargetException if the underlying method
 482      *              throws an exception.
 483      * @exception NullPointerException      if the specified object is null
 484      *              and the method is an instance method.
 485      * @exception ExceptionInInitializerError if the initialization
 486      * provoked by this method fails.
 487      */
 488     @CallerSensitive
 489     @HotSpotIntrinsicCandidate
 490     public Object invoke(Object obj, Object... args)
 491         throws IllegalAccessException, IllegalArgumentException,
 492            InvocationTargetException
 493     {
 494         if (!override) {
 495             if (!Reflection.quickCheckMemberAccess(clazz, modifiers)) {
 496                 Class<?> caller = Reflection.getCallerClass();
 497                 checkAccess(caller, clazz, obj, modifiers);
 498             }
 499         }
 500         MethodAccessor ma = methodAccessor;             // read volatile
 501         if (ma == null) {
 502             ma = acquireMethodAccessor();
 503         }
 504         return ma.invoke(obj, args);
 505     }
 506 
 507     /**
 508      * Returns {@code true} if this method is a bridge
 509      * method; returns {@code false} otherwise.


src/java.base/share/classes/java/lang/reflect/Method.java
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File