< prev index next >

src/jdk.compiler/share/classes/com/sun/tools/javac/code/Flags.java

Print this page




 307      * Flag to indicate the given PackageSymbol contains any non-.java and non-.class resources.
 308      */
 309     public static final long HAS_RESOURCE = 1L<<56;
 310 
 311     /**
 312      * Flag for synthesized default constructors of anonymous classes that have an enclosing expression.
 313      */
 314     public static final long ANONCONSTR_BASED = 1L<<57;
 315 
 316     /**
 317      * Flag that marks finalize block as body-only, should not be copied into catch clauses.
 318      * Used to implement try-with-resources.
 319      */
 320     public static final long BODY_ONLY_FINALIZE = 1L<<17; //blocks only
 321 
 322     /**
 323      * Flag to indicate the given ParamSymbol has a user-friendly name filled.
 324      */
 325     public static final long NAME_FILLED = 1L<<58; //ParamSymbols only
 326 


























 327     /** Modifier masks.
 328      */
 329     public static final int
 330         AccessFlags           = PUBLIC | PROTECTED | PRIVATE,
 331         LocalClassFlags       = FINAL | ABSTRACT | STRICTFP | ENUM | SYNTHETIC,

 332         MemberClassFlags      = LocalClassFlags | INTERFACE | AccessFlags,

 333         ClassFlags            = LocalClassFlags | INTERFACE | PUBLIC | ANNOTATION,
 334         InterfaceVarFlags     = FINAL | STATIC | PUBLIC,
 335         VarFlags              = AccessFlags | FINAL | STATIC |
 336                                 VOLATILE | TRANSIENT | ENUM,
 337         ConstructorFlags      = AccessFlags,
 338         InterfaceMethodFlags  = ABSTRACT | PUBLIC,
 339         MethodFlags           = AccessFlags | ABSTRACT | STATIC | NATIVE |
 340                                 SYNCHRONIZED | FINAL | STRICTFP;
 341     public static final long
 342         ExtendedStandardFlags       = (long)StandardFlags | DEFAULT,
 343         ModifierFlags               = ((long)StandardFlags & ~INTERFACE) | DEFAULT,





 344         InterfaceMethodMask         = ABSTRACT | PRIVATE | STATIC | PUBLIC | STRICTFP | DEFAULT,
 345         AnnotationTypeElementMask   = ABSTRACT | PUBLIC,
 346         LocalVarFlags               = FINAL | PARAMETER,
 347         ReceiverParamFlags          = PARAMETER;
 348 
 349 
 350     public static Set<Modifier> asModifierSet(long flags) {
 351         Set<Modifier> modifiers = modifierSets.get(flags);
 352         if (modifiers == null) {
 353             modifiers = java.util.EnumSet.noneOf(Modifier.class);
 354             if (0 != (flags & PUBLIC))    modifiers.add(Modifier.PUBLIC);
 355             if (0 != (flags & PROTECTED)) modifiers.add(Modifier.PROTECTED);
 356             if (0 != (flags & PRIVATE))   modifiers.add(Modifier.PRIVATE);
 357             if (0 != (flags & ABSTRACT))  modifiers.add(Modifier.ABSTRACT);
 358             if (0 != (flags & STATIC))    modifiers.add(Modifier.STATIC);

 359             if (0 != (flags & FINAL))     modifiers.add(Modifier.FINAL);
 360             if (0 != (flags & TRANSIENT)) modifiers.add(Modifier.TRANSIENT);
 361             if (0 != (flags & VOLATILE))  modifiers.add(Modifier.VOLATILE);
 362             if (0 != (flags & SYNCHRONIZED))
 363                                           modifiers.add(Modifier.SYNCHRONIZED);
 364             if (0 != (flags & NATIVE))    modifiers.add(Modifier.NATIVE);
 365             if (0 != (flags & STRICTFP))  modifiers.add(Modifier.STRICTFP);
 366             if (0 != (flags & DEFAULT))   modifiers.add(Modifier.DEFAULT);
 367             modifiers = Collections.unmodifiableSet(modifiers);
 368             modifierSets.put(flags, modifiers);
 369         }
 370         return modifiers;
 371     }
 372 
 373     // Cache of modifier sets.
 374     private static final Map<Long, Set<Modifier>> modifierSets = new ConcurrentHashMap<>(64);
 375 
 376     public static boolean isStatic(Symbol symbol) {
 377         return (symbol.flags() & STATIC) != 0;
 378     }


 424         HYPOTHETICAL(Flags.HYPOTHETICAL),
 425         PROPRIETARY(Flags.PROPRIETARY),
 426         UNION(Flags.UNION),
 427         EFFECTIVELY_FINAL(Flags.EFFECTIVELY_FINAL),
 428         CLASH(Flags.CLASH),
 429         AUXILIARY(Flags.AUXILIARY),
 430         NOT_IN_PROFILE(Flags.NOT_IN_PROFILE),
 431         BAD_OVERRIDE(Flags.BAD_OVERRIDE),
 432         SIGNATURE_POLYMORPHIC(Flags.SIGNATURE_POLYMORPHIC),
 433         THROWS(Flags.THROWS),
 434         LAMBDA_METHOD(Flags.LAMBDA_METHOD),
 435         TYPE_TRANSLATED(Flags.TYPE_TRANSLATED),
 436         MODULE(Flags.MODULE),
 437         AUTOMATIC_MODULE(Flags.AUTOMATIC_MODULE),
 438         SYSTEM_MODULE(Flags.SYSTEM_MODULE),
 439         DEPRECATED_ANNOTATION(Flags.DEPRECATED_ANNOTATION),
 440         DEPRECATED_REMOVAL(Flags.DEPRECATED_REMOVAL),
 441         HAS_RESOURCE(Flags.HAS_RESOURCE),
 442         POTENTIALLY_AMBIGUOUS(Flags.POTENTIALLY_AMBIGUOUS),
 443         ANONCONSTR_BASED(Flags.ANONCONSTR_BASED),
 444         NAME_FILLED(Flags.NAME_FILLED);





 445 
 446         Flag(long flag) {
 447             this.value = flag;
 448             this.lowercaseName = StringUtils.toLowerCase(name());
 449         }
 450 
 451         @Override
 452         public String toString() {
 453             return lowercaseName;
 454         }
 455 
 456         final long value;
 457         final String lowercaseName;
 458     }
 459 
 460 }


 307      * Flag to indicate the given PackageSymbol contains any non-.java and non-.class resources.
 308      */
 309     public static final long HAS_RESOURCE = 1L<<56;
 310 
 311     /**
 312      * Flag for synthesized default constructors of anonymous classes that have an enclosing expression.
 313      */
 314     public static final long ANONCONSTR_BASED = 1L<<57;
 315 
 316     /**
 317      * Flag that marks finalize block as body-only, should not be copied into catch clauses.
 318      * Used to implement try-with-resources.
 319      */
 320     public static final long BODY_ONLY_FINALIZE = 1L<<17; //blocks only
 321 
 322     /**
 323      * Flag to indicate the given ParamSymbol has a user-friendly name filled.
 324      */
 325     public static final long NAME_FILLED = 1L<<58; //ParamSymbols only
 326 
 327     /**
 328      * Flag to indicate the given variable is a match binding variable.
 329      */
 330     public static final long MATCH_BINDING = 1L<<59;
 331 
 332     /**
 333      * A flag to indicate a match binding variable whose scope extends after the current statement.
 334      */
 335     public static final long MATCH_BINDING_TO_OUTER = 1L<<60;
 336 
 337     /**
 338      * Flag to indicate sealed class/interface declaration.
 339      */
 340     public static final long SEALED = 1L<<61;
 341 
 342     /**
 343      * Flag to indicate that the class/interface has explicitly being annotated as not sealed.
 344      */
 345     public static final long NON_SEALED = 1L<<62;
 346 
 347     /**
 348      * Flag to indicate that a class is a record. The flag is also used to mark fields that are
 349      * part of the state vector of a record.
 350      */
 351     public static final long RECORD = 1L<<63;
 352 
 353     /** Modifier masks.
 354      */
 355     public static final int
 356         AccessFlags           = PUBLIC | PROTECTED | PRIVATE,
 357         LocalClassFlags       = FINAL | ABSTRACT | STRICTFP | ENUM | SYNTHETIC,
 358         LocalRecordFlags            = LocalClassFlags | STATIC,
 359         MemberClassFlags      = LocalClassFlags | INTERFACE | AccessFlags,
 360         MemberRecordClassFlags      = MemberClassFlags | STATIC,
 361         ClassFlags            = LocalClassFlags | INTERFACE | PUBLIC | ANNOTATION,
 362         InterfaceVarFlags     = FINAL | STATIC | PUBLIC,
 363         VarFlags              = AccessFlags | FINAL | STATIC |
 364                                 VOLATILE | TRANSIENT | ENUM,
 365         ConstructorFlags      = AccessFlags,
 366         InterfaceMethodFlags  = ABSTRACT | PUBLIC,
 367         MethodFlags           = AccessFlags | ABSTRACT | STATIC | NATIVE |
 368                                 SYNCHRONIZED | FINAL | STRICTFP;
 369     public static final long
 370         ExtendedStandardFlags            = (long)StandardFlags | DEFAULT | SEALED | NON_SEALED,
 371         ExtendedLocalClassFlags          = (long)LocalClassFlags | SEALED | NON_SEALED,
 372         ExtendedLocalRecordFlags         = (long)LocalRecordFlags | SEALED | NON_SEALED,
 373         ExtendedMemberClassFlags         = (long)MemberClassFlags | SEALED | NON_SEALED,
 374         ExtendedMemberRecordClassFlags   = (long)MemberRecordClassFlags | SEALED | NON_SEALED,
 375         ExtendedClassFlags               = (long)ClassFlags | SEALED | NON_SEALED,
 376         ModifierFlags                    = ((long)StandardFlags & ~INTERFACE) | DEFAULT | SEALED | NON_SEALED,
 377         InterfaceMethodMask         = ABSTRACT | PRIVATE | STATIC | PUBLIC | STRICTFP | DEFAULT,
 378         AnnotationTypeElementMask   = ABSTRACT | PUBLIC,
 379         LocalVarFlags               = FINAL | PARAMETER,
 380         ReceiverParamFlags          = PARAMETER;
 381 
 382 
 383     public static Set<Modifier> asModifierSet(long flags) {
 384         Set<Modifier> modifiers = modifierSets.get(flags);
 385         if (modifiers == null) {
 386             modifiers = java.util.EnumSet.noneOf(Modifier.class);
 387             if (0 != (flags & PUBLIC))    modifiers.add(Modifier.PUBLIC);
 388             if (0 != (flags & PROTECTED)) modifiers.add(Modifier.PROTECTED);
 389             if (0 != (flags & PRIVATE))   modifiers.add(Modifier.PRIVATE);
 390             if (0 != (flags & ABSTRACT))  modifiers.add(Modifier.ABSTRACT);
 391             if (0 != (flags & STATIC))    modifiers.add(Modifier.STATIC);
 392             if (0 != (flags & SEALED))    modifiers.add(Modifier.SEALED);
 393             if (0 != (flags & FINAL))     modifiers.add(Modifier.FINAL);
 394             if (0 != (flags & TRANSIENT)) modifiers.add(Modifier.TRANSIENT);
 395             if (0 != (flags & VOLATILE))  modifiers.add(Modifier.VOLATILE);
 396             if (0 != (flags & SYNCHRONIZED))
 397                                           modifiers.add(Modifier.SYNCHRONIZED);
 398             if (0 != (flags & NATIVE))    modifiers.add(Modifier.NATIVE);
 399             if (0 != (flags & STRICTFP))  modifiers.add(Modifier.STRICTFP);
 400             if (0 != (flags & DEFAULT))   modifiers.add(Modifier.DEFAULT);
 401             modifiers = Collections.unmodifiableSet(modifiers);
 402             modifierSets.put(flags, modifiers);
 403         }
 404         return modifiers;
 405     }
 406 
 407     // Cache of modifier sets.
 408     private static final Map<Long, Set<Modifier>> modifierSets = new ConcurrentHashMap<>(64);
 409 
 410     public static boolean isStatic(Symbol symbol) {
 411         return (symbol.flags() & STATIC) != 0;
 412     }


 458         HYPOTHETICAL(Flags.HYPOTHETICAL),
 459         PROPRIETARY(Flags.PROPRIETARY),
 460         UNION(Flags.UNION),
 461         EFFECTIVELY_FINAL(Flags.EFFECTIVELY_FINAL),
 462         CLASH(Flags.CLASH),
 463         AUXILIARY(Flags.AUXILIARY),
 464         NOT_IN_PROFILE(Flags.NOT_IN_PROFILE),
 465         BAD_OVERRIDE(Flags.BAD_OVERRIDE),
 466         SIGNATURE_POLYMORPHIC(Flags.SIGNATURE_POLYMORPHIC),
 467         THROWS(Flags.THROWS),
 468         LAMBDA_METHOD(Flags.LAMBDA_METHOD),
 469         TYPE_TRANSLATED(Flags.TYPE_TRANSLATED),
 470         MODULE(Flags.MODULE),
 471         AUTOMATIC_MODULE(Flags.AUTOMATIC_MODULE),
 472         SYSTEM_MODULE(Flags.SYSTEM_MODULE),
 473         DEPRECATED_ANNOTATION(Flags.DEPRECATED_ANNOTATION),
 474         DEPRECATED_REMOVAL(Flags.DEPRECATED_REMOVAL),
 475         HAS_RESOURCE(Flags.HAS_RESOURCE),
 476         POTENTIALLY_AMBIGUOUS(Flags.POTENTIALLY_AMBIGUOUS),
 477         ANONCONSTR_BASED(Flags.ANONCONSTR_BASED),
 478         NAME_FILLED(Flags.NAME_FILLED),
 479         MATCH_BINDING(Flags.MATCH_BINDING),
 480         MATCH_BINDING_TO_OUTER(Flags.MATCH_BINDING_TO_OUTER),
 481         SEALED(Flags.SEALED),
 482         NON_SEALED(Flags.NON_SEALED),
 483         RECORD(Flags.RECORD);
 484 
 485         Flag(long flag) {
 486             this.value = flag;
 487             this.lowercaseName = StringUtils.toLowerCase(name());
 488         }
 489 
 490         @Override
 491         public String toString() {
 492             return lowercaseName;
 493         }
 494 
 495         final long value;
 496         final String lowercaseName;
 497     }
 498 
 499 }
< prev index next >