langtools/src/share/classes/com/sun/tools/javac/code/Source.java
author mcimadamore
Mon, 28 Nov 2011 16:05:46 +0000
changeset 11144 8a4ae514eedf
parent 11143 9dbe313bfb74
child 11314 b612aaca08d0
permissions -rw-r--r--
7115052: Add parser support for method references Summary: Add support for parsing method references to JavacParser Reviewed-by: jjg
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
10
06bc494ca11e Initial load
duke
parents:
diff changeset
     1
/*
9087
e9e44877cd18 7033660: Update copyright year to 2011 on any files changed in 2011
ohair
parents: 8849
diff changeset
     2
 * Copyright (c) 2002, 2011, 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
6721
d92073844278 6988436: Cleanup javac option handling
jjg
parents: 6592
diff changeset
    28
import java.util.*;
d92073844278 6988436: Cleanup javac option handling
jjg
parents: 6592
diff changeset
    29
import javax.lang.model.SourceVersion;
d92073844278 6988436: Cleanup javac option handling
jjg
parents: 6592
diff changeset
    30
import static javax.lang.model.SourceVersion.*;
d92073844278 6988436: Cleanup javac option handling
jjg
parents: 6592
diff changeset
    31
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    32
import com.sun.tools.javac.util.*;
06bc494ca11e Initial load
duke
parents:
diff changeset
    33
import com.sun.tools.javac.jvm.Target;
6721
d92073844278 6988436: Cleanup javac option handling
jjg
parents: 6592
diff changeset
    34
d92073844278 6988436: Cleanup javac option handling
jjg
parents: 6592
diff changeset
    35
import static com.sun.tools.javac.main.OptionName.*;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    36
06bc494ca11e Initial load
duke
parents:
diff changeset
    37
/** The source language version accepted.
06bc494ca11e Initial load
duke
parents:
diff changeset
    38
 *
5847
1908176fd6e3 6944312: Potential rebranding issues in openjdk/langtools repository sources
jjg
parents: 5520
diff changeset
    39
 *  <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
    40
 *  If you write code that depends on this, you do so at your own risk.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    41
 *  This code and its internal interfaces are subject to change or
06bc494ca11e Initial load
duke
parents:
diff changeset
    42
 *  deletion without notice.</b>
06bc494ca11e Initial load
duke
parents:
diff changeset
    43
 */
06bc494ca11e Initial load
duke
parents:
diff changeset
    44
