< prev index next >

src/java.base/share/classes/jdk/internal/javac/PreviewFeature.java

Print this page

 47          ElementType.PACKAGE,
 48          ElementType.MODULE,
 49          ElementType.TYPE})
 50  // CLASS retention will hopefully be sufficient for the purposes at hand
 51 @Retention(RetentionPolicy.CLASS)
 52 // *Not* @Documented
 53 public @interface PreviewFeature {
 54     /**
 55      * Name of the preview feature the annotated API is associated
 56      * with.
 57      */
 58     public Feature feature();
 59 
 60     public boolean reflective() default false;
 61 
 62     /**
 63      * Enum of preview features in the current release.
 64      * Values should be annotated with the feature's {@code JEP}.
 65      */
 66     public enum Feature {



 67         // The JDK build process involves creating an interim javac which is then
 68         // used to compile the rest of the JDK. The jdk.internal.javac.PreviewFeature
 69         // annotation from the current sources is used when compiling interim javac.
 70         // That's because the javac APIs of the current sources may be annotated with
 71         // this annotation and they may be using the enum constants of the current sources.
 72         // Furthermore, when compiling interim javac, the class files from the bootstrap JDK get
 73         // used and those may also contain the PreviewFeature annotation. However, they may be
 74         // using the enum constants of the bootstrap JDK's PreviewFeature annotation.
 75         // If javac sees an annotation with an unknown enum constant, it produces a warning,
 76         // and that in turn fails the build.
 77         // So, in the current sources, we need to preserve the PreviewFeature enum constants
 78         // for as long as the interim javac build needs it. As a result, we retain PreviewFeature
 79         // enum constants for preview features that are present in the bootstrap JDK.
 80         // Older constants can be removed.
 81         //
 82         // For example, Class-File API became final in JDK 24. As soon as JDK 23 was dropped as
 83         // the bootstrap JDK, the CLASSFILE_API enum constant became eligible for removal.
 84 
 85         //---
 86         @JEP(number=505, title="Structured Concurrency", status="Fifth Preview")
 87         STRUCTURED_CONCURRENCY,
 88         @JEP(number = 502, title = "Stable Values", status = "Preview")
 89         STABLE_VALUES,
 90         @JEP(number=470, title="PEM Encodings of Cryptographic Objects", status="Preview")
 91         PEM_API,
 92         LANGUAGE_MODEL,
 93         /**
 94          * A key for testing.
 95          */
 96         @JEP(number=2_147_483_647, title="Test Feature")
 97         TEST,
 98         ;
 99     }
100 
101     /**
102      * Annotation identifying the JEP associated with a preview feature.
103      */
104     @Target(ElementType.FIELD)

 47          ElementType.PACKAGE,
 48          ElementType.MODULE,
 49          ElementType.TYPE})
 50  // CLASS retention will hopefully be sufficient for the purposes at hand
 51 @Retention(RetentionPolicy.CLASS)
 52 // *Not* @Documented
 53 public @interface PreviewFeature {
 54     /**
 55      * Name of the preview feature the annotated API is associated
 56      * with.
 57      */
 58     public Feature feature();
 59 
 60     public boolean reflective() default false;
 61 
 62     /**
 63      * Enum of preview features in the current release.
 64      * Values should be annotated with the feature's {@code JEP}.
 65      */
 66     public enum Feature {
 67         @JEP(number=401, title="Value Classes and Objects", status = "Preview")
 68         VALUE_OBJECTS,
 69 
 70         // The JDK build process involves creating an interim javac which is then
 71         // used to compile the rest of the JDK. The jdk.internal.javac.PreviewFeature
 72         // annotation from the current sources is used when compiling interim javac.
 73         // That's because the javac APIs of the current sources may be annotated with
 74         // this annotation and they may be using the enum constants of the current sources.
 75         // Furthermore, when compiling interim javac, the class files from the bootstrap JDK get
 76         // used and those may also contain the PreviewFeature annotation. However, they may be
 77         // using the enum constants of the bootstrap JDK's PreviewFeature annotation.
 78         // If javac sees an annotation with an unknown enum constant, it produces a warning,
 79         // and that in turn fails the build.
 80         // So, in the current sources, we need to preserve the PreviewFeature enum constants
 81         // for as long as the interim javac build needs it. As a result, we retain PreviewFeature
 82         // enum constants for preview features that are present in the bootstrap JDK.
 83         // Older constants can be removed.
 84         //
 85         // For example, Class-File API became final in JDK 24. As soon as JDK 23 was dropped as
 86         // the bootstrap JDK, the CLASSFILE_API enum constant became eligible for removal.

 87         //---
 88         @JEP(number=505, title="Structured Concurrency", status="Fifth Preview")
 89         STRUCTURED_CONCURRENCY,
 90         @JEP(number = 502, title = "Stable Values", status = "Preview")
 91         STABLE_VALUES,
 92         @JEP(number=470, title="PEM Encodings of Cryptographic Objects", status="Preview")
 93         PEM_API,
 94         LANGUAGE_MODEL,
 95         /**
 96          * A key for testing.
 97          */
 98         @JEP(number=2_147_483_647, title="Test Feature")
 99         TEST,
100         ;
101     }
102 
103     /**
104      * Annotation identifying the JEP associated with a preview feature.
105      */
106     @Target(ElementType.FIELD)
< prev index next >