JDK-8296179 : Add SourceVersion.RELEASE_21
  • Type: CSR
  • Component: core-libs
  • Sub-Component: javax.lang.model
  • Priority: P4
  • Status: Closed
  • Resolution: Approved
  • Fix Versions: 21
  • Submitted: 2022-11-01
  • Updated: 2022-11-01
  • Resolved: 2022-11-01
Related Reports
CSR :  
Relates :  
Description
Summary
-------

Add a new enum constant `RELEASE_21` to `javax.lang.model.SourceVersion` for the JDK 21 release and update the FooVisitor14 visitors to cover release 21 as well.

Problem
-------

The `SourceVersion` enum needs an enum constant for each release being modeled.

Solution
--------

Append the enum constant `RELEASE_21` and update the visitor text and supported source version annotations to cover from RELEASE_14 to RELEASE_21.

Specification
-------------

    diff --git a/src/java.compiler/share/classes/javax/lang/model/SourceVersion.java b/src/java.compiler/share/classes/javax/lang/model/SourceVersion.java
    index 26be8fbfc32..8fecbd45a19 100644
    --- a/src/java.compiler/share/classes/javax/lang/model/SourceVersion.java
    +++ b/src/java.compiler/share/classes/javax/lang/model/SourceVersion.java
    @@ -69,6 +69,8 @@ public enum SourceVersion {
          *  18: no changes (pattern matching for switch in second preview)
          *  19: no changes (pattern matching for switch in third preview,
          *      record patterns in preview)
    +     *  20: tbd
    +     *  21: tbd
          */
     
         /**
    @@ -368,7 +370,19 @@ public enum SourceVersion {
          * href="https://docs.oracle.com/javase/specs/jls/se20/html/index.html">
          * <cite>The Java Language Specification, Java SE 20 Edition</cite></a>
          */
    -    RELEASE_20;
    +    RELEASE_20,
    +
    +    /**
    +     * The version recognized by the Java Platform, Standard Edition
    +     * 21.
    +     *
    +     * @since 21
    +     *
    +     * @see <a
    +     * href="https://docs.oracle.com/javase/specs/jls/se21/html/index.html">
    +     * <cite>The Java Language Specification, Java SE 21 Edition</cite></a>
    +     */
    +    RELEASE_21;
     
         // Note that when adding constants for newer releases, the
         // behavior of latest() and latestSupported() must be updated too.
    @@ -377,7 +391,7 @@ public enum SourceVersion {
          * {@return the latest source version that can be modeled}
          */
         public static SourceVersion latest() {
    -        return RELEASE_20;
    +        return RELEASE_21;
         }
     
         private static final SourceVersion latestSupported = getLatestSupported();
    @@ -392,7 +406,7 @@ public enum SourceVersion {
         private static SourceVersion getLatestSupported() {
             int intVersion = Runtime.version().feature();
             return (intVersion >= 11) ?
    -            valueOf("RELEASE_" + Math.min(20, intVersion)):
    +            valueOf("RELEASE_" + Math.min(21, intVersion)):
                 RELEASE_10;
         }
     
    diff --git a/src/java.compiler/share/classes/javax/lang/model/util/AbstractAnnotationValueVisitor14.java b/src/java.compiler/share/classes/javax/lang/model/util/AbstractAnnotationValueVisitor14.java
    index 5696a03ffdf..5206b49ab6c 100644
    --- a/src/java.compiler/share/classes/javax/lang/model/util/AbstractAnnotationValueVisitor14.java
    +++ b/src/java.compiler/share/classes/javax/lang/model/util/AbstractAnnotationValueVisitor14.java
    @@ -44,7 +44,7 @@ import javax.annotation.processing.SupportedSourceVersion;
      * @see AbstractAnnotationValueVisitor9
      * @since 14
      */
    -@SupportedSourceVersion(RELEASE_20)
    +@SupportedSourceVersion(RELEASE_21)
     public abstract class AbstractAnnotationValueVisitor14<R, P> extends AbstractAnnotationValueVisitor9<R, P> {
     
         /**
    diff --git a/src/java.compiler/share/classes/javax/lang/model/util/AbstractElementVisitor14.java b/src/java.compiler/share/classes/javax/lang/model/util/AbstractElementVisitor14.java
    index 3a373297c8b..d7b51093bce 100644
    --- a/src/java.compiler/share/classes/javax/lang/model/util/AbstractElementVisitor14.java
    +++ b/src/java.compiler/share/classes/javax/lang/model/util/AbstractElementVisitor14.java
    @@ -49,7 +49,7 @@ import static javax.lang.model.SourceVersion.*;
      * @see AbstractElementVisitor9
      * @since 16
      */
    -@SupportedSourceVersion(RELEASE_20)
    +@SupportedSourceVersion(RELEASE_21)
     public abstract class AbstractElementVisitor14<R, P> extends AbstractElementVisitor9<R, P> {
         /**
          * Constructor for concrete subclasses to call.
    diff --git a/src/java.compiler/share/classes/javax/lang/model/util/AbstractTypeVisitor14.java b/src/java.compiler/share/classes/javax/lang/model/util/AbstractTypeVisitor14.java
    index e300b107639..aa7d70cbd70 100644
    --- a/src/java.compiler/share/classes/javax/lang/model/util/AbstractTypeVisitor14.java
    +++ b/src/java.compiler/share/classes/javax/lang/model/util/AbstractTypeVisitor14.java
    @@ -47,7 +47,7 @@ import static javax.lang.model.SourceVersion.*;
      * @see AbstractTypeVisitor9
      * @since 14
      */
    -@SupportedSourceVersion(RELEASE_20)
    +@SupportedSourceVersion(RELEASE_21)
     public abstract class AbstractTypeVisitor14<R, P> extends AbstractTypeVisitor9<R, P> {
         /**
          * Constructor for concrete subclasses to call.
    diff --git a/src/java.compiler/share/classes/javax/lang/model/util/ElementKindVisitor14.java b/src/java.compiler/share/classes/javax/lang/model/util/ElementKindVisitor14.java
    index db8af23f387..5ce90e144ec 100644
    --- a/src/java.compiler/share/classes/javax/lang/model/util/ElementKindVisitor14.java
    +++ b/src/java.compiler/share/classes/javax/lang/model/util/ElementKindVisitor14.java
    @@ -61,7 +61,7 @@ import javax.lang.model.SourceVersion;
      * @see ElementKindVisitor9
      * @since 16
      */
    -@SupportedSourceVersion(RELEASE_20)
    +@SupportedSourceVersion(RELEASE_21)
     public class ElementKindVisitor14<R, P> extends ElementKindVisitor9<R, P> {
         /**
          * Constructor for concrete subclasses; uses {@code null} for the
    diff --git a/src/java.compiler/share/classes/javax/lang/model/util/ElementScanner14.java b/src/java.compiler/share/classes/javax/lang/model/util/ElementScanner14.java
    index 0dddf71c245..55cd3e9cd7c 100644
    --- a/src/java.compiler/share/classes/javax/lang/model/util/ElementScanner14.java
    +++ b/src/java.compiler/share/classes/javax/lang/model/util/ElementScanner14.java
    @@ -77,7 +77,7 @@ import static javax.lang.model.SourceVersion.*;
      * @see ElementScanner9
      * @since 16
      */
    -@SupportedSourceVersion(RELEASE_20)
    +@SupportedSourceVersion(RELEASE_21)
     public class ElementScanner14<R, P> extends ElementScanner9<R, P> {
         /**
          * Constructor for concrete subclasses; uses {@code null} for the
    diff --git a/src/java.compiler/share/classes/javax/lang/model/util/SimpleAnnotationValueVisitor14.java b/src/java.compiler/share/classes/javax/lang/model/util/SimpleAnnotationValueVisitor14.java
    index 87776d91abb..95b51f1cd37 100644
    --- a/src/java.compiler/share/classes/javax/lang/model/util/SimpleAnnotationValueVisitor14.java
    +++ b/src/java.compiler/share/classes/javax/lang/model/util/SimpleAnnotationValueVisitor14.java
    @@ -52,7 +52,7 @@ import static javax.lang.model.SourceVersion.*;
      * @see SimpleAnnotationValueVisitor9
      * @since 14
      */
    -@SupportedSourceVersion(RELEASE_20)
    +@SupportedSourceVersion(RELEASE_21)
     public class SimpleAnnotationValueVisitor14<R, P> extends SimpleAnnotationValueVisitor9<R, P> {
         /**
          * Constructor for concrete subclasses; uses {@code null} for the
    diff --git a/src/java.compiler/share/classes/javax/lang/model/util/SimpleElementVisitor14.java b/src/java.compiler/share/classes/javax/lang/model/util/SimpleElementVisitor14.java
    index 6cf1c4de150..bf6c2e0863f 100644
    --- a/src/java.compiler/share/classes/javax/lang/model/util/SimpleElementVisitor14.java
    +++ b/src/java.compiler/share/classes/javax/lang/model/util/SimpleElementVisitor14.java
    @@ -57,7 +57,7 @@ import static javax.lang.model.SourceVersion.*;
      * @see SimpleElementVisitor9
      * @since 16
      */
    -@SupportedSourceVersion(RELEASE_20)
    +@SupportedSourceVersion(RELEASE_21)
     public class SimpleElementVisitor14<R, P> extends SimpleElementVisitor9<R, P> {
         /**
          * Constructor for concrete subclasses; uses {@code null} for the
    diff --git a/src/java.compiler/share/classes/javax/lang/model/util/SimpleTypeVisitor14.java b/src/java.compiler/share/classes/javax/lang/model/util/SimpleTypeVisitor14.java
    index 352bd6bb0d1..850668bb8aa 100644
    --- a/src/java.compiler/share/classes/javax/lang/model/util/SimpleTypeVisitor14.java
    +++ b/src/java.compiler/share/classes/javax/lang/model/util/SimpleTypeVisitor14.java
    @@ -56,7 +56,7 @@ import static javax.lang.model.SourceVersion.*;
      * @see SimpleTypeVisitor9
      * @since 14
      */
    -@SupportedSourceVersion(RELEASE_20)
    +@SupportedSourceVersion(RELEASE_21)
     public class SimpleTypeVisitor14<R, P> extends SimpleTypeVisitor9<R, P> {
         /**
          * Constructor for concrete subclasses; uses {@code null} for the
    diff --git a/src/java.compiler/share/classes/javax/lang/model/util/TypeKindVisitor14.java b/src/java.compiler/share/classes/javax/lang/model/util/TypeKindVisitor14.java
    index a7fbc37ac20..5352e23fa8e 100644
    --- a/src/java.compiler/share/classes/javax/lang/model/util/TypeKindVisitor14.java
    +++ b/src/java.compiler/share/classes/javax/lang/model/util/TypeKindVisitor14.java
    @@ -61,7 +61,7 @@ import static javax.lang.model.SourceVersion.*;
      * @see TypeKindVisitor9
      * @since 14
      */
    -@SupportedSourceVersion(RELEASE_20)
    +@SupportedSourceVersion(RELEASE_21)
     public class TypeKindVisitor14<R, P> extends TypeKindVisitor9<R, P> {
         /**
          * Constructor for concrete subclasses to call; uses {@code null}


Comments
Moving to Approved.
01-11-2022

[~jjg], thank for the review; I'll address any formatting comments in the PR.
01-11-2022

``` + * The version recognized by the Java Platform, Standard Edition + * 21. ``` Minor quibble: join these lines into a single line.
01-11-2022