Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8306627

Add SourceVersion.RELEASE_22

XMLWordPrintable

    • Icon: CSR CSR
    • Resolution: Approved
    • Icon: P4 P4
    • 22
    • core-libs
    • None
    • source
    • minimal
    • Java API
    • SE

      Summary

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

      Problem

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

      Solution

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

      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 00cdbe320c5..1a9437109d1 100644
      --- a/src/java.compiler/share/classes/javax/lang/model/SourceVersion.java
      +++ b/src/java.compiler/share/classes/javax/lang/model/SourceVersion.java
      @@ -1,5 +1,5 @@
       /*
      - * Copyright (c) 2005, 2022, Oracle and/or its affiliates. All rights reserved.
      + * Copyright (c) 2005, 2023, Oracle and/or its affiliates. All rights reserved.
        * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
        *
        * This code is free software; you can redistribute it and/or modify it
      @@ -72,6 +72,7 @@ public enum SourceVersion {
            *  20: no changes (pattern matching for switch in fourth preview,
            *      record patterns in second preview)
            *  21: tbd
      +     *  22: tbd
            */
      
           /**
      @@ -385,7 +386,19 @@ public enum SourceVersion {
            * 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;
      +    RELEASE_21,
      +
      +    /**
      +     * The version recognized by the Java Platform, Standard Edition
      +     * 22.
      +     *
      +     * @since 22
      +     *
      +     * @see <a
      +     * href="https://docs.oracle.com/javase/specs/jls/se22/html/index.html">
      +     * <cite>The Java Language Specification, Java SE 22 Edition</cite></a>
      +     */
      +    RELEASE_22;
      
           // Note that when adding constants for newer releases, the
           // behavior of latest() and latestSupported() must be updated too.
      @@ -394,7 +407,7 @@ public enum SourceVersion {
            * {@return the latest source version that can be modeled}
            */
           public static SourceVersion latest() {
      -        return RELEASE_21;
      +        return RELEASE_22;
           }
      
           private static final SourceVersion latestSupported = getLatestSupported();
      @@ -409,7 +422,7 @@ public enum SourceVersion {
           private static SourceVersion getLatestSupported() {
               int intVersion = Runtime.version().feature();
               return (intVersion >= 11) ?
      -            valueOf("RELEASE_" + Math.min(21, intVersion)):
      +            valueOf("RELEASE_" + Math.min(22, 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 5206b49ab6c..66f73f0154f 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_21)
      +@SupportedSourceVersion(RELEASE_22)
       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 d7b51093bce..875de10d68b 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_21)
      +@SupportedSourceVersion(RELEASE_22)
       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 aa7d70cbd70..555564b7535 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_21)
      +@SupportedSourceVersion(RELEASE_22)
       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 5ce90e144ec..2cd5567f37b 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_21)
      +@SupportedSourceVersion(RELEASE_22)
       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 55cd3e9cd7c..648d710f987 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_21)
      +@SupportedSourceVersion(RELEASE_22)
       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 95b51f1cd37..8700db6d424 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_21)
      +@SupportedSourceVersion(RELEASE_22)
       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 bf6c2e0863f..8d45c35ae7b 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_21)
      +@SupportedSourceVersion(RELEASE_22)
       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 850668bb8aa..6bb75b4c0b6 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_21)
      +@SupportedSourceVersion(RELEASE_22)
       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 5352e23fa8e..5ffc131c96e 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_21)
      +@SupportedSourceVersion(RELEASE_22)
       public class TypeKindVisitor14<R, P> extends TypeKindVisitor9<R, P> {
           /**
            * Constructor for concrete subclasses to call; uses {@code null}

            darcy Joe Darcy
            darcy Joe Darcy
            Jonathan Gibbons
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: