src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Annotate.java
changeset 58713 ad69fd32778e
parent 52777 7d3391e9df19
child 58906 d58a21542c04
equal deleted inserted replaced
58712:14e098407bb0 58713:ad69fd32778e
   362             // Note: @Deprecated has no effect on local variables and parameters
   362             // Note: @Deprecated has no effect on local variables and parameters
   363             if (!c.type.isErroneous()
   363             if (!c.type.isErroneous()
   364                     && (toAnnotate.kind == MDL || toAnnotate.owner.kind != MTH)
   364                     && (toAnnotate.kind == MDL || toAnnotate.owner.kind != MTH)
   365                     && types.isSameType(c.type, syms.deprecatedType)) {
   365                     && types.isSameType(c.type, syms.deprecatedType)) {
   366                 toAnnotate.flags_field |= (Flags.DEPRECATED | Flags.DEPRECATED_ANNOTATION);
   366                 toAnnotate.flags_field |= (Flags.DEPRECATED | Flags.DEPRECATED_ANNOTATION);
   367                 Attribute fr = c.member(names.forRemoval);
   367                 if (isAttributeTrue(c.member(names.forRemoval))) {
   368                 if (fr instanceof Attribute.Constant) {
   368                     toAnnotate.flags_field |= Flags.DEPRECATED_REMOVAL;
   369                     Attribute.Constant v = (Attribute.Constant) fr;
   369                 }
   370                     if (v.type == syms.booleanType && ((Integer) v.value) != 0) {
   370             }
   371                         toAnnotate.flags_field |= Flags.DEPRECATED_REMOVAL;
   371 
   372                     }
   372             // Note: @Deprecated has no effect on local variables and parameters
       
   373             if (!c.type.isErroneous()
       
   374                     && types.isSameType(c.type, syms.previewFeatureType)) {
       
   375                 toAnnotate.flags_field |= Flags.PREVIEW_API;
       
   376                 if (isAttributeTrue(c.member(names.essentialAPI))) {
       
   377                     toAnnotate.flags_field |= Flags.PREVIEW_ESSENTIAL_API;
   373                 }
   378                 }
   374             }
   379             }
   375         }
   380         }
   376 
   381 
   377         List<T> buf = List.nil();
   382         List<T> buf = List.nil();
   395             List<Attribute.Compound> attrs =  (List<Attribute.Compound>)buf.reverse();
   400             List<Attribute.Compound> attrs =  (List<Attribute.Compound>)buf.reverse();
   396             toAnnotate.resetAnnotations();
   401             toAnnotate.resetAnnotations();
   397             toAnnotate.setDeclarationAttributes(attrs);
   402             toAnnotate.setDeclarationAttributes(attrs);
   398         }
   403         }
   399     }
   404     }
       
   405     //where:
       
   406         private boolean isAttributeTrue(Attribute attr) {
       
   407             if (attr instanceof Attribute.Constant) {
       
   408                 Attribute.Constant v = (Attribute.Constant) attr;
       
   409                 if (v.type == syms.booleanType && ((Integer) v.value) != 0) {
       
   410                     return true;
       
   411                 }
       
   412             }
       
   413             return false;
       
   414         }
   400 
   415 
   401     /**
   416     /**
   402      * Attribute and store a semantic representation of the annotation tree {@code tree} into the
   417      * Attribute and store a semantic representation of the annotation tree {@code tree} into the
   403      * tree.attribute field.
   418      * tree.attribute field.
   404      *
   419      *