src/jdk.compiler/share/classes/com/sun/tools/javac/comp/TypeEnter.java
changeset 58713 ad69fd32778e
parent 53275 f5e601ad26a8
equal deleted inserted replaced
58712:14e098407bb0 58713:ad69fd32778e
  1154     private void handleDeprecatedAnnotations(List<JCAnnotation> annotations, Symbol sym) {
  1154     private void handleDeprecatedAnnotations(List<JCAnnotation> annotations, Symbol sym) {
  1155         for (List<JCAnnotation> al = annotations; !al.isEmpty(); al = al.tail) {
  1155         for (List<JCAnnotation> al = annotations; !al.isEmpty(); al = al.tail) {
  1156             JCAnnotation a = al.head;
  1156             JCAnnotation a = al.head;
  1157             if (a.annotationType.type == syms.deprecatedType) {
  1157             if (a.annotationType.type == syms.deprecatedType) {
  1158                 sym.flags_field |= (Flags.DEPRECATED | Flags.DEPRECATED_ANNOTATION);
  1158                 sym.flags_field |= (Flags.DEPRECATED | Flags.DEPRECATED_ANNOTATION);
  1159                 a.args.stream()
  1159                 setFlagIfAttributeTrue(a, sym, names.forRemoval, DEPRECATED_REMOVAL);
  1160                         .filter(e -> e.hasTag(ASSIGN))
  1160             } else if (a.annotationType.type == syms.previewFeatureType) {
  1161                         .map(e -> (JCAssign) e)
  1161                 sym.flags_field |= Flags.PREVIEW_API;
  1162                         .filter(assign -> TreeInfo.name(assign.lhs) == names.forRemoval)
  1162                 setFlagIfAttributeTrue(a, sym, names.essentialAPI, PREVIEW_ESSENTIAL_API);
  1163                         .findFirst()
  1163             }
  1164                         .ifPresent(assign -> {
  1164         }
  1165                             JCExpression rhs = TreeInfo.skipParens(assign.rhs);
  1165     }
  1166                             if (rhs.hasTag(LITERAL)
  1166     //where:
  1167                                     && Boolean.TRUE.equals(((JCLiteral) rhs).getValue())) {
  1167         private void setFlagIfAttributeTrue(JCAnnotation a, Symbol sym, Name attribute, long flag) {
  1168                                 sym.flags_field |= DEPRECATED_REMOVAL;
  1168             a.args.stream()
  1169                             }
  1169                     .filter(e -> e.hasTag(ASSIGN))
  1170                         });
  1170                     .map(e -> (JCAssign) e)
  1171             }
  1171                     .filter(assign -> TreeInfo.name(assign.lhs) == attribute)
  1172         }
  1172                     .findFirst()
  1173     }
  1173                     .ifPresent(assign -> {
       
  1174                         JCExpression rhs = TreeInfo.skipParens(assign.rhs);
       
  1175                         if (rhs.hasTag(LITERAL)
       
  1176                                 && Boolean.TRUE.equals(((JCLiteral) rhs).getValue())) {
       
  1177                             sym.flags_field |= flag;
       
  1178                         }
       
  1179                     });
       
  1180         }
  1174 }
  1181 }