jdk/src/java.base/share/classes/java/lang/reflect/Constructor.java
changeset 25991 e48157b42439
parent 25982 724303cf59ba
parent 25859 3317bb8137f4
child 26455 195a6f3e0cd0
equal deleted inserted replaced
25876:d06a6d3c66c0 25991:e48157b42439
   542      * {@inheritDoc}
   542      * {@inheritDoc}
   543      * @since 1.8
   543      * @since 1.8
   544      */
   544      */
   545     @Override
   545     @Override
   546     public AnnotatedType getAnnotatedReceiverType() {
   546     public AnnotatedType getAnnotatedReceiverType() {
   547         if (getDeclaringClass().getEnclosingClass() == null)
   547         Class<?> thisDeclClass = getDeclaringClass();
   548             return super.getAnnotatedReceiverType();
   548         Class<?> enclosingClass = thisDeclClass.getEnclosingClass();
   549 
   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
   550         return TypeAnnotationParser.buildAnnotatedType(getTypeAnnotationBytes0(),
   568         return TypeAnnotationParser.buildAnnotatedType(getTypeAnnotationBytes0(),
   551                 sun.misc.SharedSecrets.getJavaLangAccess().
   569                 sun.misc.SharedSecrets.getJavaLangAccess().
   552                         getConstantPool(getDeclaringClass()),
   570                     getConstantPool(thisDeclClass),
   553                 this,
   571                 this,
   554                 getDeclaringClass(),
   572                 thisDeclClass,
   555                 getDeclaringClass().getEnclosingClass(),
   573                 enclosingClass,
   556                 TypeAnnotation.TypeAnnotationTarget.METHOD_RECEIVER);
   574                 TypeAnnotation.TypeAnnotationTarget.METHOD_RECEIVER);
   557     }
   575     }
   558 }
   576 }