src/jdk.compiler/share/classes/com/sun/tools/javac/code/Source.java
branchdatagramsocketimpl-branch
changeset 58678 9cf78a70fa4f
parent 53232 32c6cc430526
child 58679 9c3209ff7550
equal deleted inserted replaced
58677:13588c901957 58678:9cf78a70fa4f
     1 /*
     1 /*
     2  * Copyright (c) 2002, 2018, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 2002, 2019, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.  Oracle designates this
     7  * published by the Free Software Foundation.  Oracle designates this
    82     JDK10("10"),
    82     JDK10("10"),
    83 
    83 
    84     /** 1.11 local-variable syntax for lambda parameters */
    84     /** 1.11 local-variable syntax for lambda parameters */
    85     JDK11("11"),
    85     JDK11("11"),
    86 
    86 
    87     /** 12 covers the to be determined language features that will be added in JDK 12. */
    87     /** 12, no language features; switch expression were in preview */
    88     JDK12("12"),
    88     JDK12("12"),
    89 
    89 
    90     /** 13 covers the to be determined language features that will be added in JDK 13. */
    90     /**
    91     JDK13("13");
    91      * 13, no language features; text blocks and revised switch
       
    92      * expressions in preview
       
    93      */
       
    94     JDK13("13"),
       
    95 
       
    96     /**
       
    97      * 14 covers the to be determined language features that will be
       
    98      * added in JDK 14.
       
    99      */
       
   100     JDK14("14");
    92 
   101 
    93     private static final Context.Key<Source> sourceKey = new Context.Key<>();
   102     private static final Context.Key<Source> sourceKey = new Context.Key<>();
    94 
   103 
    95     public static Source instance(Context context) {
   104     public static Source instance(Context context) {
    96         Source instance = context.get(sourceKey);
   105         Source instance = context.get(sourceKey);
   137     public boolean isSupported() {
   146     public boolean isSupported() {
   138         return this.compareTo(MIN) >= 0;
   147         return this.compareTo(MIN) >= 0;
   139     }
   148     }
   140 
   149 
   141     public Target requiredTarget() {
   150     public Target requiredTarget() {
       
   151         if (this.compareTo(JDK14) >= 0) return Target.JDK1_14;
   142         if (this.compareTo(JDK13) >= 0) return Target.JDK1_13;
   152         if (this.compareTo(JDK13) >= 0) return Target.JDK1_13;
   143         if (this.compareTo(JDK12) >= 0) return Target.JDK1_12;
   153         if (this.compareTo(JDK12) >= 0) return Target.JDK1_12;
   144         if (this.compareTo(JDK11) >= 0) return Target.JDK1_11;
   154         if (this.compareTo(JDK11) >= 0) return Target.JDK1_11;
   145         if (this.compareTo(JDK10) >= 0) return Target.JDK1_10;
   155         if (this.compareTo(JDK10) >= 0) return Target.JDK1_10;
   146         if (this.compareTo(JDK9) >= 0) return Target.JDK1_9;
   156         if (this.compareTo(JDK9) >= 0) return Target.JDK1_9;
   184         UNDERSCORE_IDENTIFIER(MIN, JDK8),
   194         UNDERSCORE_IDENTIFIER(MIN, JDK8),
   185         PRIVATE_INTERFACE_METHODS(JDK9, Fragments.FeaturePrivateIntfMethods, DiagKind.PLURAL),
   195         PRIVATE_INTERFACE_METHODS(JDK9, Fragments.FeaturePrivateIntfMethods, DiagKind.PLURAL),
   186         LOCAL_VARIABLE_TYPE_INFERENCE(JDK10),
   196         LOCAL_VARIABLE_TYPE_INFERENCE(JDK10),
   187         VAR_SYNTAX_IMPLICIT_LAMBDAS(JDK11, Fragments.FeatureVarSyntaxInImplicitLambda, DiagKind.PLURAL),
   197         VAR_SYNTAX_IMPLICIT_LAMBDAS(JDK11, Fragments.FeatureVarSyntaxInImplicitLambda, DiagKind.PLURAL),
   188         IMPORT_ON_DEMAND_OBSERVABLE_PACKAGES(JDK1_2, JDK8),
   198         IMPORT_ON_DEMAND_OBSERVABLE_PACKAGES(JDK1_2, JDK8),
   189         SWITCH_MULTIPLE_CASE_LABELS(JDK13, Fragments.FeatureMultipleCaseLabels, DiagKind.PLURAL),
   199         SWITCH_MULTIPLE_CASE_LABELS(JDK14, Fragments.FeatureMultipleCaseLabels, DiagKind.PLURAL),
   190         SWITCH_RULE(JDK13, Fragments.FeatureSwitchRules, DiagKind.PLURAL),
   200         SWITCH_RULE(JDK14, Fragments.FeatureSwitchRules, DiagKind.PLURAL),
   191         SWITCH_EXPRESSION(JDK13, Fragments.FeatureSwitchExpressions, DiagKind.PLURAL);
   201         SWITCH_EXPRESSION(JDK14, Fragments.FeatureSwitchExpressions, DiagKind.PLURAL),
       
   202         TEXT_BLOCKS(JDK14, Fragments.FeatureTextBlocks, DiagKind.PLURAL);
   192 
   203 
   193         enum DiagKind {
   204         enum DiagKind {
   194             NORMAL,
   205             NORMAL,
   195             PLURAL;
   206             PLURAL;
   196         }
   207         }
   273             return RELEASE_11;
   284             return RELEASE_11;
   274         case JDK12:
   285         case JDK12:
   275             return RELEASE_12;
   286             return RELEASE_12;
   276         case JDK13:
   287         case JDK13:
   277             return RELEASE_13;
   288             return RELEASE_13;
       
   289         case JDK14:
       
   290             return RELEASE_14;
   278         default:
   291         default:
   279             return null;
   292             return null;
   280         }
   293         }
   281     }
   294     }
   282 }
   295 }