langtools/src/share/classes/com/sun/tools/javac/code/Flags.java
author duke
Sat, 01 Dec 2007 00:00:00 +0000
changeset 10 06bc494ca11e
child 939 38e24969c7e9
permissions -rw-r--r--
Initial load
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
10
06bc494ca11e Initial load
duke
parents:
diff changeset
     1
/*
06bc494ca11e Initial load
duke
parents:
diff changeset
     2
 * Copyright 1999-2006 Sun Microsystems, Inc.  All Rights Reserved.
06bc494ca11e Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
06bc494ca11e Initial load
duke
parents:
diff changeset
     4
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
06bc494ca11e Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
06bc494ca11e Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.  Sun designates this
06bc494ca11e Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
06bc494ca11e Initial load
duke
parents:
diff changeset
     9
 * by Sun in the LICENSE file that accompanied this code.
06bc494ca11e Initial load
duke
parents:
diff changeset
    10
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
06bc494ca11e Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
06bc494ca11e Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
06bc494ca11e Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
06bc494ca11e Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
06bc494ca11e Initial load
duke
parents:
diff changeset
    16
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
06bc494ca11e Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
06bc494ca11e Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
06bc494ca11e Initial load
duke
parents:
diff changeset
    20
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
    21
 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
06bc494ca11e Initial load
duke
parents:
diff changeset
    22
 * CA 95054 USA or visit www.sun.com if you need additional information or
06bc494ca11e Initial load
duke
parents:
diff changeset
    23
 * have any questions.
06bc494ca11e Initial load
duke
parents:
diff changeset
    24
 */
06bc494ca11e Initial load
duke
parents:
diff changeset
    25
06bc494ca11e Initial load
duke
parents:
diff changeset
    26
package com.sun.tools.javac.code;
06bc494ca11e Initial load
duke
parents:
diff changeset
    27
06bc494ca11e Initial load
duke
parents:
diff changeset
    28
import java.util.Collections;
06bc494ca11e Initial load
duke
parents:
diff changeset
    29
import java.util.Map;
06bc494ca11e Initial load
duke
parents:
diff changeset
    30
import java.util.Set;
06bc494ca11e Initial load
duke
parents:
diff changeset
    31
import javax.lang.model.element.Modifier;
06bc494ca11e Initial load
duke
parents:
diff changeset
    32
06bc494ca11e Initial load
duke
parents:
diff changeset
    33
/** Access flags and other modifiers for Java classes and members.
06bc494ca11e Initial load
duke
parents:
diff changeset
    34
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
    35
 *  <p><b>This is NOT part of any API supported by Sun Microsystems.  If
06bc494ca11e Initial load
duke
parents:
diff changeset
    36
 *  you write code that depends on this, you do so at your own risk.
06bc494ca11e Initial load
duke
parents:
diff changeset
    37
 *  This code and its internal interfaces are subject to change or
06bc494ca11e Initial load
duke
parents:
diff changeset
    38
 *  deletion without notice.</b>
06bc494ca11e Initial load
duke
parents:
diff changeset
    39
 */
06bc494ca11e Initial load
duke
parents:
diff changeset
    40
