langtools/src/share/classes/com/sun/tools/javac/jvm/Target.java
author jjg
Thu, 10 Jun 2010 16:08:01 -0700
changeset 5847 1908176fd6e3
parent 5520 86e4b9a9da40
child 6592 dc56420a69bc
permissions -rw-r--r--
6944312: Potential rebranding issues in openjdk/langtools repository sources Reviewed-by: darcy
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
10
06bc494ca11e Initial load
duke
parents:
diff changeset
     1
/*
5520
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 2982
diff changeset
     2
 * Copyright (c) 2002, 2006, 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: 2982
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: 2982
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: 2982
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 2982
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 2982
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.jvm;
06bc494ca11e Initial load
duke
parents:
diff changeset
    27
06bc494ca11e Initial load
duke
parents:
diff changeset
    28
import java.util.*;
06bc494ca11e Initial load
duke
parents:
diff changeset
    29
06bc494ca11e Initial load
duke
parents:
diff changeset
    30
import com.sun.tools.javac.code.Flags;
06bc494ca11e Initial load
duke
parents:
diff changeset
    31
import com.sun.tools.javac.code.Symbol;
06bc494ca11e Initial load
duke
parents:
diff changeset
    32
import com.sun.tools.javac.util.*;
06bc494ca11e Initial load
duke
parents:
diff changeset
    33
06bc494ca11e Initial load
duke
parents:
diff changeset
    34
/** The classfile version target.
06bc494ca11e Initial load
duke
parents:
diff changeset
    35
 *
5847
1908176fd6e3 6944312: Potential rebranding issues in openjdk/langtools repository sources
jjg
parents: 5520
diff changeset
    36
 *  <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
    37
 *  If you write code that depends on this, you do so at your own risk.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    38
 *  This code and its internal interfaces are subject to change or
06bc494ca11e Initial load
duke
parents:
diff changeset
    39
 *  deletion without notice.</b>
06bc494ca11e Initial load
duke
parents:
diff changeset
    40
 */
06bc494ca11e Initial load
duke
parents:
diff changeset
    41
