8253455: Record Classes javax.lang.model changes

Reviewed-by: darcy
This commit is contained in:
Vicente Romero 2020-10-19 02:03:10 +00:00
parent c17d58516f
commit 272bb5d580
12 changed files with 18 additions and 139 deletions

View File

@ -62,6 +62,11 @@ public @interface PreviewFeature {
// JDK 15. Since the JDK 14 codebase uses the enum constant, it is
// necessary for PreviewFeature in JDK 15 to declare the enum constant.
TEXT_BLOCKS,
// The RECORDS enum constant is not used in the JDK 16 codebase, but
// exists to support the bootcycle build of JDK 16. The bootcycle build
// of JDK 16 is performed with JDK 15 and the PreviewFeature type from
// JDK 16. Since the JDK 15 codebase uses the enum constant, it is
// necessary for PreviewFeature in JDK 16 to declare the enum constant.
RECORDS,
SEALED_CLASSES,
;

View File

@ -110,33 +110,15 @@ public enum ElementKind {
MODULE,
/**
* {@preview Associated with records, a preview feature of the Java language.
*
* This enum constant is associated with <i>records</i>, a preview
* feature of the Java language. Preview features
* may be removed in a future release, or upgraded to permanent
* features of the Java language.}
*
* A record type.
* @since 14
* @since 16
*/
@jdk.internal.PreviewFeature(feature=jdk.internal.PreviewFeature.Feature.RECORDS,
essentialAPI=false)
RECORD,
/**
* {@preview Associated with records, a preview feature of the Java language.
*
* This enum constant is associated with <i>records</i>, a preview
* feature of the Java language. Preview features
* may be removed in a future release, or upgraded to permanent
* features of the Java language.}
*
* A record component of a {@code record}.
* @since 14
* @since 16
*/
@jdk.internal.PreviewFeature(feature=jdk.internal.PreviewFeature.Feature.RECORDS,
essentialAPI=false)
RECORD_COMPONENT,
/**

View File

@ -212,13 +212,6 @@ public interface ElementVisitor<R, P> {
}
/**
* {@preview Associated with records, a preview feature of the Java language.
*
* This method is associated with <i>records</i>, a preview
* feature of the Java language. Preview features
* may be removed in a future release, or upgraded to permanent
* features of the Java language.}
*
* Visits a record component element.
*
* @implSpec The default implementation visits a {@code
@ -227,11 +220,8 @@ public interface ElementVisitor<R, P> {
* @param e the element to visit
* @param p a visitor-specified parameter
* @return a visitor-specified result
* @since 14
* @since 16
*/
@jdk.internal.PreviewFeature(feature=jdk.internal.PreviewFeature.Feature.RECORDS,
essentialAPI=false)
@SuppressWarnings("preview")
default R visitRecordComponent(RecordComponentElement e, P p) {
return visitUnknown(e, p);
}

View File

@ -26,19 +26,10 @@
package javax.lang.model.element;
/**
* {@preview Associated with records, a preview feature of the Java language.
*
* This class is associated with <i>records</i>, a preview
* feature of the Java language. Preview features
* may be removed in a future release, or upgraded to permanent
* features of the Java language.}
*
* Represents a record component.
*
* @since 14
* @since 16
*/
@jdk.internal.PreviewFeature(feature=jdk.internal.PreviewFeature.Feature.RECORDS,
essentialAPI=false)
public interface RecordComponentElement extends Element {
/**
* Returns the enclosing element of this record component.

View File

@ -180,13 +180,6 @@ public interface TypeElement extends Element, Parameterizable, QualifiedNameable
List<? extends TypeParameterElement> getTypeParameters();
/**
* {@preview Associated with records, a preview feature of the Java language.
*
* This method is associated with <i>records</i>, a preview
* feature of the Java language. Preview features
* may be removed in a future release, or upgraded to permanent
* features of the Java language.}
*
* Returns the record components of this type element in
* declaration order.
*
@ -196,11 +189,8 @@ public interface TypeElement extends Element, Parameterizable, QualifiedNameable
* @return the record components, or an empty list if there are
* none
*
* @since 14
* @since 16
*/
@jdk.internal.PreviewFeature(feature=jdk.internal.PreviewFeature.Feature.RECORDS,
essentialAPI=false)
@SuppressWarnings("preview")
default List<? extends RecordComponentElement> getRecordComponents() {
return List.of();
}

View File

@ -31,13 +31,6 @@ import javax.lang.model.element.RecordComponentElement;
import static javax.lang.model.SourceVersion.*;
/**
* {@preview Associated with records, a preview feature of the Java language.
*
* This class is associated with <i>records</i>, a preview
* feature of the Java language. Preview features
* may be removed in a future release, or upgraded to permanent
* features of the Java language.}
*
* A skeletal visitor of program elements with default behavior
* appropriate for the {@link SourceVersion#RELEASE_14 RELEASE_14}
* source version.
@ -54,10 +47,8 @@ import static javax.lang.model.SourceVersion.*;
* @see AbstractElementVisitor7
* @see AbstractElementVisitor8
* @see AbstractElementVisitor9
* @since 14
* @since 16
*/
@jdk.internal.PreviewFeature(feature=jdk.internal.PreviewFeature.Feature.RECORDS,
essentialAPI=false)
@SupportedSourceVersion(RELEASE_16)
public abstract class AbstractElementVisitor14<R, P> extends AbstractElementVisitor9<R, P> {
/**
@ -77,7 +68,6 @@ public abstract class AbstractElementVisitor14<R, P> extends AbstractElementVisi
* @param p {@inheritDoc}
* @return {@inheritDoc}
*/
@SuppressWarnings("preview")
@Override
public abstract R visitRecordComponent(RecordComponentElement t, P p);
}

View File

@ -112,42 +112,22 @@ public class ElementFilter {
}
/**
* {@preview Associated with records, a preview feature of the Java language.
*
* This method is associated with <i>records</i>, a preview
* feature of the Java language. Preview features
* may be removed in a future release, or upgraded to permanent
* features of the Java language.}
*
* Returns a list of record components in {@code elements}.
* @return a list of record components in {@code elements}
* @param elements the elements to filter
* @since 14
* @since 16
*/
@jdk.internal.PreviewFeature(feature=jdk.internal.PreviewFeature.Feature.RECORDS,
essentialAPI=false)
@SuppressWarnings("preview")
public static List<RecordComponentElement>
recordComponentsIn(Iterable<? extends Element> elements) {
return listFilter(elements, RECORD_COMPONENT_KIND, RecordComponentElement.class);
}
/**
* {@preview Associated with records, a preview feature of the Java language.
*
* This method is associated with <i>records</i>, a preview
* feature of the Java language. Preview features
* may be removed in a future release, or upgraded to permanent
* features of the Java language.}
*
* Returns a set of record components in {@code elements}.
* @return a set of record components in {@code elements}
* @param elements the elements to filter
* @since 14
* @since 16
*/
@jdk.internal.PreviewFeature(feature=jdk.internal.PreviewFeature.Feature.RECORDS,
essentialAPI=false)
@SuppressWarnings("preview")
public static Set<RecordComponentElement>
recordComponentsIn(Set<? extends Element> elements) {
return setFilter(elements, RECORD_COMPONENT_KIND, RecordComponentElement.class);

View File

@ -31,13 +31,6 @@ import static javax.lang.model.SourceVersion.*;
import javax.lang.model.SourceVersion;
/**
* {@preview Associated with records, a preview feature of the Java language.
*
* This class is associated with <i>records</i>, a preview
* feature of the Java language. Preview features
* may be removed in a future release, or upgraded to permanent
* features of the Java language.}
*
* A visitor of program elements based on their {@linkplain
* ElementKind kind} with default behavior appropriate for the {@link
* SourceVersion#RELEASE_14 RELEASE_14} source version.
@ -66,10 +59,8 @@ import javax.lang.model.SourceVersion;
* @see ElementKindVisitor7
* @see ElementKindVisitor8
* @see ElementKindVisitor9
* @since 14
* @since 16
*/
@jdk.internal.PreviewFeature(feature=jdk.internal.PreviewFeature.Feature.RECORDS,
essentialAPI=false)
@SupportedSourceVersion(RELEASE_16)
public class ElementKindVisitor14<R, P> extends ElementKindVisitor9<R, P> {
/**
@ -99,7 +90,6 @@ public class ElementKindVisitor14<R, P> extends ElementKindVisitor9<R, P> {
* @param p a visitor-specified parameter
* @return the result of {@code defaultAction}
*/
@SuppressWarnings("preview")
@Override
public R visitRecordComponent(RecordComponentElement e, P p) {
return defaultAction(e, p);

View File

@ -217,13 +217,6 @@ public class ElementKindVisitor6<R, P>
}
/**
* {@preview Associated with records, a preview feature of the Java language.
*
* This method is associated with <i>records</i>, a preview
* feature of the Java language. Preview features
* may be removed in a future release, or upgraded to permanent
* features of the Java language.}
*
* Visits a {@code RECORD} type element.
*
* @implSpec This implementation calls {@code visitUnknown}.
@ -232,10 +225,8 @@ public class ElementKindVisitor6<R, P>
* @param p a visitor-specified parameter
* @return the result of {@code visitUnknown}
*
* @since 14
* @since 16
*/
@jdk.internal.PreviewFeature(feature=jdk.internal.PreviewFeature.Feature.RECORDS,
essentialAPI=false)
public R visitTypeAsRecord(TypeElement e, P p) {
return visitUnknown(e, p);
}

View File

@ -33,13 +33,6 @@ import javax.lang.model.SourceVersion;
import static javax.lang.model.SourceVersion.*;
/**
* {@preview Associated with records, a preview feature of the Java language.
*
* This class is associated with <i>records</i>, a preview
* feature of the Java language. Preview features
* may be removed in a future release, or upgraded to permanent
* features of the Java language.}
*
* A scanning visitor of program elements with default behavior
* appropriate for the {@link SourceVersion#RELEASE_14 RELEASE_14}
* source version.
@ -81,10 +74,8 @@ import static javax.lang.model.SourceVersion.*;
* @see ElementScanner7
* @see ElementScanner8
* @see ElementScanner9
* @since 14
* @since 16
*/
@jdk.internal.PreviewFeature(feature=jdk.internal.PreviewFeature.Feature.RECORDS,
essentialAPI=false)
@SupportedSourceVersion(RELEASE_16)
public class ElementScanner14<R, P> extends ElementScanner9<R, P> {
/**
@ -156,7 +147,6 @@ public class ElementScanner14<R, P> extends ElementScanner9<R, P> {
* @param p a visitor-specified parameter
* @return the result of the scan
*/
@SuppressWarnings("preview")
@Override
public R visitRecordComponent(RecordComponentElement e, P p) {
return scan(e.getEnclosedElements(), p);

View File

@ -634,13 +634,6 @@ public interface Elements {
boolean isFunctionalInterface(TypeElement type);
/**
* {@preview Associated with records, a preview feature of the Java language.
*
* This method is associated with <i>records</i>, a preview
* feature of the Java language. Preview features
* may be removed in a future release, or upgraded to permanent
* features of the Java language.}
*
* Returns the record component for the given accessor. Returns null if the
* given method is not a record component accessor.
*
@ -655,11 +648,8 @@ public interface Elements {
* @param accessor the method for which the record component should be found.
* @return the record component, or null if the given method is not an record
* component accessor
* @since 14
* @since 16
*/
@jdk.internal.PreviewFeature(feature=jdk.internal.PreviewFeature.Feature.RECORDS,
essentialAPI=false)
@SuppressWarnings("preview")
default RecordComponentElement recordComponentFor(ExecutableElement accessor) {
if (accessor.getEnclosingElement().getKind() == ElementKind.RECORD) {
for (RecordComponentElement rec : ElementFilter.recordComponentsIn(accessor.getEnclosingElement().getEnclosedElements())) {

View File

@ -31,13 +31,6 @@ import javax.lang.model.element.RecordComponentElement;
import static javax.lang.model.SourceVersion.*;
/**
* {@preview Associated with records, a preview feature of the Java language.
*
* This class is associated with <i>records</i>, a preview
* feature of the Java language. Preview features
* may be removed in a future release, or upgraded to permanent
* features of the Java language.}
*
* A simple visitor of program elements with default behavior
* appropriate for the {@link SourceVersion#RELEASE_14 RELEASE_14}
* source version.
@ -62,10 +55,8 @@ import static javax.lang.model.SourceVersion.*;
* @see SimpleElementVisitor7
* @see SimpleElementVisitor8
* @see SimpleElementVisitor9
* @since 14
* @since 16
*/
@jdk.internal.PreviewFeature(feature=jdk.internal.PreviewFeature.Feature.RECORDS,
essentialAPI=false)
@SupportedSourceVersion(RELEASE_16)
public class SimpleElementVisitor14<R, P> extends SimpleElementVisitor9<R, P> {
/**
@ -96,7 +87,6 @@ public class SimpleElementVisitor14<R, P> extends SimpleElementVisitor9<R, P> {
* @param p a visitor-specified parameter
* @return {@inheritDoc}
*/
@SuppressWarnings("preview")
@Override
public R visitRecordComponent(RecordComponentElement e, P p) {
return defaultAction(e, p);