< prev index next >

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

Print this page




 534      * are neither implicitly nor explicitly declared in source
 535      * ("synthetic") to the parameter list for a method.  See {@link
 536      * java.lang.reflect.Parameter} for more information.
 537      *
 538      * @see java.lang.reflect.Parameter
 539      * @see java.lang.reflect.Parameter#getAnnotations
 540      * @return an array of arrays that represent the annotations on
 541      *    the formal and implicit parameters, in declaration order, of
 542      *    the executable represented by this object
 543      */
 544     public abstract Annotation[][] getParameterAnnotations();
 545 
 546     Annotation[][] sharedGetParameterAnnotations(Class<?>[] parameterTypes,
 547                                                  byte[] parameterAnnotations) {
 548         int numParameters = parameterTypes.length;
 549         if (parameterAnnotations == null)
 550             return new Annotation[numParameters][0];
 551 
 552         Annotation[][] result = parseParameterAnnotations(parameterAnnotations);
 553 
 554         if (result.length != numParameters)
 555             handleParameterNumberMismatch(result.length, numParameters);






 556         return result;
 557     }
 558 
 559     abstract void handleParameterNumberMismatch(int resultLength, int numParameters);
 560 
 561     /**
 562      * {@inheritDoc}
 563      * @throws NullPointerException  {@inheritDoc}
 564      */
 565     public <T extends Annotation> T getAnnotation(Class<T> annotationClass) {
 566         Objects.requireNonNull(annotationClass);
 567         return annotationClass.cast(declaredAnnotations().get(annotationClass));
 568     }
 569 
 570     /**
 571      * {@inheritDoc}
 572      * @throws NullPointerException {@inheritDoc}
 573      */
 574     @Override
 575     public <T extends Annotation> T[] getAnnotationsByType(Class<T> annotationClass) {
 576         Objects.requireNonNull(annotationClass);
 577 
 578         return AnnotationSupport.getDirectlyAndIndirectlyPresent(declaredAnnotations(), annotationClass);
 579     }




 534      * are neither implicitly nor explicitly declared in source
 535      * ("synthetic") to the parameter list for a method.  See {@link
 536      * java.lang.reflect.Parameter} for more information.
 537      *
 538      * @see java.lang.reflect.Parameter
 539      * @see java.lang.reflect.Parameter#getAnnotations
 540      * @return an array of arrays that represent the annotations on
 541      *    the formal and implicit parameters, in declaration order, of
 542      *    the executable represented by this object
 543      */
 544     public abstract Annotation[][] getParameterAnnotations();
 545 
 546     Annotation[][] sharedGetParameterAnnotations(Class<?>[] parameterTypes,
 547                                                  byte[] parameterAnnotations) {
 548         int numParameters = parameterTypes.length;
 549         if (parameterAnnotations == null)
 550             return new Annotation[numParameters][0];
 551 
 552         Annotation[][] result = parseParameterAnnotations(parameterAnnotations);
 553 
 554         if (result.length != numParameters &&
 555             handleParameterNumberMismatch(result.length, numParameters)) {
 556             Annotation[][] tmp = new Annotation[result.length+1][];
 557             // Shift annotations down one to account for an implicit leading parameter
 558             System.arraycopy(result, 0, tmp, 1, result.length);
 559             tmp[0] = new Annotation[0];
 560             result = tmp;
 561         }
 562         return result;
 563     }
 564 
 565     abstract boolean handleParameterNumberMismatch(int resultLength, int numParameters);
 566 
 567     /**
 568      * {@inheritDoc}
 569      * @throws NullPointerException  {@inheritDoc}
 570      */
 571     public <T extends Annotation> T getAnnotation(Class<T> annotationClass) {
 572         Objects.requireNonNull(annotationClass);
 573         return annotationClass.cast(declaredAnnotations().get(annotationClass));
 574     }
 575 
 576     /**
 577      * {@inheritDoc}
 578      * @throws NullPointerException {@inheritDoc}
 579      */
 580     @Override
 581     public <T extends Annotation> T[] getAnnotationsByType(Class<T> annotationClass) {
 582         Objects.requireNonNull(annotationClass);
 583 
 584         return AnnotationSupport.getDirectlyAndIndirectlyPresent(declaredAnnotations(), annotationClass);
 585     }


< prev index next >