public enum Target {
06bc494ca11e Initial load
duke
parents:
diff changeset
    42
    JDK1_1("1.1", 45, 3),
06bc494ca11e Initial load
duke
parents:
diff changeset
    43
    JDK1_2("1.2", 46, 0),
06bc494ca11e Initial load
duke
parents:
diff changeset
    44
    JDK1_3("1.3", 47, 0),
06bc494ca11e Initial load
duke
parents:
diff changeset
    45
06bc494ca11e Initial load
duke
parents:
diff changeset
    46
    /** J2SE1.4 = Merlin. */
06bc494ca11e Initial load
duke
parents:
diff changeset
    47
    JDK1_4("1.4", 48, 0),
06bc494ca11e Initial load
duke
parents:
diff changeset
    48
06bc494ca11e Initial load
duke
parents:
diff changeset
    49
    /** Support for the JSR14 prototype compiler (targeting 1.4 VMs
06bc494ca11e Initial load
duke
parents:
diff changeset
    50
     *  augmented with a few support classes).  This is a transitional
06bc494ca11e Initial load
duke
parents:
diff changeset
    51
     *  option that will not be supported in the product.  */
06bc494ca11e Initial load
duke
parents:
diff changeset
    52
    JSR14("jsr14", 48, 0),
06bc494ca11e Initial load
duke
parents:
diff changeset
    53
06bc494ca11e Initial load
duke
parents:
diff changeset
    54
    /** The following are undocumented transitional targets that we
06bc494ca11e Initial load
duke
parents:
diff changeset
    55
     *  had used to test VM fixes in update releases.  We do not
06bc494ca11e Initial load
duke
parents:
diff changeset
    56
     *  promise to retain support for them.  */
06bc494ca11e Initial load
duke
parents:
diff changeset
    57
    JDK1_4_1("1.4.1", 48, 0),
06bc494ca11e Initial load
duke
parents:
diff changeset
    58
    JDK1_4_2("1.4.2", 48, 0),
06bc494ca11e Initial load
duke
parents:
diff changeset
    59
06bc494ca11e Initial load
duke
parents:
diff changeset
    60
    /** Tiger. */
06bc494ca11e Initial load
duke
parents:
diff changeset
    61
    JDK1_5("1.5", 49, 0),
06bc494ca11e Initial load
duke
parents:
diff changeset
    62
06bc494ca11e Initial load
duke
parents:
diff changeset
    63
    /** JDK 6. */
06bc494ca11e Initial load
duke
parents:
diff changeset
    64
    JDK1_6("1.6", 50, 0),
06bc494ca11e Initial load
duke
parents:
diff changeset
    65
06bc494ca11e Initial load
duke
parents:
diff changeset
    66
    /** JDK 7. */
06bc494ca11e Initial load
duke
parents:
diff changeset
    67
    JDK1_7("1.7", 51, 0);
06bc494ca11e Initial load
duke
parents:
diff changeset
    68
06bc494ca11e Initial load
duke
parents:
diff changeset
    69
    private static final Context.Key<Target> targetKey =
06bc494ca11e Initial load
duke
parents:
diff changeset
    70
        new Context.Key<Target>();
06bc494ca11e Initial load
duke
parents:
diff changeset
    71
06bc494ca11e Initial load
duke
parents:
diff changeset
    72
    public static Target instance(Context context) {
06bc494ca11e Initial load
duke
parents:
diff changeset
    73
        Target instance = context.get(targetKey);
06bc494ca11e Initial load
duke
parents:
diff changeset
    74
        if (instance == null) {
06bc494ca11e Initial load
duke
parents:
diff changeset
    75
            Options options = Options.instance(context);
06bc494ca11e Initial load
duke
parents:
diff changeset
    76
            String targetString = options.get("-target");
06bc494ca11e Initial load
duke
parents:
diff changeset
    77
            if (targetString != null) instance = lookup(targetString);
06bc494ca11e Initial load
duke
parents:
diff changeset
    78
            if (instance == null) instance = DEFAULT;
06bc494ca11e Initial load
duke
parents:
diff changeset
    79
            context.put(targetKey, instance);
06bc494ca11e Initial load
duke
parents:
diff changeset
    80
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
    81
        return instance;
06bc494ca11e Initial load
duke
parents:
diff changeset
    82
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
    83
06bc494ca11e Initial load
duke
parents:
diff changeset
    84
    private static Target MIN;
06bc494ca11e Initial load
duke
parents:
diff changeset
    85
    public static Target MIN() { return MIN; }
06bc494ca11e Initial load
duke
parents:
diff changeset
    86
06bc494ca11e Initial load
duke
parents:
diff changeset
    87
    private static Target MAX;
06bc494ca11e Initial load
duke
parents:
diff changeset
    88
    public static Target MAX() { return MAX; }
06bc494ca11e Initial load
duke
parents:
diff changeset
    89
06bc494ca11e Initial load
duke
parents:
diff changeset
    90
    private static Map<String,Target> tab = new HashMap<String,Target>();
06bc494ca11e Initial load
duke
parents:
diff changeset
    91
    static {
06bc494ca11e Initial load
duke
parents:
diff changeset
    92
        for (Target t : values()) {
06bc494ca11e Initial load
duke
parents:
diff changeset
    93
            if (MIN == null) MIN = t;
06bc494ca11e Initial load
duke
parents:
diff changeset
    94
            MAX = t;
06bc494ca11e Initial load
duke
parents:
diff changeset
    95
            tab.put(t.name, t);
06bc494ca11e Initial load
duke
parents:
diff changeset
    96
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
    97
        tab.put("5", JDK1_5);
06bc494ca11e Initial load
duke
parents:
diff changeset
    98
        tab.put("6", JDK1_6);
06bc494ca11e Initial load
duke
parents:
diff changeset
    99
        tab.put("7", JDK1_7);
06bc494ca11e Initial load
duke
parents:
diff changeset
   100
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   101
06bc494ca11e Initial load
duke
parents:
diff changeset
   102
    public final String name;
06bc494ca11e Initial load
duke
parents:
diff changeset
   103
    public final int majorVersion;
06bc494ca11e Initial load
duke
parents:
diff changeset
   104
    public final int minorVersion;
06bc494ca11e Initial load
duke
parents:
diff changeset
   105
    private Target(String name, int majorVersion, int minorVersion) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   106
        this.name = name;
06bc494ca11e Initial load
duke
parents:
diff changeset
   107
        this.majorVersion = majorVersion;
06bc494ca11e Initial load
duke
parents:
diff changeset
   108
        this.minorVersion = minorVersion;
06bc494ca11e Initial load
duke
parents:
diff changeset
   109
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   110
2982
090c71af18f6 6827026: Change javac source and target default to 7
jjg
parents: 2723
diff changeset
   111
    public static final Target DEFAULT = JDK1_7;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   112
06bc494ca11e Initial load
duke
parents:
diff changeset
   113
    public static Target lookup(String name) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   114
        return tab.get(name);
06bc494ca11e Initial load
duke
parents:
diff changeset
   115
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   116
06bc494ca11e Initial load
duke
parents:
diff changeset
   117
    /** In -target 1.1 and earlier, the compiler is required to emit
06bc494ca11e Initial load
duke
parents:
diff changeset
   118
     *  synthetic method definitions in abstract classes for interface
06bc494ca11e Initial load
duke
parents:
diff changeset
   119
     *  methods that are not overridden.  We call them "Miranda" methods.
06bc494ca11e Initial load
duke
parents:
diff changeset
   120
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   121
    public boolean requiresIproxy() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   122
        return compareTo(JDK1_1) <= 0;
06bc494ca11e Initial load
duke
parents:
diff changeset
   123
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   124
06bc494ca11e Initial load
duke
parents:
diff changeset
   125
    /** Beginning in 1.4, we take advantage of the possibility of emitting
06bc494ca11e Initial load
duke
parents:
diff changeset
   126
     *  code to initialize fields before calling the superclass constructor.
06bc494ca11e Initial load
duke
parents:
diff changeset
   127
     *  This is allowed by the VM spec, but the verifier refused to allow
06bc494ca11e Initial load
duke
parents:
diff changeset
   128
     *  it until 1.4.  This is necesary to translate some code involving
06bc494ca11e Initial load
duke
parents:
diff changeset
   129
     *  inner classes.  See, for example, 4030374.
06bc494ca11e Initial load
duke
parents:
diff changeset
   130
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   131
    public boolean initializeFieldsBeforeSuper() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   132
        return compareTo(JDK1_4) >= 0;
06bc494ca11e Initial load
duke
parents:
diff changeset
   133
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   134
06bc494ca11e Initial load
duke
parents:
diff changeset
   135
    /** Beginning with -target 1.2 we obey the JLS rules for binary
06bc494ca11e Initial load
duke
parents:
diff changeset
   136
     *  compatibility, emitting as the qualifying type of a reference
06bc494ca11e Initial load
duke
parents:
diff changeset
   137
     *  to a method or field the type of the qualifier.  In earlier
06bc494ca11e Initial load
duke
parents:
diff changeset
   138
     *  targets we use as the qualifying type the class in which the
06bc494ca11e Initial load
duke
parents:
diff changeset
   139
     *  member was found.  The following methods named
06bc494ca11e Initial load
duke
parents:
diff changeset
   140
     *  *binaryCompatibility() indicate places where we vary from this
06bc494ca11e Initial load
duke
parents:
diff changeset
   141
     *  general rule. */
06bc494ca11e Initial load
duke
parents:
diff changeset
   142
    public boolean obeyBinaryCompatibility() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   143
        return compareTo(JDK1_2) >= 0;
06bc494ca11e Initial load
duke
parents:
diff changeset
   144
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   145
06bc494ca11e Initial load
duke
parents:
diff changeset
   146
    /** Starting in 1.5, the compiler uses an array type as
06bc494ca11e Initial load
duke
parents:
diff changeset
   147
     *  the qualifier for method calls (such as clone) where required by
06bc494ca11e Initial load
duke
parents:
diff changeset
   148
     *  the language and VM spec.  Earlier versions of the compiler
06bc494ca11e Initial load
duke
parents:
diff changeset
   149
     *  qualified them by Object.
06bc494ca11e Initial load
duke
parents:
diff changeset
   150
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   151
    public boolean arrayBinaryCompatibility() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   152
        return compareTo(JDK1_5) >= 0;
06bc494ca11e Initial load
duke
parents:
diff changeset
   153
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   154
06bc494ca11e Initial load
duke
parents:
diff changeset
   155
    /** Beginning after 1.2, we follow the binary compatibility rules for
06bc494ca11e Initial load
duke
parents:
diff changeset
   156
     *  interface fields.  The 1.2 VMs had bugs handling interface fields
06bc494ca11e Initial load
duke
parents:
diff changeset
   157
     *  when compiled using binary compatibility (see 4400598), so this is
06bc494ca11e Initial load
duke
parents:
diff changeset
   158
     *  an accommodation to them.
06bc494ca11e Initial load
duke
parents:
diff changeset
   159
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   160
    public boolean interfaceFieldsBinaryCompatibility() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   161
        return compareTo(JDK1_2) > 0;
06bc494ca11e Initial load
duke
parents:
diff changeset
   162
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   163
06bc494ca11e Initial load
duke
parents:
diff changeset
   164
    /** Beginning in -target 1.5, we follow the binary compatibility
06bc494ca11e Initial load
duke
parents:
diff changeset
   165
     *  rules for interface methods that redefine Object methods.
06bc494ca11e Initial load
duke
parents:
diff changeset
   166
     *  Earlier VMs had bugs handling such methods compiled using binary
06bc494ca11e Initial load
duke
parents:
diff changeset
   167
     *  compatibility (see 4392595, 4398791, 4392595, 4400415).
06bc494ca11e Initial load
duke
parents:
diff changeset
   168
     *  The VMs were fixed during or soon after 1.4.  See 4392595.
06bc494ca11e Initial load
duke
parents:
diff changeset
   169
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   170
    public boolean interfaceObjectOverridesBinaryCompatibility() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   171
        return compareTo(JDK1_5) >= 0;
06bc494ca11e Initial load
duke
parents:
diff changeset
   172
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   173
06bc494ca11e Initial load
duke
parents:
diff changeset
   174
    /** Beginning in -target 1.4.2, we make synthetic variables
06bc494ca11e Initial load
duke
parents:
diff changeset
   175
     *  package-private instead of private.  This is to prevent the
06bc494ca11e Initial load
duke
parents:
diff changeset
   176
     *  necessity of access methods, which effectively relax the
06bc494ca11e Initial load
duke
parents:
diff changeset
   177
     *  protection of the field but bloat the class files and affect
06bc494ca11e Initial load
duke
parents:
diff changeset
   178
     *  execution.
06bc494ca11e Initial load
duke
parents:
diff changeset
   179
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   180
    public boolean usePrivateSyntheticFields() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   181
        return compareTo(JDK1_4_2) < 0;
06bc494ca11e Initial load
duke
parents:
diff changeset
   182
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   183
06bc494ca11e Initial load
duke
parents:
diff changeset
   184
    /** Sometimes we need to create a field to cache a value like a
06bc494ca11e Initial load
duke
parents:
diff changeset
   185
     *  class literal of the assertions flag.  In -target 1.4.2 and
06bc494ca11e Initial load
duke
parents:
diff changeset
   186
     *  later we create a new synthetic class for this instead of
06bc494ca11e Initial load
duke
parents:
diff changeset
   187
     *  using the outermost class.  See 4401576.
06bc494ca11e Initial load
duke
parents:
diff changeset
   188
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   189
    public boolean useInnerCacheClass() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   190
        return compareTo(JDK1_4_2) >= 0;
06bc494ca11e Initial load
duke
parents:
diff changeset
   191
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   192
06bc494ca11e Initial load
duke
parents:
diff changeset
   193
    /** Return true if cldc-style stack maps need to be generated. */
06bc494ca11e Initial load
duke
parents:
diff changeset
   194
    public boolean generateCLDCStackmap() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   195
        return false;
06bc494ca11e Initial load
duke
parents:
diff changeset
   196
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   197
06bc494ca11e Initial load
duke
parents:
diff changeset
   198
    /** Beginning in -target 6, we generate stackmap attribute in
06bc494ca11e Initial load
duke
parents:
diff changeset
   199
     *  compact format. */
06bc494ca11e Initial load
duke
parents:
diff changeset
   200
    public boolean generateStackMapTable() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   201
        return compareTo(JDK1_6) >= 0;
06bc494ca11e Initial load
duke
parents:
diff changeset
   202
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   203
06bc494ca11e Initial load
duke
parents:
diff changeset
   204
    /** Beginning in -target 6, package-info classes are marked synthetic.
06bc494ca11e Initial load
duke
parents:
diff changeset
   205
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   206
    public boolean isPackageInfoSynthetic() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   207
        return compareTo(JDK1_6) >= 0;
06bc494ca11e Initial load
duke
parents:
diff changeset
   208
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   209
06bc494ca11e Initial load
duke
parents:
diff changeset
   210
    /** Do we generate "empty" stackmap slots after double and long?
06bc494ca11e Initial load
duke
parents:
diff changeset
   211
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   212
    public boolean generateEmptyAfterBig() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   213
        return false;
06bc494ca11e Initial load
duke
parents:
diff changeset
   214
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   215
06bc494ca11e Initial load
duke
parents:
diff changeset
   216
    /** Beginning in 1.5, we have an unsynchronized version of
06bc494ca11e Initial load
duke
parents:
diff changeset
   217
     *  StringBuffer called StringBuilder that can be used by the
06bc494ca11e Initial load
duke
parents:
diff changeset
   218
     *  compiler for string concatenation.
06bc494ca11e Initial load
duke
parents:
diff changeset
   219
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   220
    public boolean useStringBuilder() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   221
        return compareTo(JDK1_5) >= 0;
06bc494ca11e Initial load
duke
parents:
diff changeset
   222
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   223
06bc494ca11e Initial load
duke
parents:
diff changeset
   224
    /** Beginning in 1.5, we have flag bits we can use instead of
06bc494ca11e Initial load
duke
parents:
diff changeset
   225
     *  marker attributes.
06bc494ca11e Initial load
duke
parents:
diff changeset
   226
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   227
    public boolean useSyntheticFlag() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   228
        return compareTo(JDK1_5) >= 0;
06bc494ca11e Initial load
duke
parents:
diff changeset
   229
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   230
    public boolean useEnumFlag() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   231
        return compareTo(JDK1_5) >= 0;
06bc494ca11e Initial load
duke
parents:
diff changeset
   232
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   233
    public boolean useAnnotationFlag() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   234
        return compareTo(JDK1_5) >= 0;
06bc494ca11e Initial load
duke
parents:
diff changeset
   235
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   236
    public boolean useVarargsFlag() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   237
        return compareTo(JDK1_5) >= 0;
06bc494ca11e Initial load
duke
parents:
diff changeset
   238
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   239
    public boolean useBridgeFlag() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   240
        return compareTo(JDK1_5) >= 0;
06bc494ca11e Initial load
duke
parents:
diff changeset
   241
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   242
06bc494ca11e Initial load
duke
parents:
diff changeset
   243
    /** Return the character to be used in constructing synthetic
06bc494ca11e Initial load
duke
parents:
diff changeset
   244
     *  identifiers, where not specified by the JLS.
06bc494ca11e Initial load
duke
parents:
diff changeset
   245
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   246
    public char syntheticNameChar() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   247
        return '$';
06bc494ca11e Initial load
duke
parents:
diff changeset
   248
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   249
06bc494ca11e Initial load
duke
parents:
diff changeset
   250
    /** Does the VM have direct support for class literals?
06bc494ca11e Initial load
duke
parents:
diff changeset
   251
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   252
    public boolean hasClassLiterals() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   253
        return compareTo(JDK1_5) >= 0;
06bc494ca11e Initial load
duke
parents:
diff changeset
   254
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   255
2723
b659ca23d5f5 6829189: Java programming with JSR 292 needs language support
jrose
parents: 10
diff changeset
   256
    /** Does the VM support an invokedynamic instruction?
b659ca23d5f5 6829189: Java programming with JSR 292 needs language support
jrose
parents: 10
diff changeset
   257
     */
b659ca23d5f5 6829189: Java programming with JSR 292 needs language support
jrose
parents: 10
diff changeset
   258
    public boolean hasInvokedynamic() {
b659ca23d5f5 6829189: Java programming with JSR 292 needs language support
jrose
parents: 10
diff changeset
   259
        return compareTo(JDK1_7) >= 0;
b659ca23d5f5 6829189: Java programming with JSR 292 needs language support
jrose
parents: 10
diff changeset
   260
    }
b659ca23d5f5 6829189: Java programming with JSR 292 needs language support
jrose
parents: 10
diff changeset
   261
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   262
    /** Although we may not have support for class literals, should we
06bc494ca11e Initial load
duke
parents:
diff changeset
   263
     *  avoid initializing the class that the literal refers to?
06bc494ca11e Initial load
duke
parents:
diff changeset
   264
     *  See 4468823
06bc494ca11e Initial load
duke
parents:
diff changeset
   265
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   266
    public boolean classLiteralsNoInit() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   267
        return compareTo(JDK1_4_2) >= 0;
06bc494ca11e Initial load
duke
parents:
diff changeset
   268
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   269
06bc494ca11e Initial load
duke
parents:
diff changeset
   270
    /** Although we may not have support for class literals, when we
06bc494ca11e Initial load
duke
parents:
diff changeset
   271
     *  throw a NoClassDefFoundError, should we initialize its cause?
06bc494ca11e Initial load
duke
parents:
diff changeset
   272
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   273
    public boolean hasInitCause() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   274
        return compareTo(JDK1_4) >= 0;
06bc494ca11e Initial load
duke
parents:
diff changeset
   275
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   276
06bc494ca11e Initial load
duke
parents:
diff changeset
   277
    /** For bootstrapping, we use J2SE1.4's wrapper class constructors
06bc494ca11e Initial load
duke
parents:
diff changeset
   278
     *  to implement boxing.
06bc494ca11e Initial load
duke
parents:
diff changeset
   279
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   280
    public boolean boxWithConstructors() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   281
        return compareTo(JDK1_5) < 0;
06bc494ca11e Initial load
duke
parents:
diff changeset
   282
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   283
06bc494ca11e Initial load
duke
parents:
diff changeset
   284
    /** For bootstrapping, we use J2SE1.4's java.util.Collection
06bc494ca11e Initial load
duke
parents:
diff changeset
   285
     *  instead of java.lang.Iterable.
06bc494ca11e Initial load
duke
parents:
diff changeset
   286
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   287
    public boolean hasIterable() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   288
        return compareTo(JDK1_5) >= 0;
06bc494ca11e Initial load
duke
parents:
diff changeset
   289
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   290
06bc494ca11e Initial load
duke
parents:
diff changeset
   291
    /** For bootstrapping javac only, we do without java.lang.Enum if
06bc494ca11e Initial load
duke
parents:
diff changeset
   292
     *  necessary.
06bc494ca11e Initial load
duke
parents:
diff changeset
   293
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   294
    public boolean compilerBootstrap(Symbol c) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   295
        return
06bc494ca11e Initial load
duke
parents:
diff changeset
   296
            this == JSR14 &&
06bc494ca11e Initial load
duke
parents:
diff changeset
   297
            (c.flags() & Flags.ENUM) != 0 &&
06bc494ca11e Initial load
duke
parents:
diff changeset
   298
            c.flatName().toString().startsWith("com.sun.tools.")
06bc494ca11e Initial load
duke
parents:
diff changeset
   299
            // && !Target.class.getSuperclass().getName().equals("java.lang.Enum")
06bc494ca11e Initial load
duke
parents:
diff changeset
   300
            ;
06bc494ca11e Initial load
duke
parents:
diff changeset
   301
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   302
06bc494ca11e Initial load
duke
parents:
diff changeset
   303
    /** In J2SE1.5.0, we introduced the "EnclosingMethod" attribute
06bc494ca11e Initial load
duke
parents:
diff changeset
   304
     *  for improved reflection support.
06bc494ca11e Initial load
duke
parents:
diff changeset
   305
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   306
    public boolean hasEnclosingMethodAttribute() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   307
        return compareTo(JDK1_5) >= 0 || this == JSR14;
06bc494ca11e Initial load
duke
parents:
diff changeset
   308
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   309
}