src/share/classes/java/lang/reflect/Constructor.java

Print this page
rev 10097 : 8044629: (reflect) Constructor.getAnnotatedReceiverType() returns wrong value
Reviewed-by: duke


 527                           "Parameter annotations don't match number of parameters");
 528             }
 529         }
 530     }
 531 
 532     /**
 533      * {@inheritDoc}
 534      * @since 1.8
 535      */
 536     @Override
 537     public AnnotatedType getAnnotatedReturnType() {
 538         return getAnnotatedReturnType0(getDeclaringClass());
 539     }
 540 
 541     /**
 542      * {@inheritDoc}
 543      * @since 1.8
 544      */
 545     @Override
 546     public AnnotatedType getAnnotatedReceiverType() {
 547         if (getDeclaringClass().getEnclosingClass() == null)
 548             return super.getAnnotatedReceiverType();
 549 


















 550         return TypeAnnotationParser.buildAnnotatedType(getTypeAnnotationBytes0(),
 551                 sun.misc.SharedSecrets.getJavaLangAccess().
 552                         getConstantPool(getDeclaringClass()),
 553                 this,
 554                 getDeclaringClass(),
 555                 getDeclaringClass().getEnclosingClass(),
 556                 TypeAnnotation.TypeAnnotationTarget.METHOD_RECEIVER);
 557     }
 558 }


 527                           "Parameter annotations don't match number of parameters");
 528             }
 529         }
 530     }
 531 
 532     /**
 533      * {@inheritDoc}
 534      * @since 1.8
 535      */
 536     @Override
 537     public AnnotatedType getAnnotatedReturnType() {
 538         return getAnnotatedReturnType0(getDeclaringClass());
 539     }
 540 
 541     /**
 542      * {@inheritDoc}
 543      * @since 1.8
 544      */
 545     @Override
 546     public AnnotatedType getAnnotatedReceiverType() {
 547         Class<?> thisDeclClass = getDeclaringClass();
 548         Class<?> enclosingClass = thisDeclClass.getEnclosingClass();
 549 
 550         if (enclosingClass == null) {
 551             // A Constructor for a top-level class
 552             return null;
 553         }
 554 
 555         Class<?> outerDeclaringClass = thisDeclClass.getDeclaringClass();
 556         if (outerDeclaringClass == null) {
 557             // A constructor for a local or anonymous class
 558             return null;
 559         }
 560 
 561         // Either static nested or inner class
 562         if (Modifier.isStatic(thisDeclClass.getModifiers())) {
 563             // static nested
 564             return null;
 565         }
 566 
 567         // A Constructor for an inner class
 568         return TypeAnnotationParser.buildAnnotatedType(getTypeAnnotationBytes0(),
 569                 sun.misc.SharedSecrets.getJavaLangAccess().
 570                     getConstantPool(thisDeclClass),
 571                 this,
 572                 thisDeclClass,
 573                 enclosingClass,
 574                 TypeAnnotation.TypeAnnotationTarget.METHOD_RECEIVER);
 575     }
 576 }