langtools/src/share/classes/com/sun/tools/javac/code/Flags.java
author mcimadamore
Sun, 04 Nov 2012 10:59:42 +0000
changeset 14443 91c05eb19277
parent 14369 3d660d08d1f7
child 14547 86d8d242b0c4
permissions -rw-r--r--
7192246: Add type-checking support for default methods Summary: Add type-checking support for default methods as per Featherweight-Defender document Reviewed-by: jjg, dlsmith
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
10
06bc494ca11e Initial load
duke
parents:
diff changeset
     1
/*
12335
4725d88691dd 7133185: Update 292 overload resolution logic to match JLS
mcimadamore
parents: 9300
diff changeset
     2
 * Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved.
10
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
5520
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 5492
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
10
06bc494ca11e Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5520
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 5492
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
10
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
 *
5520
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 5492
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 5492
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 5492
diff changeset
    23
 * questions.
10
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
14258
8d2148961366 8000663: clean up langtools imports
jjg
parents: 12335
diff changeset
    28
import java.util.Collections;
939
38e24969c7e9 6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents: 10
diff changeset
    29
import java.util.EnumSet;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    30
import java.util.Map;
06bc494ca11e Initial load
duke
parents:
diff changeset
    31
import java.util.Set;
14258
8d2148961366 8000663: clean up langtools imports
jjg
parents: 12335
diff changeset
    32
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    33
import javax.lang.model.element.Modifier;
06bc494ca11e Initial load
duke
parents:
diff changeset
    34
06bc494ca11e Initial load
duke
parents:
diff changeset
    35
/** Access flags and other modifiers for Java classes and members.
06bc494ca11e Initial load
duke
parents:
diff changeset
    36
 *
5847
1908176fd6e3 6944312: Potential rebranding issues in openjdk/langtools repository sources
jjg
parents: 5520
diff changeset
    37
 *  <p><b>This is NOT part of any supported API.
1908176fd6e3 6944312: Potential rebranding issues in openjdk/langtools repository sources
jjg
parents: 5520
diff changeset
    38
 *  If you write code that depends on this, you do so at your own risk.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    39
 *  This code and its internal interfaces are subject to change or
06bc494ca11e Initial load
duke
parents:
diff changeset
    40
 *  deletion without notice.</b>
06bc494ca11e Initial load
duke
parents:
diff changeset
    41
 */
06bc494ca11e Initial load
duke
parents:
diff changeset
    42
