src/java.compiler/share/classes/javax/lang/model/SourceVersion.java
author darcy
Wed, 13 Nov 2019 15:16:45 -0800
changeset 59068 dc45ed0ab083
parent 55382 30b1b7b4dd86
permissions -rw-r--r--
8233096: Update javax.lang.model for switch expressions Reviewed-by: jjg, jlahoda
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
10
06bc494ca11e Initial load
duke
parents:
diff changeset
     1
/*
54271
44edf64cb206 8221264: Refactor and update SourceVersion.latestSupported
darcy
parents: 53023
diff changeset
     2
 * Copyright (c) 2005, 2019, 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: 10
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: 10
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: 10
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 10
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 10
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 javax.lang.model;
06bc494ca11e Initial load
duke
parents:
diff changeset
    27
06bc494ca11e Initial load
duke
parents:
diff changeset
    28
import java.util.Collections;
06bc494ca11e Initial load
duke
parents:
diff changeset
    29
import java.util.Set;
06bc494ca11e Initial load
duke
parents:
diff changeset
    30
import java.util.HashSet;
06bc494ca11e Initial load
duke
parents:
diff changeset
    31
06bc494ca11e Initial load
duke
parents:
diff changeset
    32
/**
06bc494ca11e Initial load
duke
parents:
diff changeset
    33
 * Source versions of the Java™ programming language.
06bc494ca11e Initial load
duke
parents:
diff changeset
    34
 *
9303
eae35c201e19 7032975: API files in javax.annotation.processing need to be updated for references to JLS
jjh
parents: 5520
diff changeset
    35
 * See the appropriate edition of
eae35c201e19 7032975: API files in javax.annotation.processing need to be updated for references to JLS
jjh
parents: 5520
diff changeset
    36
 * <cite>The Java&trade; Language Specification</cite>
eae35c201e19 7032975: API files in javax.annotation.processing need to be updated for references to JLS
jjh
parents: 5520
diff changeset
    37
 * for information about a particular source version.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    38
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
    39
 * <p>Note that additional source version constants will be added to
06bc494ca11e Initial load
duke
parents:
diff changeset
    40
 * model future releases of the language.
06bc494ca11e Initial load
duke
parents:
diff changeset
    41
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
    42
 * @author Joseph D. Darcy
06bc494ca11e Initial load
duke
parents:
diff changeset
    43
 * @author Scott Seligman
06bc494ca11e Initial load
duke
parents:
diff changeset
    44
 * @author Peter von der Ah&eacute;
06bc494ca11e Initial load
duke
parents:
diff changeset
    45
 * @since 1.6
06bc494ca11e Initial load
duke
parents:
diff changeset
    46
 */
06bc494ca11e Initial load
duke
parents:
diff changeset
    47