public enum Source {
06bc494ca11e Initial load
duke
parents:
diff changeset
    45
    /** 1.0 had no inner classes, and so could not pass the JCK. */
06bc494ca11e Initial load
duke
parents:
diff changeset
    46
    // public static final Source JDK1_0 =              new Source("1.0");
06bc494ca11e Initial load
duke
parents:
diff changeset
    47
06bc494ca11e Initial load
duke
parents:
diff changeset
    48
    /** 1.1 did not have strictfp, and so could not pass the JCK. */
06bc494ca11e Initial load
duke
parents:
diff changeset
    49
    // public static final Source JDK1_1 =              new Source("1.1");
06bc494ca11e Initial load
duke
parents:
diff changeset
    50
06bc494ca11e Initial load
duke
parents:
diff changeset
    51
    /** 1.2 introduced strictfp. */
06bc494ca11e Initial load
duke
parents:
diff changeset
    52
    JDK1_2("1.2"),
06bc494ca11e Initial load
duke
parents:
diff changeset
    53
06bc494ca11e Initial load
duke
parents:
diff changeset
    54
    /** 1.3 is the same language as 1.2. */
06bc494ca11e Initial load
duke
parents:
diff changeset
    55
    JDK1_3("1.3"),
06bc494ca11e Initial load
duke
parents:
diff changeset
    56
06bc494ca11e Initial load
duke
parents:
diff changeset
    57
    /** 1.4 introduced assert. */
06bc494ca11e Initial load
duke
parents:
diff changeset
    58
    JDK1_4("1.4"),
06bc494ca11e Initial load
duke
parents:
diff changeset
    59
06bc494ca11e Initial load
duke
parents:
diff changeset
    60
    /** 1.5 introduced generics, attributes, foreach, boxing, static import,
06bc494ca11e Initial load
duke
parents:
diff changeset
    61
     *  covariant return, enums, varargs, et al. */
06bc494ca11e Initial load
duke
parents:
diff changeset
    62
    JDK1_5("1.5"),
06bc494ca11e Initial load
duke
parents:
diff changeset
    63
06bc494ca11e Initial load
duke
parents:
diff changeset
    64
    /** 1.6 reports encoding problems as errors instead of warnings. */
06bc494ca11e Initial load
duke
parents:
diff changeset
    65
    JDK1_6("1.6"),
06bc494ca11e Initial load
duke
parents:
diff changeset
    66
10180
b293c1f36ac4 7025784: Add SourceVersion.RELEASE_8
darcy
parents: 9595
diff changeset
    67
    /** 1.7 introduced try-with-resources, multi-catch, string switch, etc. */
b293c1f36ac4 7025784: Add SourceVersion.RELEASE_8
darcy
parents: 9595
diff changeset
    68
    JDK1_7("1.7"),
b293c1f36ac4 7025784: Add SourceVersion.RELEASE_8
darcy
parents: 9595
diff changeset
    69
b293c1f36ac4 7025784: Add SourceVersion.RELEASE_8
darcy
parents: 9595
diff changeset
    70
    /** 1.8 covers the to be determined language features that will be added in JDK 8. */
b293c1f36ac4 7025784: Add SourceVersion.RELEASE_8
darcy
parents: 9595
diff changeset
    71
    JDK1_8("1.8");
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    72
06bc494ca11e Initial load
duke
parents:
diff changeset
    73
    private static final Context.Key<Source> sourceKey
06bc494ca11e Initial load
duke
parents:
diff changeset
    74
        = new Context.Key<Source>();
06bc494ca11e Initial load
duke
parents:
diff changeset
    75
06bc494ca11e Initial load
duke
parents:
diff changeset
    76
    public static Source instance(Context context) {
06bc494ca11e Initial load
duke
parents:
diff changeset
    77
        Source instance = context.get(sourceKey);
06bc494ca11e Initial load
duke
parents:
diff changeset
    78
        if (instance == null) {
06bc494ca11e Initial load
duke
parents:
diff changeset
    79
            Options options = Options.instance(context);
6721
d92073844278 6988436: Cleanup javac option handling
jjg
parents: 6592
diff changeset
    80
            String sourceString = options.get(SOURCE);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    81
            if (sourceString != null) instance = lookup(sourceString);
06bc494ca11e Initial load
duke
parents:
diff changeset
    82
            if (instance == null) instance = DEFAULT;
06bc494ca11e Initial load
duke
parents:
diff changeset
    83
            context.put(sourceKey, instance);
06bc494ca11e Initial load
duke
parents:
diff changeset
    84
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
    85
        return instance;
06bc494ca11e Initial load
duke
parents:
diff changeset
    86
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
    87
06bc494ca11e Initial load
duke
parents:
diff changeset
    88
    public final String name;
06bc494ca11e Initial load
duke
parents:
diff changeset
    89
06bc494ca11e Initial load
duke
parents:
diff changeset
    90
    private static Map<String,Source> tab = new HashMap<String,Source>();
06bc494ca11e Initial load
duke
parents:
diff changeset
    91
    static {
06bc494ca11e Initial load
duke
parents:
diff changeset
    92
        for (Source s : values()) {
06bc494ca11e Initial load
duke
parents:
diff changeset
    93
            tab.put(s.name, s);
06bc494ca11e Initial load
duke
parents:
diff changeset
    94
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
    95
        tab.put("5", JDK1_5); // Make 5 an alias for 1.5
06bc494ca11e Initial load
duke
parents:
diff changeset
    96
        tab.put("6", JDK1_6); // Make 6 an alias for 1.6
06bc494ca11e Initial load
duke
parents:
diff changeset
    97
        tab.put("7", JDK1_7); // Make 7 an alias for 1.7
10180
b293c1f36ac4 7025784: Add SourceVersion.RELEASE_8
darcy
parents: 9595
diff changeset
    98
        tab.put("8", JDK1_8); // Make 8 an alias for 1.8
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    99
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   100
06bc494ca11e Initial load
duke
parents:
diff changeset
   101
    private Source(String name) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   102
        this.name = name;
06bc494ca11e Initial load
duke
parents:
diff changeset
   103
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   104
10180
b293c1f36ac4 7025784: Add SourceVersion.RELEASE_8
darcy
parents: 9595
diff changeset
   105
    public static final Source DEFAULT = JDK1_8;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   106
06bc494ca11e Initial load
duke
parents:
diff changeset
   107
    public static Source lookup(String name) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   108
        return tab.get(name);
06bc494ca11e Initial load
duke
parents:
diff changeset
   109
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   110
06bc494ca11e Initial load
duke
parents:
diff changeset
   111
    public Target requiredTarget() {
10180
b293c1f36ac4 7025784: Add SourceVersion.RELEASE_8
darcy
parents: 9595
diff changeset
   112
        if (this.compareTo(JDK1_8) >= 0) return Target.JDK1_8;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   113
        if (this.compareTo(JDK1_7) >= 0) return Target.JDK1_7;
06bc494ca11e Initial load
duke
parents:
diff changeset
   114
        if (this.compareTo(JDK1_6) >= 0) return Target.JDK1_6;
06bc494ca11e Initial load
duke
parents:
diff changeset
   115
        if (this.compareTo(JDK1_5) >= 0) return Target.JDK1_5;
06bc494ca11e Initial load
duke
parents:
diff changeset
   116
        if (this.compareTo(JDK1_4) >= 0) return Target.JDK1_4;
06bc494ca11e Initial load
duke
parents:
diff changeset
   117
        return Target.JDK1_1;
06bc494ca11e Initial load
duke
parents:
diff changeset
   118
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   119
06bc494ca11e Initial load
duke
parents:
diff changeset
   120
    /** Allow encoding errors, giving only warnings. */
06bc494ca11e Initial load
duke
parents:
diff changeset
   121
    public boolean allowEncodingErrors() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   122
        return compareTo(JDK1_6) < 0;
06bc494ca11e Initial load
duke
parents:
diff changeset
   123
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   124
    public boolean allowAsserts() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   125
        return compareTo(JDK1_4) >= 0;
06bc494ca11e Initial load
duke
parents:
diff changeset
   126
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   127
    public boolean allowCovariantReturns() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   128
        return compareTo(JDK1_5) >= 0;
06bc494ca11e Initial load
duke
parents:
diff changeset
   129
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   130
    public boolean allowGenerics() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   131
        return compareTo(JDK1_5) >= 0;
06bc494ca11e Initial load
duke
parents:
diff changeset
   132
    }
5321
c8efe769cb3b 6939620: Switch to 'complex' diamond inference scheme
mcimadamore
parents: 5320
diff changeset
   133
    public boolean allowDiamond() {
c8efe769cb3b 6939620: Switch to 'complex' diamond inference scheme
mcimadamore
parents: 5320
diff changeset
   134
        return compareTo(JDK1_7) >= 0;
c8efe769cb3b 6939620: Switch to 'complex' diamond inference scheme
mcimadamore
parents: 5320
diff changeset
   135
    }
5492
515e4b33b335 6943289: Project Coin: Improved Exception Handling for Java (aka 'multicatch')
mcimadamore
parents: 5321
diff changeset
   136
    public boolean allowMulticatch() {
515e4b33b335 6943289: Project Coin: Improved Exception Handling for Java (aka 'multicatch')
mcimadamore
parents: 5321
diff changeset
   137
        return compareTo(JDK1_7) >= 0;
515e4b33b335 6943289: Project Coin: Improved Exception Handling for Java (aka 'multicatch')
mcimadamore
parents: 5321
diff changeset
   138
    }
8849
4189ac38ddc9 6558548: The compiler needs to be aligned with clarified specification of throws
mcimadamore
parents: 7681
diff changeset
   139
    public boolean allowImprovedRethrowAnalysis() {
4189ac38ddc9 6558548: The compiler needs to be aligned with clarified specification of throws
mcimadamore
parents: 7681
diff changeset
   140
        return compareTo(JDK1_7) >= 0;
4189ac38ddc9 6558548: The compiler needs to be aligned with clarified specification of throws
mcimadamore
parents: 7681
diff changeset
   141
    }
4189ac38ddc9 6558548: The compiler needs to be aligned with clarified specification of throws
mcimadamore
parents: 7681
diff changeset
   142
    public boolean allowImprovedCatchAnalysis() {
4189ac38ddc9 6558548: The compiler needs to be aligned with clarified specification of throws
mcimadamore
parents: 7681
diff changeset
   143
        return compareTo(JDK1_7) >= 0;
4189ac38ddc9 6558548: The compiler needs to be aligned with clarified specification of throws
mcimadamore
parents: 7681
diff changeset
   144
    }
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   145
    public boolean allowEnums() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   146
        return compareTo(JDK1_5) >= 0;
06bc494ca11e Initial load
duke
parents:
diff changeset
   147
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   148
    public boolean allowForeach() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   149
        return compareTo(JDK1_5) >= 0;
06bc494ca11e Initial load
duke
parents:
diff changeset
   150
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   151
    public boolean allowStaticImport() {
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
    public boolean allowBoxing() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   155
        return compareTo(JDK1_5) >= 0;
06bc494ca11e Initial load
duke
parents:
diff changeset
   156
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   157
    public boolean allowVarargs() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   158
        return compareTo(JDK1_5) >= 0;
06bc494ca11e Initial load
duke
parents:
diff changeset
   159
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   160
    public boolean allowAnnotations() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   161
        return compareTo(JDK1_5) >= 0;
06bc494ca11e Initial load
duke
parents:
diff changeset
   162
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   163
    // hex floating-point literals supported?
06bc494ca11e Initial load
duke
parents:
diff changeset
   164
    public boolean allowHexFloats() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   165
        return compareTo(JDK1_5) >= 0;
06bc494ca11e Initial load
duke
parents:
diff changeset
   166
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   167
    public boolean allowAnonOuterThis() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   168
        return compareTo(JDK1_5) >= 0;
06bc494ca11e Initial load
duke
parents:
diff changeset
   169
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   170
    public boolean addBridges() {
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
    public boolean enforceMandatoryWarnings() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   174
        return compareTo(JDK1_5) >= 0;
06bc494ca11e Initial load
duke
parents:
diff changeset
   175
    }
6148
3a8158299c51 6911256: Project Coin: Support Automatic Resource Management (ARM) blocks in the compiler
darcy
parents: 5857
diff changeset
   176
    public boolean allowTryWithResources() {
3a8158299c51 6911256: Project Coin: Support Automatic Resource Management (ARM) blocks in the compiler
darcy
parents: 5857
diff changeset
   177
        return compareTo(JDK1_7) >= 0;
3a8158299c51 6911256: Project Coin: Support Automatic Resource Management (ARM) blocks in the compiler
darcy
parents: 5857
diff changeset
   178
    }
3149
0cd06d598d6f 6843077: JSR 308: Annotations on types
jjg
parents: 2982
diff changeset
   179
    public boolean allowTypeAnnotations() {
0cd06d598d6f 6843077: JSR 308: Annotations on types
jjg
parents: 2982
diff changeset
   180
        return compareTo(JDK1_7) >= 0;
0cd06d598d6f 6843077: JSR 308: Annotations on types
jjg
parents: 2982
diff changeset
   181
    }
3895
3b3c2a1e5e8a 6860965: Project Coin: binary literals
jjg
parents: 3765
diff changeset
   182
    public boolean allowBinaryLiterals() {
3b3c2a1e5e8a 6860965: Project Coin: binary literals
jjg
parents: 3765
diff changeset
   183
        return compareTo(JDK1_7) >= 0;
3b3c2a1e5e8a 6860965: Project Coin: binary literals
jjg
parents: 3765
diff changeset
   184
    }
3b3c2a1e5e8a 6860965: Project Coin: binary literals
jjg
parents: 3765
diff changeset
   185
    public boolean allowUnderscoresInLiterals() {
3b3c2a1e5e8a 6860965: Project Coin: binary literals
jjg
parents: 3765
diff changeset
   186
        return compareTo(JDK1_7) >= 0;
3b3c2a1e5e8a 6860965: Project Coin: binary literals
jjg
parents: 3765
diff changeset
   187
    }
6592
dc56420a69bc 6979327: method handle invocation should use casts instead of type parameters to specify return type
mcimadamore
parents: 6148
diff changeset
   188
    public boolean allowStringsInSwitch() {
5736
ee0850472ca1 6939134: JSR 292 adjustments to method handle invocation
jrose
parents: 5321
diff changeset
   189
        return compareTo(JDK1_7) >= 0;
ee0850472ca1 6939134: JSR 292 adjustments to method handle invocation
jrose
parents: 5321
diff changeset
   190
    }
7643
a067a0cda531 6993978: Project Coin: Compiler support of annotation to reduce varargs warnings
mcimadamore
parents: 7330
diff changeset
   191
    public boolean allowSimplifiedVarargs() {
a067a0cda531 6993978: Project Coin: Compiler support of annotation to reduce varargs warnings
mcimadamore
parents: 7330
diff changeset
   192
        return compareTo(JDK1_7) >= 0;
a067a0cda531 6993978: Project Coin: Compiler support of annotation to reduce varargs warnings
mcimadamore
parents: 7330
diff changeset
   193
    }
9595
a7dea6cbd5f7 7038363: cast from object to primitive should be for source >= 1.7
jjg
parents: 9087
diff changeset
   194
    public boolean allowObjectToPrimitiveCast() {
a7dea6cbd5f7 7038363: cast from object to primitive should be for source >= 1.7
jjg
parents: 9087
diff changeset
   195
        return compareTo(JDK1_7) >= 0;
a7dea6cbd5f7 7038363: cast from object to primitive should be for source >= 1.7
jjg
parents: 9087
diff changeset
   196
    }
11143
9dbe313bfb74 7115050: Add parser support for lambda expressions
mcimadamore
parents: 10180
diff changeset
   197
    public boolean allowLambda() {
9dbe313bfb74 7115050: Add parser support for lambda expressions
mcimadamore
parents: 10180
diff changeset
   198
        return compareTo(JDK1_8) >= 0;
9dbe313bfb74 7115050: Add parser support for lambda expressions
mcimadamore
parents: 10180
diff changeset
   199
    }
11144
8a4ae514eedf 7115052: Add parser support for method references
mcimadamore
parents: 11143
diff changeset
   200
    public boolean allowMethodReferences() {
8a4ae514eedf 7115052: Add parser support for method references
mcimadamore
parents: 11143
diff changeset
   201
        return compareTo(JDK1_8) >= 0;
8a4ae514eedf 7115052: Add parser support for method references
mcimadamore
parents: 11143
diff changeset
   202
    }
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   203
    public static SourceVersion toSourceVersion(Source source) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   204
        switch(source) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   205
        case JDK1_2:
06bc494ca11e Initial load
duke
parents:
diff changeset
   206
            return RELEASE_2;
06bc494ca11e Initial load
duke
parents:
diff changeset
   207
        case JDK1_3:
06bc494ca11e Initial load
duke
parents:
diff changeset
   208
            return RELEASE_3;
06bc494ca11e Initial load
duke
parents:
diff changeset
   209
        case JDK1_4:
06bc494ca11e Initial load
duke
parents:
diff changeset
   210
            return RELEASE_4;
06bc494ca11e Initial load
duke
parents:
diff changeset
   211
        case JDK1_5:
06bc494ca11e Initial load
duke
parents:
diff changeset
   212
            return RELEASE_5;
06bc494ca11e Initial load
duke
parents:
diff changeset
   213
        case JDK1_6:
06bc494ca11e Initial load
duke
parents:
diff changeset
   214
            return RELEASE_6;
06bc494ca11e Initial load
duke
parents:
diff changeset
   215
        case JDK1_7:
06bc494ca11e Initial load
duke
parents:
diff changeset
   216
            return RELEASE_7;
10180
b293c1f36ac4 7025784: Add SourceVersion.RELEASE_8
darcy
parents: 9595
diff changeset
   217
        case JDK1_8:
b293c1f36ac4 7025784: Add SourceVersion.RELEASE_8
darcy
parents: 9595
diff changeset
   218
            return RELEASE_8;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   219
        default:
06bc494ca11e Initial load
duke
parents:
diff changeset
   220
            return null;
06bc494ca11e Initial load
duke
parents:
diff changeset
   221
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   222
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   223
}