< prev index next >

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

Print this page




 509      *              conversion for primitive arguments fails; or if,
 510      *              after possible unwrapping, a parameter value
 511      *              cannot be converted to the corresponding formal
 512      *              parameter type by a method invocation conversion.
 513      * @exception InvocationTargetException if the underlying method
 514      *              throws an exception.
 515      * @exception NullPointerException      if the specified object is null
 516      *              and the method is an instance method.
 517      * @exception ExceptionInInitializerError if the initialization
 518      * provoked by this method fails.
 519      */
 520     @CallerSensitive
 521     @ForceInline // to ensure Reflection.getCallerClass optimization
 522     @HotSpotIntrinsicCandidate
 523     public Object invoke(Object obj, Object... args)
 524         throws IllegalAccessException, IllegalArgumentException,
 525            InvocationTargetException
 526     {
 527         if (!override) {
 528             Class<?> caller = Reflection.getCallerClass();
 529             checkAccess(caller, clazz, obj, modifiers);


 530         }
 531         MethodAccessor ma = methodAccessor;             // read volatile
 532         if (ma == null) {
 533             ma = acquireMethodAccessor();
 534         }
 535         return ma.invoke(obj, args);
 536     }
 537 
 538     /**
 539      * Returns {@code true} if this method is a bridge
 540      * method; returns {@code false} otherwise.
 541      *
 542      * @return true if and only if this method is a bridge
 543      * method as defined by the Java Language Specification.
 544      * @since 1.5
 545      */
 546     public boolean isBridge() {
 547         return (getModifiers() & Modifier.BRIDGE) != 0;
 548     }
 549 




 509      *              conversion for primitive arguments fails; or if,
 510      *              after possible unwrapping, a parameter value
 511      *              cannot be converted to the corresponding formal
 512      *              parameter type by a method invocation conversion.
 513      * @exception InvocationTargetException if the underlying method
 514      *              throws an exception.
 515      * @exception NullPointerException      if the specified object is null
 516      *              and the method is an instance method.
 517      * @exception ExceptionInInitializerError if the initialization
 518      * provoked by this method fails.
 519      */
 520     @CallerSensitive
 521     @ForceInline // to ensure Reflection.getCallerClass optimization
 522     @HotSpotIntrinsicCandidate
 523     public Object invoke(Object obj, Object... args)
 524         throws IllegalAccessException, IllegalArgumentException,
 525            InvocationTargetException
 526     {
 527         if (!override) {
 528             Class<?> caller = Reflection.getCallerClass();
 529             checkAccess(caller, clazz,
 530                         Modifier.isStatic(modifiers) ? null : obj.getClass(),
 531                         modifiers);
 532         }
 533         MethodAccessor ma = methodAccessor;             // read volatile
 534         if (ma == null) {
 535             ma = acquireMethodAccessor();
 536         }
 537         return ma.invoke(obj, args);
 538     }
 539 
 540     /**
 541      * Returns {@code true} if this method is a bridge
 542      * method; returns {@code false} otherwise.
 543      *
 544      * @return true if and only if this method is a bridge
 545      * method as defined by the Java Language Specification.
 546      * @since 1.5
 547      */
 548     public boolean isBridge() {
 549         return (getModifiers() & Modifier.BRIDGE) != 0;
 550     }
 551 


< prev index next >