< prev index next >

src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Annotate.java

Print this page

  80     protected static final Context.Key<Annotate> annotateKey = new Context.Key<>();
  81 
  82     public static Annotate instance(Context context) {
  83         Annotate instance = context.get(annotateKey);
  84         if (instance == null)
  85             instance = new Annotate(context);
  86         return instance;
  87     }
  88 
  89     private final Attr attr;
  90     private final Check chk;
  91     private final ConstFold cfolder;
  92     private final Enter enter;
  93     private final Log log;
  94     private final Names names;
  95     private final Resolve resolve;
  96     private final TreeMaker make;
  97     private final Symtab syms;
  98     private final TypeEnvs typeEnvs;
  99     private final Types types;

 100 
 101     private final Attribute theUnfinishedDefaultValue;
 102     private final String sourceName;
 103 
 104     @SuppressWarnings("this-escape")
 105     protected Annotate(Context context) {
 106         context.put(annotateKey, this);
 107 
 108         attr = Attr.instance(context);
 109         chk = Check.instance(context);
 110         cfolder = ConstFold.instance(context);
 111         enter = Enter.instance(context);
 112         log = Log.instance(context);
 113         make = TreeMaker.instance(context);
 114         names = Names.instance(context);
 115         resolve = Resolve.instance(context);
 116         syms = Symtab.instance(context);
 117         typeEnvs = TypeEnvs.instance(context);
 118         types = Types.instance(context);

 119 
 120         theUnfinishedDefaultValue =  new Attribute.Error(syms.errType);
 121 
 122         Source source = Source.instance(context);
 123         sourceName = source.name;
 124 
 125         blockCount = 1;
 126     }
 127 
 128     /** Semaphore to delay annotation processing */
 129     private int blockCount = 0;
 130 
 131     /** Called when annotations processing needs to be postponed. */
 132     public void blockAnnotations() {
 133         blockCount++;
 134     }
 135 
 136     /** Called when annotation processing can be resumed. */
 137     public void unblockAnnotations() {
 138         blockCount--;

 351                 toAnnotate.flags_field |= (Flags.DEPRECATED | Flags.DEPRECATED_ANNOTATION);
 352                 if (isAttributeTrue(c.member(names.forRemoval))) {
 353                     toAnnotate.flags_field |= Flags.DEPRECATED_REMOVAL;
 354                 }
 355             }
 356 
 357             if (!c.type.isErroneous()
 358                     && types.isSameType(c.type, syms.previewFeatureType)) {
 359                 toAnnotate.flags_field |= Flags.PREVIEW_API;
 360                 if (isAttributeTrue(c.member(names.reflective))) {
 361                     toAnnotate.flags_field |= Flags.PREVIEW_REFLECTIVE;
 362                 }
 363             }
 364 
 365             if (!c.type.isErroneous()
 366                     && toAnnotate.kind == TYP
 367                     && types.isSameType(c.type, syms.valueBasedType)) {
 368                 toAnnotate.flags_field |= Flags.VALUE_BASED;
 369             }
 370 
















 371             if (!c.type.isErroneous()
 372                     && types.isSameType(c.type, syms.restrictedType)) {
 373                 toAnnotate.flags_field |= Flags.RESTRICTED;
 374             }
 375 
 376             if (!c.type.isErroneous()
 377                     && toAnnotate.kind == VAR
 378                     && types.isSameType(c.type, syms.requiresIdentityType)) {
 379                 toAnnotate.flags_field |= Flags.REQUIRES_IDENTITY;
 380             }
 381         }
 382 
 383         List<T> buf = List.nil();
 384         for (ListBuffer<T> lb : annotated.values()) {
 385             if (lb.size() == 1) {
 386                 buf = buf.prepend(lb.first());
 387             } else {
 388                 AnnotationContext<T> ctx = new AnnotationContext<>(env, annotated, pos, typeAnnotations);
 389                 T res = makeContainerAnnotation(lb.toList(), ctx, toAnnotate, isTypeParam);
 390                 if (res != null)

  80     protected static final Context.Key<Annotate> annotateKey = new Context.Key<>();
  81 
  82     public static Annotate instance(Context context) {
  83         Annotate instance = context.get(annotateKey);
  84         if (instance == null)
  85             instance = new Annotate(context);
  86         return instance;
  87     }
  88 
  89     private final Attr attr;
  90     private final Check chk;
  91     private final ConstFold cfolder;
  92     private final Enter enter;
  93     private final Log log;
  94     private final Names names;
  95     private final Resolve resolve;
  96     private final TreeMaker make;
  97     private final Symtab syms;
  98     private final TypeEnvs typeEnvs;
  99     private final Types types;
 100     private final Preview preview;
 101 
 102     private final Attribute theUnfinishedDefaultValue;
 103     private final String sourceName;
 104 
 105     @SuppressWarnings("this-escape")
 106     protected Annotate(Context context) {
 107         context.put(annotateKey, this);
 108 
 109         attr = Attr.instance(context);
 110         chk = Check.instance(context);
 111         cfolder = ConstFold.instance(context);
 112         enter = Enter.instance(context);
 113         log = Log.instance(context);
 114         make = TreeMaker.instance(context);
 115         names = Names.instance(context);
 116         resolve = Resolve.instance(context);
 117         syms = Symtab.instance(context);
 118         typeEnvs = TypeEnvs.instance(context);
 119         types = Types.instance(context);
 120         preview = Preview.instance(context);
 121 
 122         theUnfinishedDefaultValue =  new Attribute.Error(syms.errType);
 123 
 124         Source source = Source.instance(context);
 125         sourceName = source.name;
 126 
 127         blockCount = 1;
 128     }
 129 
 130     /** Semaphore to delay annotation processing */
 131     private int blockCount = 0;
 132 
 133     /** Called when annotations processing needs to be postponed. */
 134     public void blockAnnotations() {
 135         blockCount++;
 136     }
 137 
 138     /** Called when annotation processing can be resumed. */
 139     public void unblockAnnotations() {
 140         blockCount--;

 353                 toAnnotate.flags_field |= (Flags.DEPRECATED | Flags.DEPRECATED_ANNOTATION);
 354                 if (isAttributeTrue(c.member(names.forRemoval))) {
 355                     toAnnotate.flags_field |= Flags.DEPRECATED_REMOVAL;
 356                 }
 357             }
 358 
 359             if (!c.type.isErroneous()
 360                     && types.isSameType(c.type, syms.previewFeatureType)) {
 361                 toAnnotate.flags_field |= Flags.PREVIEW_API;
 362                 if (isAttributeTrue(c.member(names.reflective))) {
 363                     toAnnotate.flags_field |= Flags.PREVIEW_REFLECTIVE;
 364                 }
 365             }
 366 
 367             if (!c.type.isErroneous()
 368                     && toAnnotate.kind == TYP
 369                     && types.isSameType(c.type, syms.valueBasedType)) {
 370                 toAnnotate.flags_field |= Flags.VALUE_BASED;
 371             }
 372 
 373             if (!c.type.isErroneous()
 374                     && toAnnotate.kind == TYP
 375                     && types.isSameType(c.type, syms.migratedValueClassType)) {
 376                 toAnnotate.flags_field |= Flags.MIGRATED_VALUE_CLASS;
 377             }
 378 
 379             if (!c.type.isErroneous()
 380                     && toAnnotate.kind == VAR
 381                     && toAnnotate.owner.kind == TYP
 382                     && types.isSameType(c.type, syms.strictType)) {
 383                 preview.checkSourceLevel(pos.get(c), Feature.VALUE_CLASSES);
 384                 toAnnotate.flags_field |= Flags.STRICT;
 385                 // temporary hack to indicate that a class has at least one strict field
 386                 toAnnotate.owner.flags_field |= Flags.HAS_STRICT;
 387             }
 388 
 389             if (!c.type.isErroneous()
 390                     && types.isSameType(c.type, syms.restrictedType)) {
 391                 toAnnotate.flags_field |= Flags.RESTRICTED;
 392             }
 393 
 394             if (!c.type.isErroneous()
 395                     && toAnnotate.kind == VAR
 396                     && types.isSameType(c.type, syms.requiresIdentityType)) {
 397                 toAnnotate.flags_field |= Flags.REQUIRES_IDENTITY;
 398             }
 399         }
 400 
 401         List<T> buf = List.nil();
 402         for (ListBuffer<T> lb : annotated.values()) {
 403             if (lb.size() == 1) {
 404                 buf = buf.prepend(lb.first());
 405             } else {
 406                 AnnotationContext<T> ctx = new AnnotationContext<>(env, annotated, pos, typeAnnotations);
 407                 T res = makeContainerAnnotation(lb.toList(), ctx, toAnnotate, isTypeParam);
 408                 if (res != null)
< prev index next >