< 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--;

 358                 toAnnotate.flags_field |= (Flags.DEPRECATED | Flags.DEPRECATED_ANNOTATION);
 359                 if (isAttributeTrue(c.member(names.forRemoval))) {
 360                     toAnnotate.flags_field |= Flags.DEPRECATED_REMOVAL;
 361                 }
 362             }
 363 
 364             if (!c.type.isErroneous()
 365                     && types.isSameType(c.type, syms.previewFeatureType)) {
 366                 toAnnotate.flags_field |= Flags.PREVIEW_API;
 367                 if (isAttributeTrue(c.member(names.reflective))) {
 368                     toAnnotate.flags_field |= Flags.PREVIEW_REFLECTIVE;
 369                 }
 370             }
 371 
 372             if (!c.type.isErroneous()
 373                     && toAnnotate.kind == TYP
 374                     && types.isSameType(c.type, syms.valueBasedType)) {
 375                 toAnnotate.flags_field |= Flags.VALUE_BASED;
 376             }
 377 
















 378             if (!c.type.isErroneous()
 379                     && types.isSameType(c.type, syms.restrictedType)) {
 380                 toAnnotate.flags_field |= Flags.RESTRICTED;
 381             }
 382 
 383             if (!c.type.isErroneous()
 384                     && toAnnotate.kind == VAR
 385                     && types.isSameType(c.type, syms.requiresIdentityType)) {
 386                 toAnnotate.flags_field |= Flags.REQUIRES_IDENTITY;
 387             }
 388         }
 389 
 390         List<T> buf = List.nil();
 391         for (ListBuffer<T> lb : annotated.values()) {
 392             if (lb.size() == 1) {
 393                 buf = buf.prepend(lb.first());
 394             } else {
 395                 AnnotationContext<T> ctx = new AnnotationContext<>(env, annotated, pos, typeAnnotations);
 396                 T res = makeContainerAnnotation(lb.toList(), ctx, toAnnotate, isTypeParam);
 397                 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--;

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