public enum SourceVersion {
06bc494ca11e Initial load
duke
parents:
diff changeset
    48
    /*
15385
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 10180
diff changeset
    49
     * Summary of language evolution
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    50
     * 1.1: nested classes
06bc494ca11e Initial load
duke
parents:
diff changeset
    51
     * 1.2: strictfp
06bc494ca11e Initial load
duke
parents:
diff changeset
    52
     * 1.3: no changes
06bc494ca11e Initial load
duke
parents:
diff changeset
    53
     * 1.4: assert
06bc494ca11e Initial load
duke
parents:
diff changeset
    54
     * 1.5: annotations, generics, autoboxing, var-args...
06bc494ca11e Initial load
duke
parents:
diff changeset
    55
     * 1.6: no changes
18660
d8332e6f4fab 8019308: Add descriptions of Java SE 7 and 8 language changes to SourceVersion
darcy
parents: 15385
diff changeset
    56
     * 1.7: diamond syntax, try-with-resources, etc.
d8332e6f4fab 8019308: Add descriptions of Java SE 7 and 8 language changes to SourceVersion
darcy
parents: 15385
diff changeset
    57
     * 1.8: lambda expressions and default methods
38534
425b30506f80 6415644: Make javax.lang.model.SourceVersion more informative
darcy
parents: 35351
diff changeset
    58
     *   9: modules, small cleanups to 1.7 and 1.8 changes
48329
984c4b99afc9 8193489: Add information about local variable type inference to SourceVersion.RELEASE_10
darcy
parents: 47475
diff changeset
    59
     *  10: local-variable type inference (var)
51198
979e4708da65 8208201: Update SourceVersion.RELEASE_11 docs to mention var for lambda param
darcy
parents: 50892
diff changeset
    60
     *  11: local-variable syntax for lambda parameters
59068
dc45ed0ab083 8233096: Update javax.lang.model for switch expressions
darcy
parents: 55382
diff changeset
    61
     *  12: no changes (switch expressions in preview)
55318
040e1c6dab96 8225532: Update source enums to describe 12 and 13 language features
darcy
parents: 55306
diff changeset
    62
     *  13: no changes (switch expressions and text blocks in preview)
59068
dc45ed0ab083 8233096: Update javax.lang.model for switch expressions
darcy
parents: 55382
diff changeset
    63
     *  14: switch expressions
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    64
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
    65
06bc494ca11e Initial load
duke
parents:
diff changeset
    66
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    67
     * The original version.
06bc494ca11e Initial load
duke
parents:
diff changeset
    68
     *
9303
eae35c201e19 7032975: API files in javax.annotation.processing need to be updated for references to JLS
jjh
parents: 5520
diff changeset
    69
     * The language described in
eae35c201e19 7032975: API files in javax.annotation.processing need to be updated for references to JLS
jjh
parents: 5520
diff changeset
    70
     * <cite>The Java&trade; Language Specification, First Edition</cite>.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    71
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
    72
    RELEASE_0,
06bc494ca11e Initial load
duke
parents:
diff changeset
    73
06bc494ca11e Initial load
duke
parents:
diff changeset
    74
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    75
     * The version recognized by the Java Platform 1.1.
06bc494ca11e Initial load
duke
parents:
diff changeset
    76
     *
9303
eae35c201e19 7032975: API files in javax.annotation.processing need to be updated for references to JLS
jjh
parents: 5520
diff changeset
    77
     * The language is {@code RELEASE_0} augmented with nested classes as described in the 1.1 update to
eae35c201e19 7032975: API files in javax.annotation.processing need to be updated for references to JLS
jjh
parents: 5520
diff changeset
    78
     * <cite>The Java&trade; Language Specification, First Edition</cite>.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    79
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
    80
    RELEASE_1,
06bc494ca11e Initial load
duke
parents:
diff changeset
    81
06bc494ca11e Initial load
duke
parents:
diff changeset
    82
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    83
     * The version recognized by the Java 2 Platform, Standard Edition,
06bc494ca11e Initial load
duke
parents:
diff changeset
    84
     * v 1.2.
06bc494ca11e Initial load
duke
parents:
diff changeset
    85
     *
9303
eae35c201e19 7032975: API files in javax.annotation.processing need to be updated for references to JLS
jjh
parents: 5520
diff changeset
    86
     * The language described in
eae35c201e19 7032975: API files in javax.annotation.processing need to be updated for references to JLS
jjh
parents: 5520
diff changeset
    87
     * <cite>The Java&trade; Language Specification,
eae35c201e19 7032975: API files in javax.annotation.processing need to be updated for references to JLS
jjh
parents: 5520
diff changeset
    88
     * Second Edition</cite>, which includes the {@code
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    89
     * strictfp} modifier.
06bc494ca11e Initial load
duke
parents:
diff changeset
    90
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
    91
    RELEASE_2,
06bc494ca11e Initial load
duke
parents:
diff changeset
    92
06bc494ca11e Initial load
duke
parents:
diff changeset
    93
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    94
     * The version recognized by the Java 2 Platform, Standard Edition,
06bc494ca11e Initial load
duke
parents:
diff changeset
    95
     * v 1.3.
06bc494ca11e Initial load
duke
parents:
diff changeset
    96
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
    97
     * No major changes from {@code RELEASE_2}.
06bc494ca11e Initial load
duke
parents:
diff changeset
    98
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
    99
    RELEASE_3,
06bc494ca11e Initial load
duke
parents:
diff changeset
   100
06bc494ca11e Initial load
duke
parents:
diff changeset
   101
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   102
     * The version recognized by the Java 2 Platform, Standard Edition,
06bc494ca11e Initial load
duke
parents:
diff changeset
   103
     * v 1.4.
06bc494ca11e Initial load
duke
parents:
diff changeset
   104
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   105
     * Added a simple assertion facility.
06bc494ca11e Initial load
duke
parents:
diff changeset
   106
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   107
    RELEASE_4,
06bc494ca11e Initial load
duke
parents:
diff changeset
   108
06bc494ca11e Initial load
duke
parents:
diff changeset
   109
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   110
     * The version recognized by the Java 2 Platform, Standard
06bc494ca11e Initial load
duke
parents:
diff changeset
   111
     * Edition 5.0.
06bc494ca11e Initial load
duke
parents:
diff changeset
   112
     *
9303
eae35c201e19 7032975: API files in javax.annotation.processing need to be updated for references to JLS
jjh
parents: 5520
diff changeset
   113
     * The language described in
eae35c201e19 7032975: API files in javax.annotation.processing need to be updated for references to JLS
jjh
parents: 5520
diff changeset
   114
     * <cite>The Java&trade; Language Specification,
eae35c201e19 7032975: API files in javax.annotation.processing need to be updated for references to JLS
jjh
parents: 5520
diff changeset
   115
     * Third Edition</cite>.  First release to support
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   116
     * generics, annotations, autoboxing, var-args, enhanced {@code
06bc494ca11e Initial load
duke
parents:
diff changeset
   117
     * for} loop, and hexadecimal floating-point literals.
06bc494ca11e Initial load
duke
parents:
diff changeset
   118
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   119
    RELEASE_5,
06bc494ca11e Initial load
duke
parents:
diff changeset
   120
06bc494ca11e Initial load
duke
parents:
diff changeset
   121
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   122
     * The version recognized by the Java Platform, Standard Edition
06bc494ca11e Initial load
duke
parents:
diff changeset
   123
     * 6.
06bc494ca11e Initial load
duke
parents:
diff changeset
   124
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   125
     * No major changes from {@code RELEASE_5}.
06bc494ca11e Initial load
duke
parents:
diff changeset
   126
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   127
    RELEASE_6,
06bc494ca11e Initial load
duke
parents:
diff changeset
   128
06bc494ca11e Initial load
duke
parents:
diff changeset
   129
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   130
     * The version recognized by the Java Platform, Standard Edition
06bc494ca11e Initial load
duke
parents:
diff changeset
   131
     * 7.
06bc494ca11e Initial load
duke
parents:
diff changeset
   132
     *
18660
d8332e6f4fab 8019308: Add descriptions of Java SE 7 and 8 language changes to SourceVersion
darcy
parents: 15385
diff changeset
   133
     * Additions in this release include, diamond syntax for
d8332e6f4fab 8019308: Add descriptions of Java SE 7 and 8 language changes to SourceVersion
darcy
parents: 15385
diff changeset
   134
     * constructors, {@code try}-with-resources, strings in switch,
d8332e6f4fab 8019308: Add descriptions of Java SE 7 and 8 language changes to SourceVersion
darcy
parents: 15385
diff changeset
   135
     * binary literals, and multi-catch.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   136
     * @since 1.7
06bc494ca11e Initial load
duke
parents:
diff changeset
   137
     */
10180
b293c1f36ac4 7025784: Add SourceVersion.RELEASE_8
darcy
parents: 9303
diff changeset
   138
    RELEASE_7,
b293c1f36ac4 7025784: Add SourceVersion.RELEASE_8
darcy
parents: 9303
diff changeset
   139
b293c1f36ac4 7025784: Add SourceVersion.RELEASE_8
darcy
parents: 9303
diff changeset
   140
    /**
b293c1f36ac4 7025784: Add SourceVersion.RELEASE_8
darcy
parents: 9303
diff changeset
   141
     * The version recognized by the Java Platform, Standard Edition
b293c1f36ac4 7025784: Add SourceVersion.RELEASE_8
darcy
parents: 9303
diff changeset
   142
     * 8.
b293c1f36ac4 7025784: Add SourceVersion.RELEASE_8
darcy
parents: 9303
diff changeset
   143
     *
18660
d8332e6f4fab 8019308: Add descriptions of Java SE 7 and 8 language changes to SourceVersion
darcy
parents: 15385
diff changeset
   144
     * Additions in this release include lambda expressions and default methods.
10180
b293c1f36ac4 7025784: Add SourceVersion.RELEASE_8
darcy
parents: 9303
diff changeset
   145
     * @since 1.8
b293c1f36ac4 7025784: Add SourceVersion.RELEASE_8
darcy
parents: 9303
diff changeset
   146
     */
22169
4be6dc44489b 8028543: Add SourceVersion.RELEASE_9
darcy
parents: 22163
diff changeset
   147
    RELEASE_8,
4be6dc44489b 8028543: Add SourceVersion.RELEASE_9
darcy
parents: 22163
diff changeset
   148
4be6dc44489b 8028543: Add SourceVersion.RELEASE_9
darcy
parents: 22163
diff changeset
   149
    /**
4be6dc44489b 8028543: Add SourceVersion.RELEASE_9
darcy
parents: 22163
diff changeset
   150
     * The version recognized by the Java Platform, Standard Edition
4be6dc44489b 8028543: Add SourceVersion.RELEASE_9
darcy
parents: 22163
diff changeset
   151
     * 9.
4be6dc44489b 8028543: Add SourceVersion.RELEASE_9
darcy
parents: 22163
diff changeset
   152
     *
38534
425b30506f80 6415644: Make javax.lang.model.SourceVersion more informative
darcy
parents: 35351
diff changeset
   153
     * Additions in this release include modules and removal of a
425b30506f80 6415644: Make javax.lang.model.SourceVersion more informative
darcy
parents: 35351
diff changeset
   154
     * single underscore from the set of legal identifier names.
425b30506f80 6415644: Make javax.lang.model.SourceVersion more informative
darcy
parents: 35351
diff changeset
   155
     *
34912
954fa9df99c7 8146572: Update "@since 1.9" to "@since 9" to match java.version.specification [langtools]
jjg
parents: 34072
diff changeset
   156
     * @since 9
22169
4be6dc44489b 8028543: Add SourceVersion.RELEASE_9
darcy
parents: 22163
diff changeset
   157
     */
43646
017aba6e9260 8028544: Add SourceVersion.RELEASE_10
darcy
parents: 38534
diff changeset
   158
     RELEASE_9,
017aba6e9260 8028544: Add SourceVersion.RELEASE_10
darcy
parents: 38534
diff changeset
   159
017aba6e9260 8028544: Add SourceVersion.RELEASE_10
darcy
parents: 38534
diff changeset
   160
    /**
017aba6e9260 8028544: Add SourceVersion.RELEASE_10
darcy
parents: 38534
diff changeset
   161
     * The version recognized by the Java Platform, Standard Edition
017aba6e9260 8028544: Add SourceVersion.RELEASE_10
darcy
parents: 38534
diff changeset
   162
     * 10.
017aba6e9260 8028544: Add SourceVersion.RELEASE_10
darcy
parents: 38534
diff changeset
   163
     *
48329
984c4b99afc9 8193489: Add information about local variable type inference to SourceVersion.RELEASE_10
darcy
parents: 47475
diff changeset
   164
     * Additions in this release include local-variable type inference
984c4b99afc9 8193489: Add information about local variable type inference to SourceVersion.RELEASE_10
darcy
parents: 47475
diff changeset
   165
     * ({@code var}).
984c4b99afc9 8193489: Add information about local variable type inference to SourceVersion.RELEASE_10
darcy
parents: 47475
diff changeset
   166
     *
43646
017aba6e9260 8028544: Add SourceVersion.RELEASE_10
darcy
parents: 38534
diff changeset
   167
     * @since 10
017aba6e9260 8028544: Add SourceVersion.RELEASE_10
darcy
parents: 38534
diff changeset
   168
     */
48343
d4329843abf4 8173382: Add -source 11 and -target 11 to javac
darcy
parents: 48329
diff changeset
   169
     RELEASE_10,
d4329843abf4 8173382: Add -source 11 and -target 11 to javac
darcy
parents: 48329
diff changeset
   170
d4329843abf4 8173382: Add -source 11 and -target 11 to javac
darcy
parents: 48329
diff changeset
   171
    /**
d4329843abf4 8173382: Add -source 11 and -target 11 to javac
darcy
parents: 48329
diff changeset
   172
     * The version recognized by the Java Platform, Standard Edition
d4329843abf4 8173382: Add -source 11 and -target 11 to javac
darcy
parents: 48329
diff changeset
   173
     * 11.
d4329843abf4 8173382: Add -source 11 and -target 11 to javac
darcy
parents: 48329
diff changeset
   174
     *
51198
979e4708da65 8208201: Update SourceVersion.RELEASE_11 docs to mention var for lambda param
darcy
parents: 50892
diff changeset
   175
     * Additions in this release include local-variable syntax for
979e4708da65 8208201: Update SourceVersion.RELEASE_11 docs to mention var for lambda param
darcy
parents: 50892
diff changeset
   176
     * lambda parameters.
979e4708da65 8208201: Update SourceVersion.RELEASE_11 docs to mention var for lambda param
darcy
parents: 50892
diff changeset
   177
     *
48343
d4329843abf4 8173382: Add -source 11 and -target 11 to javac
darcy
parents: 48329
diff changeset
   178
     * @since 11
d4329843abf4 8173382: Add -source 11 and -target 11 to javac
darcy
parents: 48329
diff changeset
   179
     */
50892
a5557f24b4d4 8205615: Start of release updates for JDK 12
darcy
parents: 48538
diff changeset
   180
     RELEASE_11,
a5557f24b4d4 8205615: Start of release updates for JDK 12
darcy
parents: 48538
diff changeset
   181
a5557f24b4d4 8205615: Start of release updates for JDK 12
darcy
parents: 48538
diff changeset
   182
    /**
a5557f24b4d4 8205615: Start of release updates for JDK 12
darcy
parents: 48538
diff changeset
   183
     * The version recognized by the Java Platform, Standard Edition
a5557f24b4d4 8205615: Start of release updates for JDK 12
darcy
parents: 48538
diff changeset
   184
     * 12.
a5557f24b4d4 8205615: Start of release updates for JDK 12
darcy
parents: 48538
diff changeset
   185
     *
a5557f24b4d4 8205615: Start of release updates for JDK 12
darcy
parents: 48538
diff changeset
   186
     * @since 12
a5557f24b4d4 8205615: Start of release updates for JDK 12
darcy
parents: 48538
diff changeset
   187
     */
53023
6879069d9d94 8205626: Start of release updates for JDK 13
darcy
parents: 51198
diff changeset
   188
     RELEASE_12,
6879069d9d94 8205626: Start of release updates for JDK 13
darcy
parents: 51198
diff changeset
   189
6879069d9d94 8205626: Start of release updates for JDK 13
darcy
parents: 51198
diff changeset
   190
    /**
6879069d9d94 8205626: Start of release updates for JDK 13
darcy
parents: 51198
diff changeset
   191
     * The version recognized by the Java Platform, Standard Edition
6879069d9d94 8205626: Start of release updates for JDK 13
darcy
parents: 51198
diff changeset
   192
     * 13.
6879069d9d94 8205626: Start of release updates for JDK 13
darcy
parents: 51198
diff changeset
   193
     *
6879069d9d94 8205626: Start of release updates for JDK 13
darcy
parents: 51198
diff changeset
   194
     * @since 13
6879069d9d94 8205626: Start of release updates for JDK 13
darcy
parents: 51198
diff changeset
   195
     */
55382
30b1b7b4dd86 8214546: Start of release updates for JDK 14
darcy
parents: 55318
diff changeset
   196
     RELEASE_13,
30b1b7b4dd86 8214546: Start of release updates for JDK 14
darcy
parents: 55318
diff changeset
   197
30b1b7b4dd86 8214546: Start of release updates for JDK 14
darcy
parents: 55318
diff changeset
   198
    /**
30b1b7b4dd86 8214546: Start of release updates for JDK 14
darcy
parents: 55318
diff changeset
   199
     * The version recognized by the Java Platform, Standard Edition
30b1b7b4dd86 8214546: Start of release updates for JDK 14
darcy
parents: 55318
diff changeset
   200
     * 14.
30b1b7b4dd86 8214546: Start of release updates for JDK 14
darcy
parents: 55318
diff changeset
   201
     *
59068
dc45ed0ab083 8233096: Update javax.lang.model for switch expressions
darcy
parents: 55382
diff changeset
   202
     * Additions in this release include switch expressions.
dc45ed0ab083 8233096: Update javax.lang.model for switch expressions
darcy
parents: 55382
diff changeset
   203
     *
55382
30b1b7b4dd86 8214546: Start of release updates for JDK 14
darcy
parents: 55318
diff changeset
   204
     * @since 14
30b1b7b4dd86 8214546: Start of release updates for JDK 14
darcy
parents: 55318
diff changeset
   205
     */
30b1b7b4dd86 8214546: Start of release updates for JDK 14
darcy
parents: 55318
diff changeset
   206
     RELEASE_14;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   207
06bc494ca11e Initial load
duke
parents:
diff changeset
   208
    // Note that when adding constants for newer releases, the
06bc494ca11e Initial load
duke
parents:
diff changeset
   209
    // behavior of latest() and latestSupported() must be updated too.
06bc494ca11e Initial load
duke
parents:
diff changeset
   210
06bc494ca11e Initial load
duke
parents:
diff changeset
   211
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   212
     * Returns the latest source version that can be modeled.
06bc494ca11e Initial load
duke
parents:
diff changeset
   213
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   214
     * @return the latest source version that can be modeled
06bc494ca11e Initial load
duke
parents:
diff changeset
   215
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   216
    public static SourceVersion latest() {
55382
30b1b7b4dd86 8214546: Start of release updates for JDK 14
darcy
parents: 55318
diff changeset
   217
        return RELEASE_14;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   218
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   219
06bc494ca11e Initial load
duke
parents:
diff changeset
   220
    private static final SourceVersion latestSupported = getLatestSupported();
06bc494ca11e Initial load
duke
parents:
diff changeset
   221
54271
44edf64cb206 8221264: Refactor and update SourceVersion.latestSupported
darcy
parents: 53023
diff changeset
   222
    /*
44edf64cb206 8221264: Refactor and update SourceVersion.latestSupported
darcy
parents: 53023
diff changeset
   223
     * The integer version to enum constant mapping implemented by
44edf64cb206 8221264: Refactor and update SourceVersion.latestSupported
darcy
parents: 53023
diff changeset
   224
     * this method assumes the JEP 322: "Time-Based Release
44edf64cb206 8221264: Refactor and update SourceVersion.latestSupported
darcy
parents: 53023
diff changeset
   225
     * Versioning" scheme is in effect. This scheme began in JDK
44edf64cb206 8221264: Refactor and update SourceVersion.latestSupported
darcy
parents: 53023
diff changeset
   226
     * 10. If the JDK versioning scheme is revised, this method may
44edf64cb206 8221264: Refactor and update SourceVersion.latestSupported
darcy
parents: 53023
diff changeset
   227
     * need to be updated accordingly.
44edf64cb206 8221264: Refactor and update SourceVersion.latestSupported
darcy
parents: 53023
diff changeset
   228
     */
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   229
    private static SourceVersion getLatestSupported() {
54271
44edf64cb206 8221264: Refactor and update SourceVersion.latestSupported
darcy
parents: 53023
diff changeset
   230
        int intVersion = Runtime.version().feature();
44edf64cb206 8221264: Refactor and update SourceVersion.latestSupported
darcy
parents: 53023
diff changeset
   231
        return (intVersion >= 11) ?
55382
30b1b7b4dd86 8214546: Start of release updates for JDK 14
darcy
parents: 55318
diff changeset
   232
            valueOf("RELEASE_" + Math.min(14, intVersion)):
54271
44edf64cb206 8221264: Refactor and update SourceVersion.latestSupported
darcy
parents: 53023
diff changeset
   233
            RELEASE_10;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   234
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   235
06bc494ca11e Initial load
duke
parents:
diff changeset
   236
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   237
     * Returns the latest source version fully supported by the
54271
44edf64cb206 8221264: Refactor and update SourceVersion.latestSupported
darcy
parents: 53023
diff changeset
   238
     * current execution environment.  {@code RELEASE_9} or later must
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   239
     * be returned.
06bc494ca11e Initial load
duke
parents:
diff changeset
   240
     *
54271
44edf64cb206 8221264: Refactor and update SourceVersion.latestSupported
darcy
parents: 53023
diff changeset
   241
     * @apiNote This method is included alongside {@link latest} to
44edf64cb206 8221264: Refactor and update SourceVersion.latestSupported
darcy
parents: 53023
diff changeset
   242
     * allow identification of situations where the language model API
44edf64cb206 8221264: Refactor and update SourceVersion.latestSupported
darcy
parents: 53023
diff changeset
   243
     * is running on a platform version different than the latest
44edf64cb206 8221264: Refactor and update SourceVersion.latestSupported
darcy
parents: 53023
diff changeset
   244
     * version modeled by the API. One way that sort of situation can
44edf64cb206 8221264: Refactor and update SourceVersion.latestSupported
darcy
parents: 53023
diff changeset
   245
     * occur is if an IDE or similar tool is using the API to model
44edf64cb206 8221264: Refactor and update SourceVersion.latestSupported
darcy
parents: 53023
diff changeset
   246
     * source version <i>N</i> while running on platform version
44edf64cb206 8221264: Refactor and update SourceVersion.latestSupported
darcy
parents: 53023
diff changeset
   247
     * (<i>N</i>&nbsp;-&nbsp;1). Running in this configuration is
44edf64cb206 8221264: Refactor and update SourceVersion.latestSupported
darcy
parents: 53023
diff changeset
   248
     * supported by the API. Running an API on platform versions
44edf64cb206 8221264: Refactor and update SourceVersion.latestSupported
darcy
parents: 53023
diff changeset
   249
     * earlier than (<i>N</i>&nbsp;-&nbsp;1) or later than <i>N</i>
44edf64cb206 8221264: Refactor and update SourceVersion.latestSupported
darcy
parents: 53023
diff changeset
   250
     * may or may not work as an implementation detail. If an
44edf64cb206 8221264: Refactor and update SourceVersion.latestSupported
darcy
parents: 53023
diff changeset
   251
     * annotation processor was generating code to run under the
44edf64cb206 8221264: Refactor and update SourceVersion.latestSupported
darcy
parents: 53023
diff changeset
   252
     * current execution environment, the processor should only use
44edf64cb206 8221264: Refactor and update SourceVersion.latestSupported
darcy
parents: 53023
diff changeset
   253
     * platform features up to the {@code latestSupported} release,
44edf64cb206 8221264: Refactor and update SourceVersion.latestSupported
darcy
parents: 53023
diff changeset
   254
     * which may be earlier than the {@code latest} release.
44edf64cb206 8221264: Refactor and update SourceVersion.latestSupported
darcy
parents: 53023
diff changeset
   255
     *
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   256
     * @return the latest source version that is fully supported
06bc494ca11e Initial load
duke
parents:
diff changeset
   257
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   258
    public static SourceVersion latestSupported() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   259
        return latestSupported;
06bc494ca11e Initial load
duke
parents:
diff changeset
   260
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   261
06bc494ca11e Initial load
duke
parents:
diff changeset
   262
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   263
     * Returns whether or not {@code name} is a syntactically valid
06bc494ca11e Initial load
duke
parents:
diff changeset
   264
     * identifier (simple name) or keyword in the latest source
06bc494ca11e Initial load
duke
parents:
diff changeset
   265
     * version.  The method returns {@code true} if the name consists
06bc494ca11e Initial load
duke
parents:
diff changeset
   266
     * of an initial character for which {@link
06bc494ca11e Initial load
duke
parents:
diff changeset
   267
     * Character#isJavaIdentifierStart(int)} returns {@code true},
06bc494ca11e Initial load
duke
parents:
diff changeset
   268
     * followed only by characters for which {@link
06bc494ca11e Initial load
duke
parents:
diff changeset
   269
     * Character#isJavaIdentifierPart(int)} returns {@code true}.
47283
ce5fd3ba3fea 8187982: Update SourceVersion to mention restricted keywords
darcy
parents: 47216
diff changeset
   270
     * This pattern matches regular identifiers, keywords, restricted
55306
ea43db53de91 8223305: Compiler support for Switch Expressions
jlahoda
parents: 54271
diff changeset
   271
     * keywords, restricted identifiers and the literals {@code "true"},
ea43db53de91 8223305: Compiler support for Switch Expressions
jlahoda
parents: 54271
diff changeset
   272
     * {@code "false"}, {@code "null"}.
48499
239c7d9bb192 8187951: Update javax.lang.model.SourceVersion for "var" name
darcy
parents: 48329
diff changeset
   273
     *
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   274
     * The method returns {@code false} for all other strings.
06bc494ca11e Initial load
duke
parents:
diff changeset
   275
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   276
     * @param name the string to check
06bc494ca11e Initial load
duke
parents:
diff changeset
   277
     * @return {@code true} if this string is a
06bc494ca11e Initial load
duke
parents:
diff changeset
   278
     * syntactically valid identifier or keyword, {@code false}
06bc494ca11e Initial load
duke
parents:
diff changeset
   279
     * otherwise.
06bc494ca11e Initial load
duke
parents:
diff changeset
   280
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   281
    public static boolean isIdentifier(CharSequence name) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   282
        String id = name.toString();
06bc494ca11e Initial load
duke
parents:
diff changeset
   283
06bc494ca11e Initial load
duke
parents:
diff changeset
   284
        if (id.length() == 0) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   285
            return false;
06bc494ca11e Initial load
duke
parents:
diff changeset
   286
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   287
        int cp = id.codePointAt(0);
06bc494ca11e Initial load
duke
parents:
diff changeset
   288
        if (!Character.isJavaIdentifierStart(cp)) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   289
            return false;
06bc494ca11e Initial load
duke
parents:
diff changeset
   290
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   291
        for (int i = Character.charCount(cp);
06bc494ca11e Initial load
duke
parents:
diff changeset
   292
                i < id.length();
06bc494ca11e Initial load
duke
parents:
diff changeset
   293
                i += Character.charCount(cp)) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   294
            cp = id.codePointAt(i);
06bc494ca11e Initial load
duke
parents:
diff changeset
   295
            if (!Character.isJavaIdentifierPart(cp)) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   296
                return false;
06bc494ca11e Initial load
duke
parents:
diff changeset
   297
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   298
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   299
        return true;
06bc494ca11e Initial load
duke
parents:
diff changeset
   300
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   301
06bc494ca11e Initial load
duke
parents:
diff changeset
   302
    /**
38534
425b30506f80 6415644: Make javax.lang.model.SourceVersion more informative
darcy
parents: 35351
diff changeset
   303
     * Returns whether or not {@code name} is a syntactically valid
425b30506f80 6415644: Make javax.lang.model.SourceVersion more informative
darcy
parents: 35351
diff changeset
   304
     * qualified name in the latest source version.  Unlike {@link
425b30506f80 6415644: Make javax.lang.model.SourceVersion more informative
darcy
parents: 35351
diff changeset
   305
     * #isIdentifier isIdentifier}, this method returns {@code false}
425b30506f80 6415644: Make javax.lang.model.SourceVersion more informative
darcy
parents: 35351
diff changeset
   306
     * for keywords, boolean literals, and the null literal.
48499
239c7d9bb192 8187951: Update javax.lang.model.SourceVersion for "var" name
darcy
parents: 48329
diff changeset
   307
     *
47283
ce5fd3ba3fea 8187982: Update SourceVersion to mention restricted keywords
darcy
parents: 47216
diff changeset
   308
     * This method returns {@code true} for <i>restricted
55306
ea43db53de91 8223305: Compiler support for Switch Expressions
jlahoda
parents: 54271
diff changeset
   309
     * keywords</i> and <i>restricted identifiers</i>
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   310
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   311
     * @param name the string to check
06bc494ca11e Initial load
duke
parents:
diff changeset
   312
     * @return {@code true} if this string is a
06bc494ca11e Initial load
duke
parents:
diff changeset
   313
     * syntactically valid name, {@code false} otherwise.
47283
ce5fd3ba3fea 8187982: Update SourceVersion to mention restricted keywords
darcy
parents: 47216
diff changeset
   314
     * @jls 3.9 Keywords
9303
eae35c201e19 7032975: API files in javax.annotation.processing need to be updated for references to JLS
jjh
parents: 5520
diff changeset
   315
     * @jls 6.2 Names and Identifiers
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   316
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   317
    public static boolean isName(CharSequence name) {
38534
425b30506f80 6415644: Make javax.lang.model.SourceVersion more informative
darcy
parents: 35351
diff changeset
   318
        return isName(name, latest());
425b30506f80 6415644: Make javax.lang.model.SourceVersion more informative
darcy
parents: 35351
diff changeset
   319
    }
425b30506f80 6415644: Make javax.lang.model.SourceVersion more informative
darcy
parents: 35351
diff changeset
   320
425b30506f80 6415644: Make javax.lang.model.SourceVersion more informative
darcy
parents: 35351
diff changeset
   321
    /**
425b30506f80 6415644: Make javax.lang.model.SourceVersion more informative
darcy
parents: 35351
diff changeset
   322
     * Returns whether or not {@code name} is a syntactically valid
425b30506f80 6415644: Make javax.lang.model.SourceVersion more informative
darcy
parents: 35351
diff changeset
   323
     * qualified name in the given source version.  Unlike {@link
425b30506f80 6415644: Make javax.lang.model.SourceVersion more informative
darcy
parents: 35351
diff changeset
   324
     * #isIdentifier isIdentifier}, this method returns {@code false}
425b30506f80 6415644: Make javax.lang.model.SourceVersion more informative
darcy
parents: 35351
diff changeset
   325
     * for keywords, boolean literals, and the null literal.
48499
239c7d9bb192 8187951: Update javax.lang.model.SourceVersion for "var" name
darcy
parents: 48329
diff changeset
   326
     *
47283
ce5fd3ba3fea 8187982: Update SourceVersion to mention restricted keywords
darcy
parents: 47216
diff changeset
   327
     * This method returns {@code true} for <i>restricted
55306
ea43db53de91 8223305: Compiler support for Switch Expressions
jlahoda
parents: 54271
diff changeset
   328
     * keywords</i> and <i>restricted identifiers</i>
38534
425b30506f80 6415644: Make javax.lang.model.SourceVersion more informative
darcy
parents: 35351
diff changeset
   329
     *
425b30506f80 6415644: Make javax.lang.model.SourceVersion more informative
darcy
parents: 35351
diff changeset
   330
     * @param name the string to check
425b30506f80 6415644: Make javax.lang.model.SourceVersion more informative
darcy
parents: 35351
diff changeset
   331
     * @param version the version to use
425b30506f80 6415644: Make javax.lang.model.SourceVersion more informative
darcy
parents: 35351
diff changeset
   332
     * @return {@code true} if this string is a
425b30506f80 6415644: Make javax.lang.model.SourceVersion more informative
darcy
parents: 35351
diff changeset
   333
     * syntactically valid name, {@code false} otherwise.
47283
ce5fd3ba3fea 8187982: Update SourceVersion to mention restricted keywords
darcy
parents: 47216
diff changeset
   334
     * @jls 3.9 Keywords
38534
425b30506f80 6415644: Make javax.lang.model.SourceVersion more informative
darcy
parents: 35351
diff changeset
   335
     * @jls 6.2 Names and Identifiers
425b30506f80 6415644: Make javax.lang.model.SourceVersion more informative
darcy
parents: 35351
diff changeset
   336
     * @since 9
425b30506f80 6415644: Make javax.lang.model.SourceVersion more informative
darcy
parents: 35351
diff changeset
   337
     */
425b30506f80 6415644: Make javax.lang.model.SourceVersion more informative
darcy
parents: 35351
diff changeset
   338
    public static boolean isName(CharSequence name, SourceVersion version) {
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   339
        String id = name.toString();
06bc494ca11e Initial load
duke
parents:
diff changeset
   340
06bc494ca11e Initial load
duke
parents:
diff changeset
   341
        for(String s : id.split("\\.", -1)) {
38534
425b30506f80 6415644: Make javax.lang.model.SourceVersion more informative
darcy
parents: 35351
diff changeset
   342
            if (!isIdentifier(s) || isKeyword(s, version))
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   343
                return false;
06bc494ca11e Initial load
duke
parents:
diff changeset
   344
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   345
        return true;
06bc494ca11e Initial load
duke
parents:
diff changeset
   346
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   347
38534
425b30506f80 6415644: Make javax.lang.model.SourceVersion more informative
darcy
parents: 35351
diff changeset
   348
    /**
425b30506f80 6415644: Make javax.lang.model.SourceVersion more informative
darcy
parents: 35351
diff changeset
   349
     * Returns whether or not {@code s} is a keyword, boolean literal,
425b30506f80 6415644: Make javax.lang.model.SourceVersion more informative
darcy
parents: 35351
diff changeset
   350
     * or null literal in the latest source version.
47283
ce5fd3ba3fea 8187982: Update SourceVersion to mention restricted keywords
darcy
parents: 47216
diff changeset
   351
     * This method returns {@code false} for <i>restricted
55306
ea43db53de91 8223305: Compiler support for Switch Expressions
jlahoda
parents: 54271
diff changeset
   352
     * keywords</i> and <i>restricted identifiers</i>.
38534
425b30506f80 6415644: Make javax.lang.model.SourceVersion more informative
darcy
parents: 35351
diff changeset
   353
     *
425b30506f80 6415644: Make javax.lang.model.SourceVersion more informative
darcy
parents: 35351
diff changeset
   354
     * @param s the string to check
425b30506f80 6415644: Make javax.lang.model.SourceVersion more informative
darcy
parents: 35351
diff changeset
   355
     * @return {@code true} if {@code s} is a keyword, or boolean
425b30506f80 6415644: Make javax.lang.model.SourceVersion more informative
darcy
parents: 35351
diff changeset
   356
     * literal, or null literal, {@code false} otherwise.
425b30506f80 6415644: Make javax.lang.model.SourceVersion more informative
darcy
parents: 35351
diff changeset
   357
     * @jls 3.9 Keywords
425b30506f80 6415644: Make javax.lang.model.SourceVersion more informative
darcy
parents: 35351
diff changeset
   358
     * @jls 3.10.3 Boolean Literals
425b30506f80 6415644: Make javax.lang.model.SourceVersion more informative
darcy
parents: 35351
diff changeset
   359
     * @jls 3.10.7 The Null Literal
425b30506f80 6415644: Make javax.lang.model.SourceVersion more informative
darcy
parents: 35351
diff changeset
   360
     */
425b30506f80 6415644: Make javax.lang.model.SourceVersion more informative
darcy
parents: 35351
diff changeset
   361
    public static boolean isKeyword(CharSequence s) {
425b30506f80 6415644: Make javax.lang.model.SourceVersion more informative
darcy
parents: 35351
diff changeset
   362
        return isKeyword(s, latest());
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   363
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   364
06bc494ca11e Initial load
duke
parents:
diff changeset
   365
    /**
38534
425b30506f80 6415644: Make javax.lang.model.SourceVersion more informative
darcy
parents: 35351
diff changeset
   366
     * Returns whether or not {@code s} is a keyword, boolean literal,
425b30506f80 6415644: Make javax.lang.model.SourceVersion more informative
darcy
parents: 35351
diff changeset
   367
     * or null literal in the given source version.
47283
ce5fd3ba3fea 8187982: Update SourceVersion to mention restricted keywords
darcy
parents: 47216
diff changeset
   368
     * This method returns {@code false} for <i>restricted
55306
ea43db53de91 8223305: Compiler support for Switch Expressions
jlahoda
parents: 54271
diff changeset
   369
     * keywords</i> and <i>restricted identifiers</i>.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   370
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   371
     * @param s the string to check
38534
425b30506f80 6415644: Make javax.lang.model.SourceVersion more informative
darcy
parents: 35351
diff changeset
   372
     * @param version the version to use
425b30506f80 6415644: Make javax.lang.model.SourceVersion more informative
darcy
parents: 35351
diff changeset
   373
     * @return {@code true} if {@code s} is a keyword, or boolean
425b30506f80 6415644: Make javax.lang.model.SourceVersion more informative
darcy
parents: 35351
diff changeset
   374
     * literal, or null literal, {@code false} otherwise.
425b30506f80 6415644: Make javax.lang.model.SourceVersion more informative
darcy
parents: 35351
diff changeset
   375
     * @jls 3.9 Keywords
425b30506f80 6415644: Make javax.lang.model.SourceVersion more informative
darcy
parents: 35351
diff changeset
   376
     * @jls 3.10.3 Boolean Literals
425b30506f80 6415644: Make javax.lang.model.SourceVersion more informative
darcy
parents: 35351
diff changeset
   377
     * @jls 3.10.7 The Null Literal
425b30506f80 6415644: Make javax.lang.model.SourceVersion more informative
darcy
parents: 35351
diff changeset
   378
     * @since 9
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   379
     */
38534
425b30506f80 6415644: Make javax.lang.model.SourceVersion more informative
darcy
parents: 35351
diff changeset
   380
    public static boolean isKeyword(CharSequence s, SourceVersion version) {
425b30506f80 6415644: Make javax.lang.model.SourceVersion more informative
darcy
parents: 35351
diff changeset
   381
        String id = s.toString();
425b30506f80 6415644: Make javax.lang.model.SourceVersion more informative
darcy
parents: 35351
diff changeset
   382
        switch(id) {
425b30506f80 6415644: Make javax.lang.model.SourceVersion more informative
darcy
parents: 35351
diff changeset
   383
            // A trip through history
425b30506f80 6415644: Make javax.lang.model.SourceVersion more informative
darcy
parents: 35351
diff changeset
   384
        case "strictfp":
425b30506f80 6415644: Make javax.lang.model.SourceVersion more informative
darcy
parents: 35351
diff changeset
   385
            return version.compareTo(RELEASE_2) >= 0;
425b30506f80 6415644: Make javax.lang.model.SourceVersion more informative
darcy
parents: 35351
diff changeset
   386
425b30506f80 6415644: Make javax.lang.model.SourceVersion more informative
darcy
parents: 35351
diff changeset
   387
        case "assert":
425b30506f80 6415644: Make javax.lang.model.SourceVersion more informative
darcy
parents: 35351
diff changeset
   388
            return version.compareTo(RELEASE_4) >= 0;
425b30506f80 6415644: Make javax.lang.model.SourceVersion more informative
darcy
parents: 35351
diff changeset
   389
425b30506f80 6415644: Make javax.lang.model.SourceVersion more informative
darcy
parents: 35351
diff changeset
   390
        case "enum":
425b30506f80 6415644: Make javax.lang.model.SourceVersion more informative
darcy
parents: 35351
diff changeset
   391
            return version.compareTo(RELEASE_5) >= 0;
425b30506f80 6415644: Make javax.lang.model.SourceVersion more informative
darcy
parents: 35351
diff changeset
   392
425b30506f80 6415644: Make javax.lang.model.SourceVersion more informative
darcy
parents: 35351
diff changeset
   393
        case "_":
425b30506f80 6415644: Make javax.lang.model.SourceVersion more informative
darcy
parents: 35351
diff changeset
   394
            return version.compareTo(RELEASE_9) >= 0;
425b30506f80 6415644: Make javax.lang.model.SourceVersion more informative
darcy
parents: 35351
diff changeset
   395
425b30506f80 6415644: Make javax.lang.model.SourceVersion more informative
darcy
parents: 35351
diff changeset
   396
            // Keywords common across versions
425b30506f80 6415644: Make javax.lang.model.SourceVersion more informative
darcy
parents: 35351
diff changeset
   397
425b30506f80 6415644: Make javax.lang.model.SourceVersion more informative
darcy
parents: 35351
diff changeset
   398
            // Modifiers
425b30506f80 6415644: Make javax.lang.model.SourceVersion more informative
darcy
parents: 35351
diff changeset
   399
        case "public":    case "protected": case "private":
425b30506f80 6415644: Make javax.lang.model.SourceVersion more informative
darcy
parents: 35351
diff changeset
   400
        case "abstract":  case "static":    case "final":
425b30506f80 6415644: Make javax.lang.model.SourceVersion more informative
darcy
parents: 35351
diff changeset
   401
        case "transient": case "volatile":  case "synchronized":
425b30506f80 6415644: Make javax.lang.model.SourceVersion more informative
darcy
parents: 35351
diff changeset
   402
        case "native":
425b30506f80 6415644: Make javax.lang.model.SourceVersion more informative
darcy
parents: 35351
diff changeset
   403
425b30506f80 6415644: Make javax.lang.model.SourceVersion more informative
darcy
parents: 35351
diff changeset
   404
            // Declarations
425b30506f80 6415644: Make javax.lang.model.SourceVersion more informative
darcy
parents: 35351
diff changeset
   405
        case "class":     case "interface": case "extends":
425b30506f80 6415644: Make javax.lang.model.SourceVersion more informative
darcy
parents: 35351
diff changeset
   406
        case "package":   case "throws":    case "implements":
425b30506f80 6415644: Make javax.lang.model.SourceVersion more informative
darcy
parents: 35351
diff changeset
   407
425b30506f80 6415644: Make javax.lang.model.SourceVersion more informative
darcy
parents: 35351
diff changeset
   408
            // Primitive types and void
425b30506f80 6415644: Make javax.lang.model.SourceVersion more informative
darcy
parents: 35351
diff changeset
   409
        case "boolean":   case "byte":      case "char":
425b30506f80 6415644: Make javax.lang.model.SourceVersion more informative
darcy
parents: 35351
diff changeset
   410
        case "short":     case "int":       case "long":
425b30506f80 6415644: Make javax.lang.model.SourceVersion more informative
darcy
parents: 35351
diff changeset
   411
        case "float":     case "double":
425b30506f80 6415644: Make javax.lang.model.SourceVersion more informative
darcy
parents: 35351
diff changeset
   412
        case "void":
425b30506f80 6415644: Make javax.lang.model.SourceVersion more informative
darcy
parents: 35351
diff changeset
   413
425b30506f80 6415644: Make javax.lang.model.SourceVersion more informative
darcy
parents: 35351
diff changeset
   414
            // Control flow
425b30506f80 6415644: Make javax.lang.model.SourceVersion more informative
darcy
parents: 35351
diff changeset
   415
        case "if":      case "else":
425b30506f80 6415644: Make javax.lang.model.SourceVersion more informative
darcy
parents: 35351
diff changeset
   416
        case "try":     case "catch":    case "finally":
425b30506f80 6415644: Make javax.lang.model.SourceVersion more informative
darcy
parents: 35351
diff changeset
   417
        case "do":      case "while":
425b30506f80 6415644: Make javax.lang.model.SourceVersion more informative
darcy
parents: 35351
diff changeset
   418
        case "for":     case "continue":
425b30506f80 6415644: Make javax.lang.model.SourceVersion more informative
darcy
parents: 35351
diff changeset
   419
        case "switch":  case "case":     case "default":
425b30506f80 6415644: Make javax.lang.model.SourceVersion more informative
darcy
parents: 35351
diff changeset
   420
        case "break":   case "throw":    case "return":
425b30506f80 6415644: Make javax.lang.model.SourceVersion more informative
darcy
parents: 35351
diff changeset
   421
425b30506f80 6415644: Make javax.lang.model.SourceVersion more informative
darcy
parents: 35351
diff changeset
   422
            // Other keywords
425b30506f80 6415644: Make javax.lang.model.SourceVersion more informative
darcy
parents: 35351
diff changeset
   423
        case  "this":   case "new":      case "super":
425b30506f80 6415644: Make javax.lang.model.SourceVersion more informative
darcy
parents: 35351
diff changeset
   424
        case "import":  case "instanceof":
425b30506f80 6415644: Make javax.lang.model.SourceVersion more informative
darcy
parents: 35351
diff changeset
   425
425b30506f80 6415644: Make javax.lang.model.SourceVersion more informative
darcy
parents: 35351
diff changeset
   426
            // Forbidden!
425b30506f80 6415644: Make javax.lang.model.SourceVersion more informative
darcy
parents: 35351
diff changeset
   427
        case "goto":        case "const":
425b30506f80 6415644: Make javax.lang.model.SourceVersion more informative
darcy
parents: 35351
diff changeset
   428
425b30506f80 6415644: Make javax.lang.model.SourceVersion more informative
darcy
parents: 35351
diff changeset
   429
            // literals
425b30506f80 6415644: Make javax.lang.model.SourceVersion more informative
darcy
parents: 35351
diff changeset
   430
        case "null":         case "true":       case "false":
425b30506f80 6415644: Make javax.lang.model.SourceVersion more informative
darcy
parents: 35351
diff changeset
   431
            return true;
425b30506f80 6415644: Make javax.lang.model.SourceVersion more informative
darcy
parents: 35351
diff changeset
   432
425b30506f80 6415644: Make javax.lang.model.SourceVersion more informative
darcy
parents: 35351
diff changeset
   433
        default:
425b30506f80 6415644: Make javax.lang.model.SourceVersion more informative
darcy
parents: 35351
diff changeset
   434
            return false;
425b30506f80 6415644: Make javax.lang.model.SourceVersion more informative
darcy
parents: 35351
diff changeset
   435
        }
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   436
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   437
}