Skip to content

Commit

Permalink
8255014: Record Classes javax.lang.model changes, follow-up
Browse files Browse the repository at this point in the history
Reviewed-by: jlahoda
  • Loading branch information
Vicente Romero committed Oct 28, 2020
1 parent 6bb7e45 commit 8ad7f38
Show file tree
Hide file tree
Showing 12 changed files with 18 additions and 139 deletions.
5 changes: 5 additions & 0 deletions src/java.base/share/classes/jdk/internal/PreviewFeature.java
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,11 @@ public enum Feature {
// 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,
;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,33 +109,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,

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -211,13 +211,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
Expand All @@ -226,11 +219,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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand All @@ -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();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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> {
/**
Expand All @@ -77,7 +68,6 @@ protected AbstractElementVisitor14(){
* @param p {@inheritDoc}
* @return {@inheritDoc}
*/
@SuppressWarnings("preview")
@Override
public abstract R visitRecordComponent(RecordComponentElement t, P p);
}
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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> {
/**
Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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}.
Expand All @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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> {
/**
Expand Down Expand Up @@ -156,7 +147,6 @@ private List<? extends Element> createScanningList(Parameterizable element,
* @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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -632,13 +632,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.
*
Expand All @@ -653,11 +646,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())) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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> {
/**
Expand Down Expand Up @@ -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);
Expand Down

1 comment on commit 8ad7f38

@bridgekeeper
Copy link

@bridgekeeper bridgekeeper bot commented on 8ad7f38 Oct 28, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.