Skip to content
Permalink
Browse files

8253455: Record Classes javax.lang.model changes

Reviewed-by: darcy
  • Loading branch information
Vicente Romero committed Oct 19, 2020
1 parent c17d585 commit 272bb5d580e5173de28bbc8c5b79364443103d72
@@ -62,6 +62,11 @@
// 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,
;
@@ -110,33 +110,15 @@
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,

/**
@@ -212,13 +212,6 @@ default R visitModule(ModuleElement e, P 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 @@ default R visitModule(ModuleElement e, P 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);
}
@@ -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.
@@ -180,13 +180,6 @@
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 @@
* @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();
}
@@ -31,13 +31,6 @@
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 @@
* @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 @@ protected AbstractElementVisitor14(){
* @param p {@inheritDoc}
* @return {@inheritDoc}
*/
@SuppressWarnings("preview")
@Override
public abstract R visitRecordComponent(RecordComponentElement t, P p);
}
@@ -112,42 +112,22 @@ private ElementFilter() {} // Do not instantiate.
}

/**
* {@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);
@@ -31,13 +31,6 @@
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 @@
* @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 @@ protected ElementKindVisitor14(R defaultValue) {
* @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);
@@ -217,13 +217,6 @@ public R visitTypeAsInterface(TypeElement e, P 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 R visitTypeAsInterface(TypeElement e, P 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);
}
@@ -33,13 +33,6 @@
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 @@
* @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 R visitExecutable(ExecutableElement e, P 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);
@@ -634,13 +634,6 @@ boolean overrides(ExecutableElement overrider, ExecutableElement overridden,
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 @@ boolean overrides(ExecutableElement overrider, ExecutableElement overridden,
* @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())) {
@@ -31,13 +31,6 @@
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 @@
* @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 @@ protected SimpleElementVisitor14(R defaultValue){
* @param p a visitor-specified parameter
* @return {@inheritDoc}
*/
@SuppressWarnings("preview")
@Override
public R visitRecordComponent(RecordComponentElement e, P p) {
return defaultAction(e, p);

1 comment on commit 272bb5d

@bridgekeeper

This comment has been minimized.

Copy link

@bridgekeeper bridgekeeper bot commented on 272bb5d Oct 19, 2020

Please sign in to comment.