public class Flags {
06bc494ca11e Initial load
duke
parents:
diff changeset
    43
06bc494ca11e Initial load
duke
parents:
diff changeset
    44
    private Flags() {} // uninstantiable
06bc494ca11e Initial load
duke
parents:
diff changeset
    45
06bc494ca11e Initial load
duke
parents:
diff changeset
    46
    public static String toString(long flags) {
8625
6b51ef804d49 6639645: Modeling type implementing missing interfaces
jjg
parents: 8241
diff changeset
    47
        StringBuilder buf = new StringBuilder();
939
38e24969c7e9 6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents: 10
diff changeset
    48
        String sep = "";
38e24969c7e9 6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents: 10
diff changeset
    49
        for (Flag s : asFlagSet(flags)) {
38e24969c7e9 6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents: 10
diff changeset
    50
            buf.append(sep);
38e24969c7e9 6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents: 10
diff changeset
    51
            buf.append(s);
38e24969c7e9 6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents: 10
diff changeset
    52
            sep = " ";
38e24969c7e9 6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents: 10
diff changeset
    53
        }
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    54
        return buf.toString();
06bc494ca11e Initial load
duke
parents:
diff changeset
    55
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
    56
939
38e24969c7e9 6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents: 10
diff changeset
    57
    public static EnumSet<Flag> asFlagSet(long mask) {
38e24969c7e9 6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents: 10
diff changeset
    58
        EnumSet<Flag> flags = EnumSet.noneOf(Flag.class);
38e24969c7e9 6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents: 10
diff changeset
    59
        if ((mask&PUBLIC) != 0) flags.add(Flag.PUBLIC);
38e24969c7e9 6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents: 10
diff changeset
    60
        if ((mask&PRIVATE) != 0) flags.add(Flag.PRIVATE);
38e24969c7e9 6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents: 10
diff changeset
    61
        if ((mask&PROTECTED) != 0) flags.add(Flag.PROTECTED);
38e24969c7e9 6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents: 10
diff changeset
    62
        if ((mask&STATIC) != 0) flags.add(Flag.STATIC);
38e24969c7e9 6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents: 10
diff changeset
    63
        if ((mask&FINAL) != 0) flags.add(Flag.FINAL);
38e24969c7e9 6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents: 10
diff changeset
    64
        if ((mask&SYNCHRONIZED) != 0) flags.add(Flag.SYNCHRONIZED);
38e24969c7e9 6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents: 10
diff changeset
    65
        if ((mask&VOLATILE) != 0) flags.add(Flag.VOLATILE);
38e24969c7e9 6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents: 10
diff changeset
    66
        if ((mask&TRANSIENT) != 0) flags.add(Flag.TRANSIENT);
38e24969c7e9 6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents: 10
diff changeset
    67
        if ((mask&NATIVE) != 0) flags.add(Flag.NATIVE);
38e24969c7e9 6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents: 10
diff changeset
    68
        if ((mask&INTERFACE) != 0) flags.add(Flag.INTERFACE);
38e24969c7e9 6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents: 10
diff changeset
    69
        if ((mask&ABSTRACT) != 0) flags.add(Flag.ABSTRACT);
38e24969c7e9 6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents: 10
diff changeset
    70
        if ((mask&STRICTFP) != 0) flags.add(Flag.STRICTFP);
38e24969c7e9 6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents: 10
diff changeset
    71
        if ((mask&BRIDGE) != 0) flags.add(Flag.BRIDGE);
38e24969c7e9 6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents: 10
diff changeset
    72
        if ((mask&SYNTHETIC) != 0) flags.add(Flag.SYNTHETIC);
38e24969c7e9 6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents: 10
diff changeset
    73
        if ((mask&DEPRECATED) != 0) flags.add(Flag.DEPRECATED);
38e24969c7e9 6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents: 10
diff changeset
    74
        if ((mask&HASINIT) != 0) flags.add(Flag.HASINIT);
38e24969c7e9 6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents: 10
diff changeset
    75
        if ((mask&ENUM) != 0) flags.add(Flag.ENUM);
38e24969c7e9 6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents: 10
diff changeset
    76
        if ((mask&IPROXY) != 0) flags.add(Flag.IPROXY);
38e24969c7e9 6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents: 10
diff changeset
    77
        if ((mask&NOOUTERTHIS) != 0) flags.add(Flag.NOOUTERTHIS);
38e24969c7e9 6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents: 10
diff changeset
    78
        if ((mask&EXISTS) != 0) flags.add(Flag.EXISTS);
38e24969c7e9 6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents: 10
diff changeset
    79
        if ((mask&COMPOUND) != 0) flags.add(Flag.COMPOUND);
38e24969c7e9 6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents: 10
diff changeset
    80
        if ((mask&CLASS_SEEN) != 0) flags.add(Flag.CLASS_SEEN);
38e24969c7e9 6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents: 10
diff changeset
    81
        if ((mask&SOURCE_SEEN) != 0) flags.add(Flag.SOURCE_SEEN);
38e24969c7e9 6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents: 10
diff changeset
    82
        if ((mask&LOCKED) != 0) flags.add(Flag.LOCKED);
38e24969c7e9 6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents: 10
diff changeset
    83
        if ((mask&UNATTRIBUTED) != 0) flags.add(Flag.UNATTRIBUTED);
38e24969c7e9 6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents: 10
diff changeset
    84
        if ((mask&ANONCONSTR) != 0) flags.add(Flag.ANONCONSTR);
38e24969c7e9 6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents: 10
diff changeset
    85
        if ((mask&ACYCLIC) != 0) flags.add(Flag.ACYCLIC);
38e24969c7e9 6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents: 10
diff changeset
    86
        if ((mask&PARAMETER) != 0) flags.add(Flag.PARAMETER);
38e24969c7e9 6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents: 10
diff changeset
    87
        if ((mask&VARARGS) != 0) flags.add(Flag.VARARGS);
38e24969c7e9 6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents: 10
diff changeset
    88
        return flags;
38e24969c7e9 6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents: 10
diff changeset
    89
    }
38e24969c7e9 6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents: 10
diff changeset
    90
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    91
    /* Standard Java flags.
06bc494ca11e Initial load
duke
parents:
diff changeset
    92
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
    93
    public static final int PUBLIC       = 1<<0;
06bc494ca11e Initial load
duke
parents:
diff changeset
    94
    public static final int PRIVATE      = 1<<1;
06bc494ca11e Initial load
duke
parents:
diff changeset
    95
    public static final int PROTECTED    = 1<<2;
06bc494ca11e Initial load
duke
parents:
diff changeset
    96
    public static final int STATIC       = 1<<3;
06bc494ca11e Initial load
duke
parents:
diff changeset
    97
    public static final int FINAL        = 1<<4;
06bc494ca11e Initial load
duke
parents:
diff changeset
    98
    public static final int SYNCHRONIZED = 1<<5;
06bc494ca11e Initial load
duke
parents:
diff changeset
    99
    public static final int VOLATILE     = 1<<6;
06bc494ca11e Initial load
duke
parents:
diff changeset
   100
    public static final int TRANSIENT    = 1<<7;
06bc494ca11e Initial load
duke
parents:
diff changeset
   101
    public static final int NATIVE       = 1<<8;
06bc494ca11e Initial load
duke
parents:
diff changeset
   102
    public static final int INTERFACE    = 1<<9;
06bc494ca11e Initial load
duke
parents:
diff changeset
   103
    public static final int ABSTRACT     = 1<<10;
06bc494ca11e Initial load
duke
parents:
diff changeset
   104
    public static final int STRICTFP     = 1<<11;
06bc494ca11e Initial load
duke
parents:
diff changeset
   105
06bc494ca11e Initial load
duke
parents:
diff changeset
   106
    /* Flag that marks a symbol synthetic, added in classfile v49.0. */
06bc494ca11e Initial load
duke
parents:
diff changeset
   107
    public static final int SYNTHETIC    = 1<<12;
06bc494ca11e Initial load
duke
parents:
diff changeset
   108
06bc494ca11e Initial load
duke
parents:
diff changeset
   109
    /** Flag that marks attribute interfaces, added in classfile v49.0. */
06bc494ca11e Initial load
duke
parents:
diff changeset
   110
    public static final int ANNOTATION   = 1<<13;
06bc494ca11e Initial load
duke
parents:
diff changeset
   111
06bc494ca11e Initial load
duke
parents:
diff changeset
   112
    /** An enumeration type or an enumeration constant, added in
06bc494ca11e Initial load
duke
parents:
diff changeset
   113
     *  classfile v49.0. */
06bc494ca11e Initial load
duke
parents:
diff changeset
   114
    public static final int ENUM         = 1<<14;
06bc494ca11e Initial load
duke
parents:
diff changeset
   115
06bc494ca11e Initial load
duke
parents:
diff changeset
   116
    public static final int StandardFlags = 0x0fff;
4870
a132763160d7 6919889: assorted position errors in compiler syntax trees
jjg
parents: 1264
diff changeset
   117
    public static final int ModifierFlags = StandardFlags & ~INTERFACE;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   118
06bc494ca11e Initial load
duke
parents:
diff changeset
   119
    // Because the following access flags are overloaded with other
06bc494ca11e Initial load
duke
parents:
diff changeset
   120
    // bit positions, we translate them when reading and writing class
06bc494ca11e Initial load
duke
parents:
diff changeset
   121
    // files into unique bits positions: ACC_SYNTHETIC <-> SYNTHETIC,
06bc494ca11e Initial load
duke
parents:
diff changeset
   122
    // for example.
06bc494ca11e Initial load
duke
parents:
diff changeset
   123
    public static final int ACC_SUPER    = 0x0020;
06bc494ca11e Initial load
duke
parents:
diff changeset
   124
    public static final int ACC_BRIDGE   = 0x0040;
06bc494ca11e Initial load
duke
parents:
diff changeset
   125
    public static final int ACC_VARARGS  = 0x0080;
06bc494ca11e Initial load
duke
parents:
diff changeset
   126
06bc494ca11e Initial load
duke
parents:
diff changeset
   127
    /*****************************************
06bc494ca11e Initial load
duke
parents:
diff changeset
   128
     * Internal compiler flags (no bits in the lower 16).
06bc494ca11e Initial load
duke
parents:
diff changeset
   129
     *****************************************/
06bc494ca11e Initial load
duke
parents:
diff changeset
   130
06bc494ca11e Initial load
duke
parents:
diff changeset
   131
    /** Flag is set if symbol is deprecated.
06bc494ca11e Initial load
duke
parents:
diff changeset
   132
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   133
    public static final int DEPRECATED   = 1<<17;
06bc494ca11e Initial load
duke
parents:
diff changeset
   134
06bc494ca11e Initial load
duke
parents:
diff changeset
   135
    /** Flag is set for a variable symbol if the variable's definition
06bc494ca11e Initial load
duke
parents:
diff changeset
   136
     *  has an initializer part.
06bc494ca11e Initial load
duke
parents:
diff changeset
   137
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   138
    public static final int HASINIT          = 1<<18;
06bc494ca11e Initial load
duke
parents:
diff changeset
   139
06bc494ca11e Initial load
duke
parents:
diff changeset
   140
    /** Flag is set for compiler-generated anonymous method symbols
06bc494ca11e Initial load
duke
parents:
diff changeset
   141
     *  that `own' an initializer block.
06bc494ca11e Initial load
duke
parents:
diff changeset
   142
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   143
    public static final int BLOCK            = 1<<20;
06bc494ca11e Initial load
duke
parents:
diff changeset
   144
06bc494ca11e Initial load
duke
parents:
diff changeset
   145
    /** Flag is set for compiler-generated abstract methods that implement
06bc494ca11e Initial load
duke
parents:
diff changeset
   146
     *  an interface method (Miranda methods).
06bc494ca11e Initial load
duke
parents:
diff changeset
   147
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   148
    public static final int IPROXY           = 1<<21;
06bc494ca11e Initial load
duke
parents:
diff changeset
   149
06bc494ca11e Initial load
duke
parents:
diff changeset
   150
    /** Flag is set for nested classes that do not access instance members
06bc494ca11e Initial load
duke
parents:
diff changeset
   151
     *  or `this' of an outer class and therefore don't need to be passed
06bc494ca11e Initial load
duke
parents:
diff changeset
   152
     *  a this$n reference.  This flag is currently set only for anonymous
06bc494ca11e Initial load
duke
parents:
diff changeset
   153
     *  classes in superclass constructor calls and only for pre 1.4 targets.
06bc494ca11e Initial load
duke
parents:
diff changeset
   154
     *  todo: use this flag for optimizing away this$n parameters in
06bc494ca11e Initial load
duke
parents:
diff changeset
   155
     *  other cases.
06bc494ca11e Initial load
duke
parents:
diff changeset
   156
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   157
    public static final int NOOUTERTHIS  = 1<<22;
06bc494ca11e Initial load
duke
parents:
diff changeset
   158
06bc494ca11e Initial load
duke
parents:
diff changeset
   159
    /** Flag is set for package symbols if a package has a member or
06bc494ca11e Initial load
duke
parents:
diff changeset
   160
     *  directory and therefore exists.
06bc494ca11e Initial load
duke
parents:
diff changeset
   161
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   162
    public static final int EXISTS           = 1<<23;
06bc494ca11e Initial load
duke
parents:
diff changeset
   163
06bc494ca11e Initial load
duke
parents:
diff changeset
   164
    /** Flag is set for compiler-generated compound classes
06bc494ca11e Initial load
duke
parents:
diff changeset
   165
     *  representing multiple variable bounds
06bc494ca11e Initial load
duke
parents:
diff changeset
   166
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   167
    public static final int COMPOUND     = 1<<24;
06bc494ca11e Initial load
duke
parents:
diff changeset
   168
06bc494ca11e Initial load
duke
parents:
diff changeset
   169
    /** Flag is set for class symbols if a class file was found for this class.
06bc494ca11e Initial load
duke
parents:
diff changeset
   170
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   171
    public static final int CLASS_SEEN   = 1<<25;
06bc494ca11e Initial load
duke
parents:
diff changeset
   172
06bc494ca11e Initial load
duke
parents:
diff changeset
   173
    /** Flag is set for class symbols if a source file was found for this
06bc494ca11e Initial load
duke
parents:
diff changeset
   174
     *  class.
06bc494ca11e Initial load
duke
parents:
diff changeset
   175
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   176
    public static final int SOURCE_SEEN  = 1<<26;
06bc494ca11e Initial load
duke
parents:
diff changeset
   177
06bc494ca11e Initial load
duke
parents:
diff changeset
   178
    /* State flags (are reset during compilation).
06bc494ca11e Initial load
duke
parents:
diff changeset
   179
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   180
06bc494ca11e Initial load
duke
parents:
diff changeset
   181
    /** Flag for class symbols is set and later re-set as a lock in
06bc494ca11e Initial load
duke
parents:
diff changeset
   182
     *  Enter to detect cycles in the superclass/superinterface
06bc494ca11e Initial load
duke
parents:
diff changeset
   183
     *  relations.  Similarly for constructor call cycle detection in
06bc494ca11e Initial load
duke
parents:
diff changeset
   184
     *  Attr.
06bc494ca11e Initial load
duke
parents:
diff changeset
   185
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   186
    public static final int LOCKED           = 1<<27;
06bc494ca11e Initial load
duke
parents:
diff changeset
   187
06bc494ca11e Initial load
duke
parents:
diff changeset
   188
    /** Flag for class symbols is set and later re-set to indicate that a class
06bc494ca11e Initial load
duke
parents:
diff changeset
   189
     *  has been entered but has not yet been attributed.
06bc494ca11e Initial load
duke
parents:
diff changeset
   190
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   191
    public static final int UNATTRIBUTED = 1<<28;
06bc494ca11e Initial load
duke
parents:
diff changeset
   192
06bc494ca11e Initial load
duke
parents:
diff changeset
   193
    /** Flag for synthesized default constructors of anonymous classes.
06bc494ca11e Initial load
duke
parents:
diff changeset
   194
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   195
    public static final int ANONCONSTR   = 1<<29;
06bc494ca11e Initial load
duke
parents:
diff changeset
   196
06bc494ca11e Initial load
duke
parents:
diff changeset
   197
    /** Flag for class symbols to indicate it has been checked and found
06bc494ca11e Initial load
duke
parents:
diff changeset
   198
     *  acyclic.
06bc494ca11e Initial load
duke
parents:
diff changeset
   199
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   200
    public static final int ACYCLIC          = 1<<30;
06bc494ca11e Initial load
duke
parents:
diff changeset
   201
06bc494ca11e Initial load
duke
parents:
diff changeset
   202
    /** Flag that marks bridge methods.
06bc494ca11e Initial load
duke
parents:
diff changeset
   203
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   204
    public static final long BRIDGE          = 1L<<31;
06bc494ca11e Initial load
duke
parents:
diff changeset
   205
06bc494ca11e Initial load
duke
parents:
diff changeset
   206
    /** Flag that marks formal parameters.
06bc494ca11e Initial load
duke
parents:
diff changeset
   207
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   208
    public static final long PARAMETER   = 1L<<33;
06bc494ca11e Initial load
duke
parents:
diff changeset
   209
06bc494ca11e Initial load
duke
parents:
diff changeset
   210
    /** Flag that marks varargs methods.
06bc494ca11e Initial load
duke
parents:
diff changeset
   211
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   212
    public static final long VARARGS   = 1L<<34;
06bc494ca11e Initial load
duke
parents:
diff changeset
   213
06bc494ca11e Initial load
duke
parents:
diff changeset
   214
    /** Flag for annotation type symbols to indicate it has been
06bc494ca11e Initial load
duke
parents:
diff changeset
   215
     *  checked and found acyclic.
06bc494ca11e Initial load
duke
parents:
diff changeset
   216
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   217
    public static final long ACYCLIC_ANN      = 1L<<35;
06bc494ca11e Initial load
duke
parents:
diff changeset
   218
06bc494ca11e Initial load
duke
parents:
diff changeset
   219
    /** Flag that marks a generated default constructor.
06bc494ca11e Initial load
duke
parents:
diff changeset
   220
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   221
    public static final long GENERATEDCONSTR   = 1L<<36;
06bc494ca11e Initial load
duke
parents:
diff changeset
   222
06bc494ca11e Initial load
duke
parents:
diff changeset
   223
    /** Flag that marks a hypothetical method that need not really be
06bc494ca11e Initial load
duke
parents:
diff changeset
   224
     *  generated in the binary, but is present in the symbol table to
12335
4725d88691dd 7133185: Update 292 overload resolution logic to match JLS
mcimadamore
parents: 9300
diff changeset
   225
     *  simplify checking for erasure clashes - also used for 292 poly sig methods.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   226
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   227
    public static final long HYPOTHETICAL   = 1L<<37;
06bc494ca11e Initial load
duke
parents:
diff changeset
   228
06bc494ca11e Initial load
duke
parents:
diff changeset
   229
    /**
5848
c5a4ce47e780 6960407: Potential rebranding issues in openjdk/langtools repository sources
jjg
parents: 5847
diff changeset
   230
     * Flag that marks an internal proprietary class.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   231
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   232
    public static final long PROPRIETARY = 1L<<38;
06bc494ca11e Initial load
duke
parents:
diff changeset
   233
5492
515e4b33b335 6943289: Project Coin: Improved Exception Handling for Java (aka 'multicatch')
mcimadamore
parents: 4870
diff changeset
   234
    /**
9300
c2de4dd9853b 7033809: Rename "disjunctive" to "union" in javax.lang.model
darcy
parents: 8625
diff changeset
   235
     * Flag that marks a a multi-catch parameter
5492
515e4b33b335 6943289: Project Coin: Improved Exception Handling for Java (aka 'multicatch')
mcimadamore
parents: 4870
diff changeset
   236
     */
9300
c2de4dd9853b 7033809: Rename "disjunctive" to "union" in javax.lang.model
darcy
parents: 8625
diff changeset
   237
    public static final long UNION = 1L<<39;
5492
515e4b33b335 6943289: Project Coin: Improved Exception Handling for Java (aka 'multicatch')
mcimadamore
parents: 4870
diff changeset
   238
5738
jrose
parents: 5520 5736
diff changeset
   239
    /**
6591
a953c8c6b85e 6337171: javac should create bridge methods when type variable bounds restricted
mcimadamore
parents: 5857
diff changeset
   240
     * Flag that marks a special kind of bridge methods (the ones that
a953c8c6b85e 6337171: javac should create bridge methods when type variable bounds restricted
mcimadamore
parents: 5857
diff changeset
   241
     * come from restricted supertype bounds)
a953c8c6b85e 6337171: javac should create bridge methods when type variable bounds restricted
mcimadamore
parents: 5857
diff changeset
   242
     */
12335
4725d88691dd 7133185: Update 292 overload resolution logic to match JLS
mcimadamore
parents: 9300
diff changeset
   243
    public static final long OVERRIDE_BRIDGE = 1L<<40;
6591
a953c8c6b85e 6337171: javac should create bridge methods when type variable bounds restricted
mcimadamore
parents: 5857
diff changeset
   244
7203
1153590927f7 6993963: Project Coin: Use precise exception analysis for effectively final catch parameters
mcimadamore
parents: 7074
diff changeset
   245
    /**
1153590927f7 6993963: Project Coin: Use precise exception analysis for effectively final catch parameters
mcimadamore
parents: 7074
diff changeset
   246
     * Flag that marks an 'effectively final' local variable
1153590927f7 6993963: Project Coin: Use precise exception analysis for effectively final catch parameters
mcimadamore
parents: 7074
diff changeset
   247
     */
12335
4725d88691dd 7133185: Update 292 overload resolution logic to match JLS
mcimadamore
parents: 9300
diff changeset
   248
    public static final long EFFECTIVELY_FINAL = 1L<<41;
7203
1153590927f7 6993963: Project Coin: Use precise exception analysis for effectively final catch parameters
mcimadamore
parents: 7074
diff changeset
   249
8228
4e6ee38974b2 6910550: javac 1.5.0_17 fails with incorrect error message
mcimadamore
parents: 7681
diff changeset
   250
    /**
4e6ee38974b2 6910550: javac 1.5.0_17 fails with incorrect error message
mcimadamore
parents: 7681
diff changeset
   251
     * Flag that marks non-override equivalent methods with the same signature
4e6ee38974b2 6910550: javac 1.5.0_17 fails with incorrect error message
mcimadamore
parents: 7681
diff changeset
   252
     */
12335
4725d88691dd 7133185: Update 292 overload resolution logic to match JLS
mcimadamore
parents: 9300
diff changeset
   253
    public static final long CLASH = 1L<<42;
8228
4e6ee38974b2 6910550: javac 1.5.0_17 fails with incorrect error message
mcimadamore
parents: 7681
diff changeset
   254
14267
6321fbe0cf50 7192245: Add parser support for default methods
mcimadamore
parents: 14258
diff changeset
   255
    /**
6321fbe0cf50 7192245: Add parser support for default methods
mcimadamore
parents: 14258
diff changeset
   256
     * Flag that marks either a default method or an interface containing default methods
6321fbe0cf50 7192245: Add parser support for default methods
mcimadamore
parents: 14258
diff changeset
   257
     */
6321fbe0cf50 7192245: Add parser support for default methods
mcimadamore
parents: 14258
diff changeset
   258
    public static final long DEFAULT = 1L<<43;
6321fbe0cf50 7192245: Add parser support for default methods
mcimadamore
parents: 14258
diff changeset
   259
14369
3d660d08d1f7 7153951: Add new lint option -Xlint:auxiliaryclass
ohrstrom
parents: 14267
diff changeset
   260
    /**
3d660d08d1f7 7153951: Add new lint option -Xlint:auxiliaryclass
ohrstrom
parents: 14267
diff changeset
   261
     * Flag that marks class as auxiliary, ie a non-public class following
3d660d08d1f7 7153951: Add new lint option -Xlint:auxiliaryclass
ohrstrom
parents: 14267
diff changeset
   262
     * the public class in a source file, that could block implicit compilation.
3d660d08d1f7 7153951: Add new lint option -Xlint:auxiliaryclass
ohrstrom
parents: 14267
diff changeset
   263
     */
3d660d08d1f7 7153951: Add new lint option -Xlint:auxiliaryclass
ohrstrom
parents: 14267
diff changeset
   264
    public static final long AUXILIARY = 1L<<43;
3d660d08d1f7 7153951: Add new lint option -Xlint:auxiliaryclass
ohrstrom
parents: 14267
diff changeset
   265
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   266
    /** Modifier masks.
06bc494ca11e Initial load
duke
parents:
diff changeset
   267
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   268
    public static final int
06bc494ca11e Initial load
duke
parents:
diff changeset
   269
        AccessFlags           = PUBLIC | PROTECTED | PRIVATE,
06bc494ca11e Initial load
duke
parents:
diff changeset
   270
        LocalClassFlags       = FINAL | ABSTRACT | STRICTFP | ENUM | SYNTHETIC,
06bc494ca11e Initial load
duke
parents:
diff changeset
   271
        MemberClassFlags      = LocalClassFlags | INTERFACE | AccessFlags,
06bc494ca11e Initial load
duke
parents:
diff changeset
   272
        ClassFlags            = LocalClassFlags | INTERFACE | PUBLIC | ANNOTATION,
06bc494ca11e Initial load
duke
parents:
diff changeset
   273
        InterfaceVarFlags     = FINAL | STATIC | PUBLIC,
06bc494ca11e Initial load
duke
parents:
diff changeset
   274
        VarFlags              = AccessFlags | FINAL | STATIC |
06bc494ca11e Initial load
duke
parents:
diff changeset
   275
                                VOLATILE | TRANSIENT | ENUM,
06bc494ca11e Initial load
duke
parents:
diff changeset
   276
        ConstructorFlags      = AccessFlags,
06bc494ca11e Initial load
duke
parents:
diff changeset
   277
        InterfaceMethodFlags  = ABSTRACT | PUBLIC,
06bc494ca11e Initial load
duke
parents:
diff changeset
   278
        MethodFlags           = AccessFlags | ABSTRACT | STATIC | NATIVE |
06bc494ca11e Initial load
duke
parents:
diff changeset
   279
                                SYNCHRONIZED | FINAL | STRICTFP;
06bc494ca11e Initial load
duke
parents:
diff changeset
   280
    public static final long
14267
6321fbe0cf50 7192245: Add parser support for default methods
mcimadamore
parents: 14258
diff changeset
   281
        ExtendedStandardFlags       = (long)StandardFlags | DEFAULT,
6321fbe0cf50 7192245: Add parser support for default methods
mcimadamore
parents: 14258
diff changeset
   282
        InterfaceDefaultMethodMask  = ABSTRACT | PUBLIC | STRICTFP | SYNCHRONIZED | DEFAULT,
6321fbe0cf50 7192245: Add parser support for default methods
mcimadamore
parents: 14258
diff changeset
   283
        LocalVarFlags               = FINAL | PARAMETER;
6321fbe0cf50 7192245: Add parser support for default methods
mcimadamore
parents: 14258
diff changeset
   284
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   285
06bc494ca11e Initial load
duke
parents:
diff changeset
   286
    public static Set<Modifier> asModifierSet(long flags) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   287
        Set<Modifier> modifiers = modifierSets.get(flags);
06bc494ca11e Initial load
duke
parents:
diff changeset
   288
        if (modifiers == null) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   289
            modifiers = java.util.EnumSet.noneOf(Modifier.class);
06bc494ca11e Initial load
duke
parents:
diff changeset
   290
            if (0 != (flags & PUBLIC))    modifiers.add(Modifier.PUBLIC);
06bc494ca11e Initial load
duke
parents:
diff changeset
   291
            if (0 != (flags & PROTECTED)) modifiers.add(Modifier.PROTECTED);
06bc494ca11e Initial load
duke
parents:
diff changeset
   292
            if (0 != (flags & PRIVATE))   modifiers.add(Modifier.PRIVATE);
06bc494ca11e Initial load
duke
parents:
diff changeset
   293
            if (0 != (flags & ABSTRACT))  modifiers.add(Modifier.ABSTRACT);
06bc494ca11e Initial load
duke
parents:
diff changeset
   294
            if (0 != (flags & STATIC))    modifiers.add(Modifier.STATIC);
06bc494ca11e Initial load
duke
parents:
diff changeset
   295
            if (0 != (flags & FINAL))     modifiers.add(Modifier.FINAL);
06bc494ca11e Initial load
duke
parents:
diff changeset
   296
            if (0 != (flags & TRANSIENT)) modifiers.add(Modifier.TRANSIENT);
06bc494ca11e Initial load
duke
parents:
diff changeset
   297
            if (0 != (flags & VOLATILE))  modifiers.add(Modifier.VOLATILE);
06bc494ca11e Initial load
duke
parents:
diff changeset
   298
            if (0 != (flags & SYNCHRONIZED))
06bc494ca11e Initial load
duke
parents:
diff changeset
   299
                                          modifiers.add(Modifier.SYNCHRONIZED);
06bc494ca11e Initial load
duke
parents:
diff changeset
   300
            if (0 != (flags & NATIVE))    modifiers.add(Modifier.NATIVE);
06bc494ca11e Initial load
duke
parents:
diff changeset
   301
            if (0 != (flags & STRICTFP))  modifiers.add(Modifier.STRICTFP);
06bc494ca11e Initial load
duke
parents:
diff changeset
   302
            modifiers = Collections.unmodifiableSet(modifiers);
06bc494ca11e Initial load
duke
parents:
diff changeset
   303
            modifierSets.put(flags, modifiers);
06bc494ca11e Initial load
duke
parents:
diff changeset
   304
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   305
        return modifiers;
06bc494ca11e Initial load
duke
parents:
diff changeset
   306
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   307
06bc494ca11e Initial load
duke
parents:
diff changeset
   308
    // Cache of modifier sets.
06bc494ca11e Initial load
duke
parents:
diff changeset
   309
    private static Map<Long, Set<Modifier>> modifierSets =
06bc494ca11e Initial load
duke
parents:
diff changeset
   310
        new java.util.concurrent.ConcurrentHashMap<Long, Set<Modifier>>(64);
06bc494ca11e Initial load
duke
parents:
diff changeset
   311
06bc494ca11e Initial load
duke
parents:
diff changeset
   312
    public static boolean isStatic(Symbol symbol) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   313
        return (symbol.flags() & STATIC) != 0;
06bc494ca11e Initial load
duke
parents:
diff changeset
   314
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   315
06bc494ca11e Initial load
duke
parents:
diff changeset
   316
    public static boolean isEnum(Symbol symbol) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   317
        return (symbol.flags() & ENUM) != 0;
06bc494ca11e Initial load
duke
parents:
diff changeset
   318
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   319
06bc494ca11e Initial load
duke
parents:
diff changeset
   320
    public static boolean isConstant(Symbol.VarSymbol symbol) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   321
        return symbol.getConstValue() != null;
06bc494ca11e Initial load
duke
parents:
diff changeset
   322
    }
939
38e24969c7e9 6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents: 10
diff changeset
   323
38e24969c7e9 6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents: 10
diff changeset
   324
    public enum Flag {
38e24969c7e9 6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents: 10
diff changeset
   325
38e24969c7e9 6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents: 10
diff changeset
   326
        PUBLIC("public"),
38e24969c7e9 6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents: 10
diff changeset
   327
        PRIVATE("private"),
38e24969c7e9 6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents: 10
diff changeset
   328
        PROTECTED("protected"),
38e24969c7e9 6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents: 10
diff changeset
   329
        STATIC("static"),
38e24969c7e9 6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents: 10
diff changeset
   330
        FINAL("final"),
38e24969c7e9 6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents: 10
diff changeset
   331
        SYNCHRONIZED("synchronized"),
38e24969c7e9 6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents: 10
diff changeset
   332
        VOLATILE("volatile"),
38e24969c7e9 6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents: 10
diff changeset
   333
        TRANSIENT("transient"),
38e24969c7e9 6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents: 10
diff changeset
   334
        NATIVE("native"),
38e24969c7e9 6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents: 10
diff changeset
   335
        INTERFACE("interface"),
38e24969c7e9 6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents: 10
diff changeset
   336
        ABSTRACT("abstract"),
14267
6321fbe0cf50 7192245: Add parser support for default methods
mcimadamore
parents: 14258
diff changeset
   337
        DEFAULT("default"),
939
38e24969c7e9 6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents: 10
diff changeset
   338
        STRICTFP("strictfp"),
38e24969c7e9 6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents: 10
diff changeset
   339
        BRIDGE("bridge"),
38e24969c7e9 6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents: 10
diff changeset
   340
        SYNTHETIC("synthetic"),
38e24969c7e9 6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents: 10
diff changeset
   341
        DEPRECATED("deprecated"),
38e24969c7e9 6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents: 10
diff changeset
   342
        HASINIT("hasinit"),
38e24969c7e9 6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents: 10
diff changeset
   343
        ENUM("enum"),
38e24969c7e9 6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents: 10
diff changeset
   344
        IPROXY("iproxy"),
38e24969c7e9 6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents: 10
diff changeset
   345
        NOOUTERTHIS("noouterthis"),
38e24969c7e9 6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents: 10
diff changeset
   346
        EXISTS("exists"),
38e24969c7e9 6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents: 10
diff changeset
   347
        COMPOUND("compound"),
38e24969c7e9 6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents: 10
diff changeset
   348
        CLASS_SEEN("class_seen"),
38e24969c7e9 6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents: 10
diff changeset
   349
        SOURCE_SEEN("source_seen"),
38e24969c7e9 6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents: 10
diff changeset
   350
        LOCKED("locked"),
38e24969c7e9 6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents: 10
diff changeset
   351
        UNATTRIBUTED("unattributed"),
38e24969c7e9 6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents: 10
diff changeset
   352
        ANONCONSTR("anonconstr"),
38e24969c7e9 6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents: 10
diff changeset
   353
        ACYCLIC("acyclic"),
38e24969c7e9 6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents: 10
diff changeset
   354
        PARAMETER("parameter"),
38e24969c7e9 6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents: 10
diff changeset
   355
        VARARGS("varargs"),
38e24969c7e9 6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents: 10
diff changeset
   356
        PACKAGE("package");
38e24969c7e9 6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents: 10
diff changeset
   357
38e24969c7e9 6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents: 10
diff changeset
   358
        String name;
38e24969c7e9 6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents: 10
diff changeset
   359
38e24969c7e9 6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents: 10
diff changeset
   360
        Flag(String name) {
38e24969c7e9 6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents: 10
diff changeset
   361
            this.name = name;
38e24969c7e9 6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents: 10
diff changeset
   362
        }
38e24969c7e9 6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents: 10
diff changeset
   363
38e24969c7e9 6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents: 10
diff changeset
   364
        public String toString() {
38e24969c7e9 6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents: 10
diff changeset
   365
            return name;
38e24969c7e9 6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents: 10
diff changeset
   366
        }
38e24969c7e9 6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents: 10
diff changeset
   367
    }
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   368
}