Skip to content

Commit 272bb5d

Browse files
author
Vicente Romero
committedOct 19, 2020
8253455: Record Classes javax.lang.model changes
Reviewed-by: darcy
1 parent c17d585 commit 272bb5d

12 files changed

+18
-139
lines changed
 

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

+5
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,11 @@ public enum Feature {
6262
// JDK 15. Since the JDK 14 codebase uses the enum constant, it is
6363
// necessary for PreviewFeature in JDK 15 to declare the enum constant.
6464
TEXT_BLOCKS,
65+
// The RECORDS enum constant is not used in the JDK 16 codebase, but
66+
// exists to support the bootcycle build of JDK 16. The bootcycle build
67+
// of JDK 16 is performed with JDK 15 and the PreviewFeature type from
68+
// JDK 16. Since the JDK 15 codebase uses the enum constant, it is
69+
// necessary for PreviewFeature in JDK 16 to declare the enum constant.
6570
RECORDS,
6671
SEALED_CLASSES,
6772
;

‎src/java.compiler/share/classes/javax/lang/model/element/ElementKind.java

+2-20
Original file line numberDiff line numberDiff line change
@@ -110,33 +110,15 @@ public enum ElementKind {
110110
MODULE,
111111

112112
/**
113-
* {@preview Associated with records, a preview feature of the Java language.
114-
*
115-
* This enum constant is associated with <i>records</i>, a preview
116-
* feature of the Java language. Preview features
117-
* may be removed in a future release, or upgraded to permanent
118-
* features of the Java language.}
119-
*
120113
* A record type.
121-
* @since 14
114+
* @since 16
122115
*/
123-
@jdk.internal.PreviewFeature(feature=jdk.internal.PreviewFeature.Feature.RECORDS,
124-
essentialAPI=false)
125116
RECORD,
126117

127118
/**
128-
* {@preview Associated with records, a preview feature of the Java language.
129-
*
130-
* This enum constant is associated with <i>records</i>, a preview
131-
* feature of the Java language. Preview features
132-
* may be removed in a future release, or upgraded to permanent
133-
* features of the Java language.}
134-
*
135119
* A record component of a {@code record}.
136-
* @since 14
120+
* @since 16
137121
*/
138-
@jdk.internal.PreviewFeature(feature=jdk.internal.PreviewFeature.Feature.RECORDS,
139-
essentialAPI=false)
140122
RECORD_COMPONENT,
141123

142124
/**

‎src/java.compiler/share/classes/javax/lang/model/element/ElementVisitor.java

+1-11
Original file line numberDiff line numberDiff line change
@@ -212,13 +212,6 @@ default R visitModule(ModuleElement e, P p) {
212212
}
213213

214214
/**
215-
* {@preview Associated with records, a preview feature of the Java language.
216-
*
217-
* This method is associated with <i>records</i>, a preview
218-
* feature of the Java language. Preview features
219-
* may be removed in a future release, or upgraded to permanent
220-
* features of the Java language.}
221-
*
222215
* Visits a record component element.
223216
*
224217
* @implSpec The default implementation visits a {@code
@@ -227,11 +220,8 @@ default R visitModule(ModuleElement e, P p) {
227220
* @param e the element to visit
228221
* @param p a visitor-specified parameter
229222
* @return a visitor-specified result
230-
* @since 14
223+
* @since 16
231224
*/
232-
@jdk.internal.PreviewFeature(feature=jdk.internal.PreviewFeature.Feature.RECORDS,
233-
essentialAPI=false)
234-
@SuppressWarnings("preview")
235225
default R visitRecordComponent(RecordComponentElement e, P p) {
236226
return visitUnknown(e, p);
237227
}

‎src/java.compiler/share/classes/javax/lang/model/element/RecordComponentElement.java

+1-10
Original file line numberDiff line numberDiff line change
@@ -26,19 +26,10 @@
2626
package javax.lang.model.element;
2727

2828
/**
29-
* {@preview Associated with records, a preview feature of the Java language.
30-
*
31-
* This class is associated with <i>records</i>, a preview
32-
* feature of the Java language. Preview features
33-
* may be removed in a future release, or upgraded to permanent
34-
* features of the Java language.}
35-
*
3629
* Represents a record component.
3730
*
38-
* @since 14
31+
* @since 16
3932
*/
40-
@jdk.internal.PreviewFeature(feature=jdk.internal.PreviewFeature.Feature.RECORDS,
41-
essentialAPI=false)
4233
public interface RecordComponentElement extends Element {
4334
/**
4435
* Returns the enclosing element of this record component.

‎src/java.compiler/share/classes/javax/lang/model/element/TypeElement.java

+1-11
Original file line numberDiff line numberDiff line change
@@ -180,13 +180,6 @@ public interface TypeElement extends Element, Parameterizable, QualifiedNameable
180180
List<? extends TypeParameterElement> getTypeParameters();
181181

182182
/**
183-
* {@preview Associated with records, a preview feature of the Java language.
184-
*
185-
* This method is associated with <i>records</i>, a preview
186-
* feature of the Java language. Preview features
187-
* may be removed in a future release, or upgraded to permanent
188-
* features of the Java language.}
189-
*
190183
* Returns the record components of this type element in
191184
* declaration order.
192185
*
@@ -196,11 +189,8 @@ public interface TypeElement extends Element, Parameterizable, QualifiedNameable
196189
* @return the record components, or an empty list if there are
197190
* none
198191
*
199-
* @since 14
192+
* @since 16
200193
*/
201-
@jdk.internal.PreviewFeature(feature=jdk.internal.PreviewFeature.Feature.RECORDS,
202-
essentialAPI=false)
203-
@SuppressWarnings("preview")
204194
default List<? extends RecordComponentElement> getRecordComponents() {
205195
return List.of();
206196
}

‎src/java.compiler/share/classes/javax/lang/model/util/AbstractElementVisitor14.java

+1-11
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,6 @@
3131
import static javax.lang.model.SourceVersion.*;
3232

3333
/**
34-
* {@preview Associated with records, a preview feature of the Java language.
35-
*
36-
* This class is associated with <i>records</i>, a preview
37-
* feature of the Java language. Preview features
38-
* may be removed in a future release, or upgraded to permanent
39-
* features of the Java language.}
40-
*
4134
* A skeletal visitor of program elements with default behavior
4235
* appropriate for the {@link SourceVersion#RELEASE_14 RELEASE_14}
4336
* source version.
@@ -54,10 +47,8 @@
5447
* @see AbstractElementVisitor7
5548
* @see AbstractElementVisitor8
5649
* @see AbstractElementVisitor9
57-
* @since 14
50+
* @since 16
5851
*/
59-
@jdk.internal.PreviewFeature(feature=jdk.internal.PreviewFeature.Feature.RECORDS,
60-
essentialAPI=false)
6152
@SupportedSourceVersion(RELEASE_16)
6253
public abstract class AbstractElementVisitor14<R, P> extends AbstractElementVisitor9<R, P> {
6354
/**
@@ -77,7 +68,6 @@ protected AbstractElementVisitor14(){
7768
* @param p {@inheritDoc}
7869
* @return {@inheritDoc}
7970
*/
80-
@SuppressWarnings("preview")
8171
@Override
8272
public abstract R visitRecordComponent(RecordComponentElement t, P p);
8373
}

‎src/java.compiler/share/classes/javax/lang/model/util/ElementFilter.java

+2-22
Original file line numberDiff line numberDiff line change
@@ -112,42 +112,22 @@ private ElementFilter() {} // Do not instantiate.
112112
}
113113

114114
/**
115-
* {@preview Associated with records, a preview feature of the Java language.
116-
*
117-
* This method is associated with <i>records</i>, a preview
118-
* feature of the Java language. Preview features
119-
* may be removed in a future release, or upgraded to permanent
120-
* features of the Java language.}
121-
*
122115
* Returns a list of record components in {@code elements}.
123116
* @return a list of record components in {@code elements}
124117
* @param elements the elements to filter
125-
* @since 14
118+
* @since 16
126119
*/
127-
@jdk.internal.PreviewFeature(feature=jdk.internal.PreviewFeature.Feature.RECORDS,
128-
essentialAPI=false)
129-
@SuppressWarnings("preview")
130120
public static List<RecordComponentElement>
131121
recordComponentsIn(Iterable<? extends Element> elements) {
132122
return listFilter(elements, RECORD_COMPONENT_KIND, RecordComponentElement.class);
133123
}
134124

135125
/**
136-
* {@preview Associated with records, a preview feature of the Java language.
137-
*
138-
* This method is associated with <i>records</i>, a preview
139-
* feature of the Java language. Preview features
140-
* may be removed in a future release, or upgraded to permanent
141-
* features of the Java language.}
142-
*
143126
* Returns a set of record components in {@code elements}.
144127
* @return a set of record components in {@code elements}
145128
* @param elements the elements to filter
146-
* @since 14
129+
* @since 16
147130
*/
148-
@jdk.internal.PreviewFeature(feature=jdk.internal.PreviewFeature.Feature.RECORDS,
149-
essentialAPI=false)
150-
@SuppressWarnings("preview")
151131
public static Set<RecordComponentElement>
152132
recordComponentsIn(Set<? extends Element> elements) {
153133
return setFilter(elements, RECORD_COMPONENT_KIND, RecordComponentElement.class);

‎src/java.compiler/share/classes/javax/lang/model/util/ElementKindVisitor14.java

+1-11
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,6 @@
3131
import javax.lang.model.SourceVersion;
3232

3333
/**
34-
* {@preview Associated with records, a preview feature of the Java language.
35-
*
36-
* This class is associated with <i>records</i>, a preview
37-
* feature of the Java language. Preview features
38-
* may be removed in a future release, or upgraded to permanent
39-
* features of the Java language.}
40-
*
4134
* A visitor of program elements based on their {@linkplain
4235
* ElementKind kind} with default behavior appropriate for the {@link
4336
* SourceVersion#RELEASE_14 RELEASE_14} source version.
@@ -66,10 +59,8 @@
6659
* @see ElementKindVisitor7
6760
* @see ElementKindVisitor8
6861
* @see ElementKindVisitor9
69-
* @since 14
62+
* @since 16
7063
*/
71-
@jdk.internal.PreviewFeature(feature=jdk.internal.PreviewFeature.Feature.RECORDS,
72-
essentialAPI=false)
7364
@SupportedSourceVersion(RELEASE_16)
7465
public class ElementKindVisitor14<R, P> extends ElementKindVisitor9<R, P> {
7566
/**
@@ -99,7 +90,6 @@ protected ElementKindVisitor14(R defaultValue) {
9990
* @param p a visitor-specified parameter
10091
* @return the result of {@code defaultAction}
10192
*/
102-
@SuppressWarnings("preview")
10393
@Override
10494
public R visitRecordComponent(RecordComponentElement e, P p) {
10595
return defaultAction(e, p);

‎src/java.compiler/share/classes/javax/lang/model/util/ElementKindVisitor6.java

+1-10
Original file line numberDiff line numberDiff line change
@@ -217,13 +217,6 @@ public R visitTypeAsInterface(TypeElement e, P p) {
217217
}
218218

219219
/**
220-
* {@preview Associated with records, a preview feature of the Java language.
221-
*
222-
* This method is associated with <i>records</i>, a preview
223-
* feature of the Java language. Preview features
224-
* may be removed in a future release, or upgraded to permanent
225-
* features of the Java language.}
226-
*
227220
* Visits a {@code RECORD} type element.
228221
*
229222
* @implSpec This implementation calls {@code visitUnknown}.
@@ -232,10 +225,8 @@ public R visitTypeAsInterface(TypeElement e, P p) {
232225
* @param p a visitor-specified parameter
233226
* @return the result of {@code visitUnknown}
234227
*
235-
* @since 14
228+
* @since 16
236229
*/
237-
@jdk.internal.PreviewFeature(feature=jdk.internal.PreviewFeature.Feature.RECORDS,
238-
essentialAPI=false)
239230
public R visitTypeAsRecord(TypeElement e, P p) {
240231
return visitUnknown(e, p);
241232
}

‎src/java.compiler/share/classes/javax/lang/model/util/ElementScanner14.java

+1-11
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,6 @@
3333
import static javax.lang.model.SourceVersion.*;
3434

3535
/**
36-
* {@preview Associated with records, a preview feature of the Java language.
37-
*
38-
* This class is associated with <i>records</i>, a preview
39-
* feature of the Java language. Preview features
40-
* may be removed in a future release, or upgraded to permanent
41-
* features of the Java language.}
42-
*
4336
* A scanning visitor of program elements with default behavior
4437
* appropriate for the {@link SourceVersion#RELEASE_14 RELEASE_14}
4538
* source version.
@@ -81,10 +74,8 @@
8174
* @see ElementScanner7
8275
* @see ElementScanner8
8376
* @see ElementScanner9
84-
* @since 14
77+
* @since 16
8578
*/
86-
@jdk.internal.PreviewFeature(feature=jdk.internal.PreviewFeature.Feature.RECORDS,
87-
essentialAPI=false)
8879
@SupportedSourceVersion(RELEASE_16)
8980
public class ElementScanner14<R, P> extends ElementScanner9<R, P> {
9081
/**
@@ -156,7 +147,6 @@ private List<? extends Element> createScanningList(Parameterizable element,
156147
* @param p a visitor-specified parameter
157148
* @return the result of the scan
158149
*/
159-
@SuppressWarnings("preview")
160150
@Override
161151
public R visitRecordComponent(RecordComponentElement e, P p) {
162152
return scan(e.getEnclosedElements(), p);

‎src/java.compiler/share/classes/javax/lang/model/util/Elements.java

+1-11
Original file line numberDiff line numberDiff line change
@@ -634,13 +634,6 @@ boolean overrides(ExecutableElement overrider, ExecutableElement overridden,
634634
boolean isFunctionalInterface(TypeElement type);
635635

636636
/**
637-
* {@preview Associated with records, a preview feature of the Java language.
638-
*
639-
* This method is associated with <i>records</i>, a preview
640-
* feature of the Java language. Preview features
641-
* may be removed in a future release, or upgraded to permanent
642-
* features of the Java language.}
643-
*
644637
* Returns the record component for the given accessor. Returns null if the
645638
* given method is not a record component accessor.
646639
*
@@ -655,11 +648,8 @@ boolean overrides(ExecutableElement overrider, ExecutableElement overridden,
655648
* @param accessor the method for which the record component should be found.
656649
* @return the record component, or null if the given method is not an record
657650
* component accessor
658-
* @since 14
651+
* @since 16
659652
*/
660-
@jdk.internal.PreviewFeature(feature=jdk.internal.PreviewFeature.Feature.RECORDS,
661-
essentialAPI=false)
662-
@SuppressWarnings("preview")
663653
default RecordComponentElement recordComponentFor(ExecutableElement accessor) {
664654
if (accessor.getEnclosingElement().getKind() == ElementKind.RECORD) {
665655
for (RecordComponentElement rec : ElementFilter.recordComponentsIn(accessor.getEnclosingElement().getEnclosedElements())) {

‎src/java.compiler/share/classes/javax/lang/model/util/SimpleElementVisitor14.java

+1-11
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,6 @@
3131
import static javax.lang.model.SourceVersion.*;
3232

3333
/**
34-
* {@preview Associated with records, a preview feature of the Java language.
35-
*
36-
* This class is associated with <i>records</i>, a preview
37-
* feature of the Java language. Preview features
38-
* may be removed in a future release, or upgraded to permanent
39-
* features of the Java language.}
40-
*
4134
* A simple visitor of program elements with default behavior
4235
* appropriate for the {@link SourceVersion#RELEASE_14 RELEASE_14}
4336
* source version.
@@ -62,10 +55,8 @@
6255
* @see SimpleElementVisitor7
6356
* @see SimpleElementVisitor8
6457
* @see SimpleElementVisitor9
65-
* @since 14
58+
* @since 16
6659
*/
67-
@jdk.internal.PreviewFeature(feature=jdk.internal.PreviewFeature.Feature.RECORDS,
68-
essentialAPI=false)
6960
@SupportedSourceVersion(RELEASE_16)
7061
public class SimpleElementVisitor14<R, P> extends SimpleElementVisitor9<R, P> {
7162
/**
@@ -96,7 +87,6 @@ protected SimpleElementVisitor14(R defaultValue){
9687
* @param p a visitor-specified parameter
9788
* @return {@inheritDoc}
9889
*/
99-
@SuppressWarnings("preview")
10090
@Override
10191
public R visitRecordComponent(RecordComponentElement e, P p) {
10292
return defaultAction(e, p);

0 commit comments

Comments
 (0)
Please sign in to comment.