public class Flags {
06bc494ca11e Initial load
duke
parents:
diff changeset
    41
06bc494ca11e Initial load
duke
parents:
diff changeset
    42
    private Flags() {} // uninstantiable
06bc494ca11e Initial load
duke
parents:
diff changeset
    43
06bc494ca11e Initial load
duke
parents:
diff changeset
    44
    public static String toString(long flags) {
06bc494ca11e Initial load
duke
parents:
diff changeset
    45
        StringBuffer buf = new StringBuffer();
06bc494ca11e Initial load
duke
parents:
diff changeset
    46
        if ((flags&PUBLIC) != 0) buf.append("public ");
06bc494ca11e Initial load
duke
parents:
diff changeset
    47
        if ((flags&PRIVATE) != 0) buf.append("private ");
06bc494ca11e Initial load
duke
parents:
diff changeset
    48
        if ((flags&PROTECTED) != 0) buf.append("protected ");
06bc494ca11e Initial load
duke
parents:
diff changeset
    49
        if ((flags&STATIC) != 0) buf.append("static ");
06bc494ca11e Initial load
duke
parents:
diff changeset
    50
        if ((flags&FINAL) != 0) buf.append("final ");
06bc494ca11e Initial load
duke
parents:
diff changeset
    51
        if ((flags&SYNCHRONIZED) != 0) buf.append("synchronized ");
06bc494ca11e Initial load
duke
parents:
diff changeset
    52
        if ((flags&VOLATILE) != 0) buf.append("volatile ");
06bc494ca11e Initial load
duke
parents:
diff changeset
    53
        if ((flags&TRANSIENT) != 0) buf.append("transient ");
06bc494ca11e Initial load
duke
parents:
diff changeset
    54
        if ((flags&NATIVE) != 0) buf.append("native ");
06bc494ca11e Initial load
duke
parents:
diff changeset
    55
        if ((flags&INTERFACE) != 0) buf.append("interface ");
06bc494ca11e Initial load
duke
parents:
diff changeset
    56
        if ((flags&ABSTRACT) != 0) buf.append("abstract ");
06bc494ca11e Initial load
duke
parents:
diff changeset
    57
        if ((flags&STRICTFP) != 0) buf.append("strictfp ");
06bc494ca11e Initial load
duke
parents:
diff changeset
    58
        if ((flags&BRIDGE) != 0) buf.append("bridge ");
06bc494ca11e Initial load
duke
parents:
diff changeset
    59
        if ((flags&SYNTHETIC) != 0) buf.append("synthetic ");
06bc494ca11e Initial load
duke
parents:
diff changeset
    60
        if ((flags&DEPRECATED) != 0) buf.append("deprecated ");
06bc494ca11e Initial load
duke
parents:
diff changeset
    61
        if ((flags&HASINIT) != 0) buf.append("hasinit ");
06bc494ca11e Initial load
duke
parents:
diff changeset
    62
        if ((flags&ENUM) != 0) buf.append("enum ");
06bc494ca11e Initial load
duke
parents:
diff changeset
    63
        if ((flags&IPROXY) != 0) buf.append("iproxy ");
06bc494ca11e Initial load
duke
parents:
diff changeset
    64
        if ((flags&NOOUTERTHIS) != 0) buf.append("noouterthis ");
06bc494ca11e Initial load
duke
parents:
diff changeset
    65
        if ((flags&EXISTS) != 0) buf.append("exists ");
06bc494ca11e Initial load
duke
parents:
diff changeset
    66
        if ((flags&COMPOUND) != 0) buf.append("compound ");
06bc494ca11e Initial load
duke
parents:
diff changeset
    67
        if ((flags&CLASS_SEEN) != 0) buf.append("class_seen ");
06bc494ca11e Initial load
duke
parents:
diff changeset
    68
        if ((flags&SOURCE_SEEN) != 0) buf.append("source_seen ");
06bc494ca11e Initial load
duke
parents:
diff changeset
    69
        if ((flags&LOCKED) != 0) buf.append("locked ");
06bc494ca11e Initial load
duke
parents:
diff changeset
    70
        if ((flags&UNATTRIBUTED) != 0) buf.append("unattributed ");
06bc494ca11e Initial load
duke
parents:
diff changeset
    71
        if ((flags&ANONCONSTR) != 0) buf.append("anonconstr ");
06bc494ca11e Initial load
duke
parents:
diff changeset
    72
        if ((flags&ACYCLIC) != 0) buf.append("acyclic ");
06bc494ca11e Initial load
duke
parents:
diff changeset
    73
        if ((flags&PARAMETER) != 0) buf.append("parameter ");
06bc494ca11e Initial load
duke
parents:
diff changeset
    74
        if ((flags&VARARGS) != 0) buf.append("varargs ");
06bc494ca11e Initial load
duke
parents:
diff changeset
    75
        return buf.toString();
06bc494ca11e Initial load
duke
parents:
diff changeset
    76
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
    77
06bc494ca11e Initial load
duke
parents:
diff changeset
    78
    /* Standard Java flags.
06bc494ca11e Initial load
duke
parents:
diff changeset
    79
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
    80
    public static final int PUBLIC       = 1<<0;
06bc494ca11e Initial load
duke
parents:
diff changeset
    81
    public static final int PRIVATE      = 1<<1;
06bc494ca11e Initial load
duke
parents:
diff changeset
    82
    public static final int PROTECTED    = 1<<2;
06bc494ca11e Initial load
duke
parents:
diff changeset
    83
    public static final int STATIC       = 1<<3;
06bc494ca11e Initial load
duke
parents:
diff changeset
    84
    public static final int FINAL        = 1<<4;
06bc494ca11e Initial load
duke
parents:
diff changeset
    85
    public static final int SYNCHRONIZED = 1<<5;
06bc494ca11e Initial load
duke
parents:
diff changeset
    86
    public static final int VOLATILE     = 1<<6;
06bc494ca11e Initial load
duke
parents:
diff changeset
    87
    public static final int TRANSIENT    = 1<<7;
06bc494ca11e Initial load
duke
parents:
diff changeset
    88
    public static final int NATIVE       = 1<<8;
06bc494ca11e Initial load
duke
parents:
diff changeset
    89
    public static final int INTERFACE    = 1<<9;
06bc494ca11e Initial load
duke
parents:
diff changeset
    90
    public static final int ABSTRACT     = 1<<10;
06bc494ca11e Initial load
duke
parents:
diff changeset
    91
    public static final int STRICTFP     = 1<<11;
06bc494ca11e Initial load
duke
parents:
diff changeset
    92
06bc494ca11e Initial load
duke
parents:
diff changeset
    93
    /* Flag that marks a symbol synthetic, added in classfile v49.0. */
06bc494ca11e Initial load
duke
parents:
diff changeset
    94
    public static final int SYNTHETIC    = 1<<12;
06bc494ca11e Initial load
duke
parents:
diff changeset
    95
06bc494ca11e Initial load
duke
parents:
diff changeset
    96
    /** Flag that marks attribute interfaces, added in classfile v49.0. */
06bc494ca11e Initial load
duke
parents:
diff changeset
    97
    public static final int ANNOTATION   = 1<<13;
06bc494ca11e Initial load
duke
parents:
diff changeset
    98
06bc494ca11e Initial load
duke
parents:
diff changeset
    99
    /** An enumeration type or an enumeration constant, added in
06bc494ca11e Initial load
duke
parents:
diff changeset
   100
     *  classfile v49.0. */
06bc494ca11e Initial load
duke
parents:
diff changeset
   101
    public static final int ENUM         = 1<<14;
06bc494ca11e Initial load
duke
parents:
diff changeset
   102
06bc494ca11e Initial load
duke
parents:
diff changeset
   103
    public static final int StandardFlags = 0x0fff;
06bc494ca11e Initial load
duke
parents:
diff changeset
   104
06bc494ca11e Initial load
duke
parents:
diff changeset
   105
    // Because the following access flags are overloaded with other
06bc494ca11e Initial load
duke
parents:
diff changeset
   106
    // bit positions, we translate them when reading and writing class
06bc494ca11e Initial load
duke
parents:
diff changeset
   107
    // files into unique bits positions: ACC_SYNTHETIC <-> SYNTHETIC,
06bc494ca11e Initial load
duke
parents:
diff changeset
   108
    // for example.
06bc494ca11e Initial load
duke
parents:
diff changeset
   109
    public static final int ACC_SUPER    = 0x0020;
06bc494ca11e Initial load
duke
parents:
diff changeset
   110
    public static final int ACC_BRIDGE   = 0x0040;
06bc494ca11e Initial load
duke
parents:
diff changeset
   111
    public static final int ACC_VARARGS  = 0x0080;
06bc494ca11e Initial load
duke
parents:
diff changeset
   112
06bc494ca11e Initial load
duke
parents:
diff changeset
   113
    /*****************************************
06bc494ca11e Initial load
duke
parents:
diff changeset
   114
     * Internal compiler flags (no bits in the lower 16).
06bc494ca11e Initial load
duke
parents:
diff changeset
   115
     *****************************************/
06bc494ca11e Initial load
duke
parents:
diff changeset
   116
06bc494ca11e Initial load
duke
parents:
diff changeset
   117
    /** Flag is set if symbol is deprecated.
06bc494ca11e Initial load
duke
parents:
diff changeset
   118
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   119
    public static final int DEPRECATED   = 1<<17;
06bc494ca11e Initial load
duke
parents:
diff changeset
   120
06bc494ca11e Initial load
duke
parents:
diff changeset
   121
    /** Flag is set for a variable symbol if the variable's definition
06bc494ca11e Initial load
duke
parents:
diff changeset
   122
     *  has an initializer part.
06bc494ca11e Initial load
duke
parents:
diff changeset
   123
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   124
    public static final int HASINIT          = 1<<18;
06bc494ca11e Initial load
duke
parents:
diff changeset
   125
06bc494ca11e Initial load
duke
parents:
diff changeset
   126
    /** Flag is set for compiler-generated anonymous method symbols
06bc494ca11e Initial load
duke
parents:
diff changeset
   127
     *  that `own' an initializer block.
06bc494ca11e Initial load
duke
parents:
diff changeset
   128
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   129
    public static final int BLOCK            = 1<<20;
06bc494ca11e Initial load
duke
parents:
diff changeset
   130
06bc494ca11e Initial load
duke
parents:
diff changeset
   131
    /** Flag is set for compiler-generated abstract methods that implement
06bc494ca11e Initial load
duke
parents:
diff changeset
   132
     *  an interface method (Miranda methods).
06bc494ca11e Initial load
duke
parents:
diff changeset
   133
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   134
    public static final int IPROXY           = 1<<21;
06bc494ca11e Initial load
duke
parents:
diff changeset
   135
06bc494ca11e Initial load
duke
parents:
diff changeset
   136
    /** Flag is set for nested classes that do not access instance members
06bc494ca11e Initial load
duke
parents:
diff changeset
   137
     *  or `this' of an outer class and therefore don't need to be passed
06bc494ca11e Initial load
duke
parents:
diff changeset
   138
     *  a this$n reference.  This flag is currently set only for anonymous
06bc494ca11e Initial load
duke
parents:
diff changeset
   139
     *  classes in superclass constructor calls and only for pre 1.4 targets.
06bc494ca11e Initial load
duke
parents:
diff changeset
   140
     *  todo: use this flag for optimizing away this$n parameters in
06bc494ca11e Initial load
duke
parents:
diff changeset
   141
     *  other cases.
06bc494ca11e Initial load
duke
parents:
diff changeset
   142
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   143
    public static final int NOOUTERTHIS  = 1<<22;
06bc494ca11e Initial load
duke
parents:
diff changeset
   144
06bc494ca11e Initial load
duke
parents:
diff changeset
   145
    /** Flag is set for package symbols if a package has a member or
06bc494ca11e Initial load
duke
parents:
diff changeset
   146
     *  directory and therefore exists.
06bc494ca11e Initial load
duke
parents:
diff changeset
   147
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   148
    public static final int EXISTS           = 1<<23;
06bc494ca11e Initial load
duke
parents:
diff changeset
   149
06bc494ca11e Initial load
duke
parents:
diff changeset
   150
    /** Flag is set for compiler-generated compound classes
06bc494ca11e Initial load
duke
parents:
diff changeset
   151
     *  representing multiple variable bounds
06bc494ca11e Initial load
duke
parents:
diff changeset
   152
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   153
    public static final int COMPOUND     = 1<<24;
06bc494ca11e Initial load
duke
parents:
diff changeset
   154
06bc494ca11e Initial load
duke
parents:
diff changeset
   155
    /** Flag is set for class symbols if a class file was found for this class.
06bc494ca11e Initial load
duke
parents:
diff changeset
   156
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   157
    public static final int CLASS_SEEN   = 1<<25;
06bc494ca11e Initial load
duke
parents:
diff changeset
   158
06bc494ca11e Initial load
duke
parents:
diff changeset
   159
    /** Flag is set for class symbols if a source file was found for this
06bc494ca11e Initial load
duke
parents:
diff changeset
   160
     *  class.
06bc494ca11e Initial load
duke
parents:
diff changeset
   161
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   162
    public static final int SOURCE_SEEN  = 1<<26;
06bc494ca11e Initial load
duke
parents:
diff changeset
   163
06bc494ca11e Initial load
duke
parents:
diff changeset
   164
    /* State flags (are reset during compilation).
06bc494ca11e Initial load
duke
parents:
diff changeset
   165
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   166
06bc494ca11e Initial load
duke
parents:
diff changeset
   167
    /** Flag for class symbols is set and later re-set as a lock in
06bc494ca11e Initial load
duke
parents:
diff changeset
   168
     *  Enter to detect cycles in the superclass/superinterface
06bc494ca11e Initial load
duke
parents:
diff changeset
   169
     *  relations.  Similarly for constructor call cycle detection in
06bc494ca11e Initial load
duke
parents:
diff changeset
   170
     *  Attr.
06bc494ca11e Initial load
duke
parents:
diff changeset
   171
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   172
    public static final int LOCKED           = 1<<27;
06bc494ca11e Initial load
duke
parents:
diff changeset
   173
06bc494ca11e Initial load
duke
parents:
diff changeset
   174
    /** Flag for class symbols is set and later re-set to indicate that a class
06bc494ca11e Initial load
duke
parents:
diff changeset
   175
     *  has been entered but has not yet been attributed.
06bc494ca11e Initial load
duke
parents:
diff changeset
   176
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   177
    public static final int UNATTRIBUTED = 1<<28;
06bc494ca11e Initial load
duke
parents:
diff changeset
   178
06bc494ca11e Initial load
duke
parents:
diff changeset
   179
    /** Flag for synthesized default constructors of anonymous classes.
06bc494ca11e Initial load
duke
parents:
diff changeset
   180
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   181
    public static final int ANONCONSTR   = 1<<29;
06bc494ca11e Initial load
duke
parents:
diff changeset
   182
06bc494ca11e Initial load
duke
parents:
diff changeset
   183
    /** Flag for class symbols to indicate it has been checked and found
06bc494ca11e Initial load
duke
parents:
diff changeset
   184
     *  acyclic.
06bc494ca11e Initial load
duke
parents:
diff changeset
   185
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   186
    public static final int ACYCLIC          = 1<<30;
06bc494ca11e Initial load
duke
parents:
diff changeset
   187
06bc494ca11e Initial load
duke
parents:
diff changeset
   188
    /** Flag that marks bridge methods.
06bc494ca11e Initial load
duke
parents:
diff changeset
   189
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   190
    public static final long BRIDGE          = 1L<<31;
06bc494ca11e Initial load
duke
parents:
diff changeset
   191
06bc494ca11e Initial load
duke
parents:
diff changeset
   192
    /** Flag that marks formal parameters.
06bc494ca11e Initial load
duke
parents:
diff changeset
   193
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   194
    public static final long PARAMETER   = 1L<<33;
06bc494ca11e Initial load
duke
parents:
diff changeset
   195
06bc494ca11e Initial load
duke
parents:
diff changeset
   196
    /** Flag that marks varargs methods.
06bc494ca11e Initial load
duke
parents:
diff changeset
   197
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   198
    public static final long VARARGS   = 1L<<34;
06bc494ca11e Initial load
duke
parents:
diff changeset
   199
06bc494ca11e Initial load
duke
parents:
diff changeset
   200
    /** Flag for annotation type symbols to indicate it has been
06bc494ca11e Initial load
duke
parents:
diff changeset
   201
     *  checked and found acyclic.
06bc494ca11e Initial load
duke
parents:
diff changeset
   202
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   203
    public static final long ACYCLIC_ANN      = 1L<<35;
06bc494ca11e Initial load
duke
parents:
diff changeset
   204
06bc494ca11e Initial load
duke
parents:
diff changeset
   205
    /** Flag that marks a generated default constructor.
06bc494ca11e Initial load
duke
parents:
diff changeset
   206
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   207
    public static final long GENERATEDCONSTR   = 1L<<36;
06bc494ca11e Initial load
duke
parents:
diff changeset
   208
06bc494ca11e Initial load
duke
parents:
diff changeset
   209
    /** Flag that marks a hypothetical method that need not really be
06bc494ca11e Initial load
duke
parents:
diff changeset
   210
     *  generated in the binary, but is present in the symbol table to
06bc494ca11e Initial load
duke
parents:
diff changeset
   211
     *  simplify checking for erasure clashes.
06bc494ca11e Initial load
duke
parents:
diff changeset
   212
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   213
    public static final long HYPOTHETICAL   = 1L<<37;
06bc494ca11e Initial load
duke
parents:
diff changeset
   214
06bc494ca11e Initial load
duke
parents:
diff changeset
   215
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   216
     * Flag that marks a Sun proprietary class.
06bc494ca11e Initial load
duke
parents:
diff changeset
   217
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   218
    public static final long PROPRIETARY = 1L<<38;
06bc494ca11e Initial load
duke
parents:
diff changeset
   219
06bc494ca11e Initial load
duke
parents:
diff changeset
   220
    /** Modifier masks.
06bc494ca11e Initial load
duke
parents:
diff changeset
   221
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   222
    public static final int
06bc494ca11e Initial load
duke
parents:
diff changeset
   223
        AccessFlags           = PUBLIC | PROTECTED | PRIVATE,
06bc494ca11e Initial load
duke
parents:
diff changeset
   224
        LocalClassFlags       = FINAL | ABSTRACT | STRICTFP | ENUM | SYNTHETIC,
06bc494ca11e Initial load
duke
parents:
diff changeset
   225
        MemberClassFlags      = LocalClassFlags | INTERFACE | AccessFlags,
06bc494ca11e Initial load
duke
parents:
diff changeset
   226
        ClassFlags            = LocalClassFlags | INTERFACE | PUBLIC | ANNOTATION,
06bc494ca11e Initial load
duke
parents:
diff changeset
   227
        InterfaceVarFlags     = FINAL | STATIC | PUBLIC,
06bc494ca11e Initial load
duke
parents:
diff changeset
   228
        VarFlags              = AccessFlags | FINAL | STATIC |
06bc494ca11e Initial load
duke
parents:
diff changeset
   229
                                VOLATILE | TRANSIENT | ENUM,
06bc494ca11e Initial load
duke
parents:
diff changeset
   230
        ConstructorFlags      = AccessFlags,
06bc494ca11e Initial load
duke
parents:
diff changeset
   231
        InterfaceMethodFlags  = ABSTRACT | PUBLIC,
06bc494ca11e Initial load
duke
parents:
diff changeset
   232
        MethodFlags           = AccessFlags | ABSTRACT | STATIC | NATIVE |
06bc494ca11e Initial load
duke
parents:
diff changeset
   233
                                SYNCHRONIZED | FINAL | STRICTFP;
06bc494ca11e Initial load
duke
parents:
diff changeset
   234
    public static final long
06bc494ca11e Initial load
duke
parents:
diff changeset
   235
        LocalVarFlags         = FINAL | PARAMETER;
06bc494ca11e Initial load
duke
parents:
diff changeset
   236
06bc494ca11e Initial load
duke
parents:
diff changeset
   237
    public static Set<Modifier> asModifierSet(long flags) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   238
        Set<Modifier> modifiers = modifierSets.get(flags);
06bc494ca11e Initial load
duke
parents:
diff changeset
   239
        if (modifiers == null) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   240
            modifiers = java.util.EnumSet.noneOf(Modifier.class);
06bc494ca11e Initial load
duke
parents:
diff changeset
   241
            if (0 != (flags & PUBLIC))    modifiers.add(Modifier.PUBLIC);
06bc494ca11e Initial load
duke
parents:
diff changeset
   242
            if (0 != (flags & PROTECTED)) modifiers.add(Modifier.PROTECTED);
06bc494ca11e Initial load
duke
parents:
diff changeset
   243
            if (0 != (flags & PRIVATE))   modifiers.add(Modifier.PRIVATE);
06bc494ca11e Initial load
duke
parents:
diff changeset
   244
            if (0 != (flags & ABSTRACT))  modifiers.add(Modifier.ABSTRACT);
06bc494ca11e Initial load
duke
parents:
diff changeset
   245
            if (0 != (flags & STATIC))    modifiers.add(Modifier.STATIC);
06bc494ca11e Initial load
duke
parents:
diff changeset
   246
            if (0 != (flags & FINAL))     modifiers.add(Modifier.FINAL);
06bc494ca11e Initial load
duke
parents:
diff changeset
   247
            if (0 != (flags & TRANSIENT)) modifiers.add(Modifier.TRANSIENT);
06bc494ca11e Initial load
duke
parents:
diff changeset
   248
            if (0 != (flags & VOLATILE))  modifiers.add(Modifier.VOLATILE);
06bc494ca11e Initial load
duke
parents:
diff changeset
   249
            if (0 != (flags & SYNCHRONIZED))
06bc494ca11e Initial load
duke
parents:
diff changeset
   250
                                          modifiers.add(Modifier.SYNCHRONIZED);
06bc494ca11e Initial load
duke
parents:
diff changeset
   251
            if (0 != (flags & NATIVE))    modifiers.add(Modifier.NATIVE);
06bc494ca11e Initial load
duke
parents:
diff changeset
   252
            if (0 != (flags & STRICTFP))  modifiers.add(Modifier.STRICTFP);
06bc494ca11e Initial load
duke
parents:
diff changeset
   253
            modifiers = Collections.unmodifiableSet(modifiers);
06bc494ca11e Initial load
duke
parents:
diff changeset
   254
            modifierSets.put(flags, modifiers);
06bc494ca11e Initial load
duke
parents:
diff changeset
   255
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   256
        return modifiers;
06bc494ca11e Initial load
duke
parents:
diff changeset
   257
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   258
06bc494ca11e Initial load
duke
parents:
diff changeset
   259
    // Cache of modifier sets.
06bc494ca11e Initial load
duke
parents:
diff changeset
   260
    private static Map<Long, Set<Modifier>> modifierSets =
06bc494ca11e Initial load
duke
parents:
diff changeset
   261
        new java.util.concurrent.ConcurrentHashMap<Long, Set<Modifier>>(64);
06bc494ca11e Initial load
duke
parents:
diff changeset
   262
06bc494ca11e Initial load
duke
parents:
diff changeset
   263
    public static boolean isStatic(Symbol symbol) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   264
        return (symbol.flags() & STATIC) != 0;
06bc494ca11e Initial load
duke
parents:
diff changeset
   265
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   266
06bc494ca11e Initial load
duke
parents:
diff changeset
   267
    public static boolean isEnum(Symbol symbol) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   268
        return (symbol.flags() & ENUM) != 0;
06bc494ca11e Initial load
duke
parents:
diff changeset
   269
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   270
06bc494ca11e Initial load
duke
parents:
diff changeset
   271
    public static boolean isConstant(Symbol.VarSymbol symbol) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   272
        return symbol.getConstValue() != null;
06bc494ca11e Initial load
duke
parents:
diff changeset
   273
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   274
}