Summary
-------
Add support for _record classes_ in javax.lang.model. Record classes, a.k.a. records, allow the definition of shallowly immutable, transparent carriers for a fixed set of values, the record components.
Problem
-------
Records, see ([JEP 359](http://openjdk.java.net/jeps/359)), will be previewed in Java SE 14 and support will be needed for them in javax.lang.model. In particular, a new element to represent record components will be needed, also new element kinds for records and record elements. In addition existing visitors at javax.lang.model will need to be modified for them to include the new record component element. New visitors will be needed too.
Solution
--------
Enhance javax.lang.model to support record classes. Add a new element at package <code>javax.lang.model.element</code> to represent record components. Modify existing visitors for them to include the new element. The addition of a new element will also imply adding new visitors specially targeted to Java SE 14.
Specification
-------------
diff -r 5573a7098439 src/java.compiler/share/classes/javax/lang/model/element/Element.java
--- a/src/java.compiler/share/classes/javax/lang/model/element/Element.java Sat Nov 02 10:02:18 2019 +0000
+++ b/src/java.compiler/share/classes/javax/lang/model/element/Element.java Tue Nov 19 07:52:45 2019 -0500
@@ -118,6 +118,7 @@
* @see TypeElement#getSimpleName
* @see VariableElement#getSimpleName
* @see ModuleElement#getSimpleName
+ * @see RecordComponentElement#getSimpleName
* @revised 9
* @spec JPMS
*/
@@ -148,6 +149,11 @@
* parameter}, {@linkplain ExecutableElement the executable
* element} which declares the parameter is returned.
*
+ * <li> If this is a {@linkplain
+ * RecordComponentElement#getEnclosingElement record component},
+ * {@linkplain TypeElement the type} which declares the
+ * record component is returned.
+ *
* <li> If this is a {@linkplain ModuleElement#getEnclosingElement
* module}, {@code null} is returned.
*
@@ -166,7 +172,7 @@
*
* A {@linkplain TypeElement#getEnclosedElements class or
* interface} is considered to enclose the fields, methods,
- * constructors, and member types that it directly declares.
+ * constructors, record components, and member types that it directly declares.
*
* A {@linkplain PackageElement#getEnclosedElements package}
* encloses the top-level classes and interfaces within it, but is
diff -r 5573a7098439 src/java.compiler/share/classes/javax/lang/model/element/ElementKind.java
--- a/src/java.compiler/share/classes/javax/lang/model/element/ElementKind.java Sat Nov 02 10:02:18 2019 +0000
+++ b/src/java.compiler/share/classes/javax/lang/model/element/ElementKind.java Tue Nov 19 07:52:45 2019 -0500
@@ -46,8 +46,12 @@
// Declared types
/** An enum type. */
ENUM,
- /** A class not described by a more specific kind (like {@code ENUM}). */
+ /**
+ * A class not described by a more specific kind (like {@code
+ * ENUM} or {@code RECORD}).
+ */
CLASS,
+
/** An annotation type. */
ANNOTATION_TYPE,
/**
@@ -90,6 +94,8 @@
*/
OTHER,
+ // Constants added since initial release
+
/**
* A resource variable.
* @since 1.7
@@ -101,17 +107,47 @@
* @since 9
* @spec JPMS
*/
- MODULE;
+ 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
+ */
+ @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
+ */
+ @jdk.internal.PreviewFeature(feature=jdk.internal.PreviewFeature.Feature.RECORDS,
+ essentialAPI=false)
+ RECORD_COMPONENT;
/**
* Returns {@code true} if this is a kind of class:
- * either {@code CLASS} or {@code ENUM}.
+ * either {@code CLASS} or {@code ENUM} or {@code RECORD}.
*
* @return {@code true} if this is a kind of class
*/
+ @SuppressWarnings("preview")
public boolean isClass() {
}
/**
diff -r 5573a7098439 src/java.compiler/share/classes/javax/lang/model/element/ElementVisitor.java
--- a/src/java.compiler/share/classes/javax/lang/model/element/ElementVisitor.java Sat Nov 02 10:02:18 2019 +0000
+++ b/src/java.compiler/share/classes/javax/lang/model/element/ElementVisitor.java Tue Nov 19 07:52:45 2019 -0500
@@ -164,4 +164,29 @@
default R visitModule(ModuleElement e, P p) {
return visitUnknown(e, 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
+ * RecordComponentElement} by calling {@code visitUnknown(e, p)}.
+ *
+ * @param e the element to visit
+ * @param p a visitor-specified parameter
+ * @return a visitor-specified result
+ * @since 14
+ */
+ @jdk.internal.PreviewFeature(feature=jdk.internal.PreviewFeature.Feature.RECORDS,
+ essentialAPI=false)
+ @SuppressWarnings("preview")
+ default R visitRecordComponent(RecordComponentElement e, P p) {
+ return visitUnknown(e, p);
+ }
}
diff -r 5573a7098439 src/java.compiler/share/classes/javax/lang/model/element/RecordComponentElement.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/java.compiler/share/classes/javax/lang/model/element/RecordComponentElement.java Tue Nov 19 07:52:45 2019 -0500
@@ -0,0 +1,74 @@
+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
+ */
+@jdk.internal.PreviewFeature(feature=jdk.internal.PreviewFeature.Feature.RECORDS,
+ essentialAPI=false)
+public interface RecordComponentElement extends Element {
+ /**
+ * Returns the enclosing element of this record component.
+ *
+ * The enclosing element of a record component is the type
+ * declaring the record component.
+ *
+ * @return the enclosing element of this record component
+ */
+ @Override
+ Element getEnclosingElement();
+
+ /**
+ * Returns the simple name of this record component.
+ *
+ * <p>The name of each record component must be distinct from the
+ * names of all other record components.
+ *
+ * @return the simple name of this record component
+ *
+ * @jls 6.2 Names and Identifiers
+ */
+ @Override
+ Name getSimpleName();
+
+ /**
+ * Returns the executable element for the accessor associated with the
+ * given record component.
+ *
+ * @return the record component accessor.
+ */
+ ExecutableElement getAccessor();
+}
diff -r 5573a7098439 src/java.compiler/share/classes/javax/lang/model/element/TypeElement.java
--- a/src/java.compiler/share/classes/javax/lang/model/element/TypeElement.java Sat Nov 02 10:02:18 2019 +0000
+++ b/src/java.compiler/share/classes/javax/lang/model/element/TypeElement.java Tue Nov 19 07:52:45 2019 -0500
@@ -32,7 +32,7 @@
/**
* Represents a class or interface program element. Provides access
* to information about the type and its members. Note that an enum
- * type is a kind of class and an annotation type is a kind of
+ * type and a record type are kinds of classes and an annotation type is a kind of
* interface.
*
* <p> While a {@code TypeElement} represents a class or interface
@@ -82,8 +82,9 @@
TypeMirror asType();
/**
- * Returns the fields, methods, constructors, and member types
- * that are directly declared in this class or interface.
+ * Returns the fields, methods, constructors, record components,
+ * and member types that are directly declared in this class or
+ * interface.
*
* This includes any {@linkplain Elements.Origin#MANDATED
* mandated} elements such as the (implicit) default constructor
@@ -178,6 +179,32 @@
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.
+ *
+ * @implSpec The default implementations of this method returns an
+ * empty and unmodifiable list.
+ *
+ * @return the record components, or an empty list if there are
+ * none
+ *
+ * @since 14
+ */
+ @jdk.internal.PreviewFeature(feature=jdk.internal.PreviewFeature.Feature.RECORDS,
+ essentialAPI=false)
+ @SuppressWarnings("preview")
+ default List<? extends RecordComponentElement> getRecordComponents() {
+ }
+
+ /**
* Returns the package of a top-level type and returns the
* immediately lexically enclosing element for a {@linkplain
* NestingKind#isNested nested} type.
diff -r 5573a7098439 src/java.compiler/share/classes/javax/lang/model/element/package-info.java
--- a/src/java.compiler/share/classes/javax/lang/model/element/package-info.java Sat Nov 02 10:02:18 2019 +0000
+++ b/src/java.compiler/share/classes/javax/lang/model/element/package-info.java Tue Nov 19 07:52:45 2019 -0500
@@ -90,8 +90,8 @@
* new RuntimeException();"}. If a program refers to a missing type Xyz,
* the returned model must contain no less information than if the
* declaration of type Xyz were assumed to be {@code "class Xyz {}"},
- * {@code "interface Xyz {}"}, {@code "enum Xyz {}"}, or {@code
- * "@interface Xyz {}"}. If a program refers to a missing type {@code
+ * {@code "interface Xyz {}"}, {@code "enum Xyz {}"}, {@code
+ * "@interface Xyz {}"}, or {@code "record Xyz {}"}. If a program refers to a missing type {@code
* Xyz<K1, ... ,Kn>}, the returned model must contain no less
* information than if the declaration of Xyz were assumed to be
* {@code "class Xyz<T1, ... ,Tn> {}"} or {@code "interface Xyz<T1,
diff -r 5573a7098439 src/java.compiler/share/classes/javax/lang/model/util/AbstractAnnotationValueVisitor14.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/java.compiler/share/classes/javax/lang/model/util/AbstractAnnotationValueVisitor14.java Tue Nov 19 07:52:45 2019 -0500
@@ -0,0 +1,71 @@
+package javax.lang.model.util;
+
+import static javax.lang.model.SourceVersion.*;
+import javax.lang.model.SourceVersion;
+import javax.annotation.processing.SupportedSourceVersion;
+
+/**
+ * A skeletal visitor for annotation values with default behavior
+ * appropriate for source version {@link SourceVersion#RELEASE_14 RELEASE_14}.
+ *
+ * <p> <b>WARNING:</b> The {@code AnnotationValueVisitor} interface
+ * implemented by this class may have methods added to it in the
+ * future to accommodate new, currently unknown, language structures
+ * added to future versions of the Java™ programming language.
+ * Therefore, methods whose names begin with {@code "visit"} may be
+ * added to this class in the future; to avoid incompatibilities,
+ * classes which extend this class should not declare any instance
+ * methods with names beginning with {@code "visit"}.
+ *
+ * <p>When such a new visit method is added, the default
+ * implementation in this class will be to call the {@link
+ * #visitUnknown visitUnknown} method. A new abstract annotation
+ * value visitor class will also be introduced to correspond to the
+ * new language level; this visitor will have different default
+ * behavior for the visit method in question. When the new visitor is
+ * introduced, all or portions of this visitor may be deprecated.
+ *
+ * @param <R> the return type of this visitor's methods
+ * @param <P> the type of the additional parameter to this visitor's methods.
+ *
+ * @see AbstractAnnotationValueVisitor6
+ * @see AbstractAnnotationValueVisitor7
+ * @see AbstractAnnotationValueVisitor8
+ * @see AbstractAnnotationValueVisitor9
+ * @since 14
+ */
+@SupportedSourceVersion(RELEASE_14)
+public abstract class AbstractAnnotationValueVisitor14<R, P> extends AbstractAnnotationValueVisitor9<R, P> {
+
+ /**
+ * Constructor for concrete subclasses to call.
+ */
+ protected AbstractAnnotationValueVisitor14() {
+ }
+}
diff -r 5573a7098439 src/java.compiler/share/classes/javax/lang/model/util/AbstractAnnotationValueVisitor6.java
--- a/src/java.compiler/share/classes/javax/lang/model/util/AbstractAnnotationValueVisitor6.java Sat Nov 02 10:02:18 2019 +0000
+++ b/src/java.compiler/share/classes/javax/lang/model/util/AbstractAnnotationValueVisitor6.java Tue Nov 19 07:52:45 2019 -0500
@@ -64,6 +64,7 @@
* @see AbstractAnnotationValueVisitor7
* @see AbstractAnnotationValueVisitor8
* @see AbstractAnnotationValueVisitor9
+ * @see AbstractAnnotationValueVisitor14
* @since 1.6
*/
@SupportedSourceVersion(RELEASE_6)
diff -r 5573a7098439 src/java.compiler/share/classes/javax/lang/model/util/AbstractAnnotationValueVisitor7.java
--- a/src/java.compiler/share/classes/javax/lang/model/util/AbstractAnnotationValueVisitor7.java Sat Nov 02 10:02:18 2019 +0000
+++ b/src/java.compiler/share/classes/javax/lang/model/util/AbstractAnnotationValueVisitor7.java Tue Nov 19 07:52:45 2019 -0500
@@ -57,6 +57,7 @@
* @see AbstractAnnotationValueVisitor6
* @see AbstractAnnotationValueVisitor8
* @see AbstractAnnotationValueVisitor9
+ * @see AbstractAnnotationValueVisitor14
* @since 1.7
*/
@SupportedSourceVersion(RELEASE_7)
diff -r 5573a7098439 src/java.compiler/share/classes/javax/lang/model/util/AbstractAnnotationValueVisitor8.java
--- a/src/java.compiler/share/classes/javax/lang/model/util/AbstractAnnotationValueVisitor8.java Sat Nov 02 10:02:18 2019 +0000
+++ b/src/java.compiler/share/classes/javax/lang/model/util/AbstractAnnotationValueVisitor8.java Tue Nov 19 07:52:45 2019 -0500
@@ -57,6 +57,7 @@
* @see AbstractAnnotationValueVisitor6
* @see AbstractAnnotationValueVisitor7
* @see AbstractAnnotationValueVisitor9
+ * @see AbstractAnnotationValueVisitor14
* @since 1.8
*/
@SupportedSourceVersion(RELEASE_8)
diff -r 5573a7098439 src/java.compiler/share/classes/javax/lang/model/util/AbstractAnnotationValueVisitor9.java
--- a/src/java.compiler/share/classes/javax/lang/model/util/AbstractAnnotationValueVisitor9.java Sat Nov 02 10:02:18 2019 +0000
+++ b/src/java.compiler/share/classes/javax/lang/model/util/AbstractAnnotationValueVisitor9.java Tue Nov 19 07:52:45 2019 -0500
@@ -57,6 +57,7 @@
* @see AbstractAnnotationValueVisitor6
* @see AbstractAnnotationValueVisitor7
* @see AbstractAnnotationValueVisitor8
+ * @see AbstractAnnotationValueVisitor14
* @since 9
*/
@SupportedSourceVersion(RELEASE_14)
diff -r 5573a7098439 src/java.compiler/share/classes/javax/lang/model/util/AbstractElementVisitor14.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/java.compiler/share/classes/javax/lang/model/util/AbstractElementVisitor14.java Tue Nov 19 07:52:45 2019 -0500
@@ -0,0 +1,98 @@
+package javax.lang.model.util;
+
+import javax.annotation.processing.SupportedSourceVersion;
+import javax.lang.model.SourceVersion;
+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.
+ *
+ * <p> <b>WARNING:</b> The {@code ElementVisitor} interface
+ * implemented by this class may have methods added to it in the
+ * future to accommodate new, currently unknown, language structures
+ * added to future versions of the Java™ programming language.
+ * Therefore, methods whose names begin with {@code "visit"} may be
+ * added to this class in the future; to avoid incompatibilities,
+ * classes which extend this class should not declare any instance
+ * methods with names beginning with {@code "visit"}.
+ *
+ * <p>When such a new visit method is added, the default
+ * implementation in this class will be to call the {@link
+ * #visitUnknown visitUnknown} method. A new abstract element visitor
+ * class will also be introduced to correspond to the new language
+ * level; this visitor will have different default behavior for the
+ * visit method in question. When the new visitor is introduced, all
+ * or portions of this visitor may be deprecated.
+ *
+ * @param <R> the return type of this visitor's methods. Use {@link
+ * Void} for visitors that do not need to return results.
+ * @param <P> the type of the additional parameter to this visitor's
+ * methods. Use {@code Void} for visitors that do not need an
+ * additional parameter.
+ *
+ * @see AbstractElementVisitor6
+ * @see AbstractElementVisitor7
+ * @see AbstractElementVisitor8
+ * @see AbstractElementVisitor9
+ * @since 14
+ */
+@jdk.internal.PreviewFeature(feature=jdk.internal.PreviewFeature.Feature.RECORDS,
+ essentialAPI=false)
+@SupportedSourceVersion(RELEASE_14)
+public abstract class AbstractElementVisitor14<R, P> extends AbstractElementVisitor9<R, P> {
+ /**
+ * Constructor for concrete subclasses to call.
+ */
+ protected AbstractElementVisitor14(){
+ super();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @implSpec Visits a {@code RecordComponentElement} in a manner defined by a
+ * subclass.
+ *
+ * @param t {@inheritDoc}
+ * @param p {@inheritDoc}
+ * @return {@inheritDoc}
+ */
+ @SuppressWarnings("preview")
+ @Override
+ public abstract R visitRecordComponent(RecordComponentElement t, P p);
+}
diff -r 5573a7098439 src/java.compiler/share/classes/javax/lang/model/util/AbstractElementVisitor6.java
--- a/src/java.compiler/share/classes/javax/lang/model/util/AbstractElementVisitor6.java Sat Nov 02 10:02:18 2019 +0000
+++ b/src/java.compiler/share/classes/javax/lang/model/util/AbstractElementVisitor6.java Tue Nov 19 07:52:45 2019 -0500
@@ -66,6 +66,7 @@
* @see AbstractElementVisitor7
* @see AbstractElementVisitor8
* @see AbstractElementVisitor9
+ * @see AbstractElementVisitor14
* @since 1.6
*/
@SupportedSourceVersion(RELEASE_6)
@@ -143,4 +144,23 @@
// Use implementation from interface default method
return ElementVisitor.super.visitModule(e, p);
}
+
+ /**
+ * {@inheritDoc}
+ *
+ * @implSpec Visits a {@code RecordComponentElement} by calling {@code
+ * visitUnknown}.
+ *
+ * @param e {@inheritDoc}
+ * @param p {@inheritDoc}
+ * @return {@inheritDoc}
+ *
+ * @since 14
+ */
+ @SuppressWarnings("preview")
+ @Override
+ public R visitRecordComponent(RecordComponentElement e, P p) {
+ }
}
diff -r 5573a7098439 src/java.compiler/share/classes/javax/lang/model/util/AbstractElementVisitor7.java
--- a/src/java.compiler/share/classes/javax/lang/model/util/AbstractElementVisitor7.java Sat Nov 02 10:02:18 2019 +0000
+++ b/src/java.compiler/share/classes/javax/lang/model/util/AbstractElementVisitor7.java Tue Nov 19 07:52:45 2019 -0500
@@ -61,6 +61,7 @@
* @see AbstractElementVisitor6
* @see AbstractElementVisitor8
* @see AbstractElementVisitor9
+ * @see AbstractElementVisitor14
* @since 1.7
*/
@SupportedSourceVersion(RELEASE_7)
diff -r 5573a7098439 src/java.compiler/share/classes/javax/lang/model/util/AbstractElementVisitor8.java
--- a/src/java.compiler/share/classes/javax/lang/model/util/AbstractElementVisitor8.java Sat Nov 02 10:02:18 2019 +0000
+++ b/src/java.compiler/share/classes/javax/lang/model/util/AbstractElementVisitor8.java Tue Nov 19 07:52:45 2019 -0500
@@ -61,6 +61,7 @@
* @see AbstractElementVisitor6
* @see AbstractElementVisitor7
* @see AbstractElementVisitor9
+ * @see AbstractElementVisitor14
* @since 1.8
*/
@SupportedSourceVersion(RELEASE_8)
diff -r 5573a7098439 src/java.compiler/share/classes/javax/lang/model/util/AbstractTypeVisitor14.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/java.compiler/share/classes/javax/lang/model/util/AbstractTypeVisitor14.java Tue Nov 19 07:52:45 2019 -0500
@@ -0,0 +1,73 @@
+package javax.lang.model.util;
+
+import javax.annotation.processing.SupportedSourceVersion;
+import javax.lang.model.SourceVersion;
+import static javax.lang.model.SourceVersion.*;
+
+/**
+ * A skeletal visitor of types with default behavior appropriate for the
+ * {@link SourceVersion#RELEASE_14 RELEASE_14} source version.
+ *
+ * <p> <b>WARNING:</b> The {@code TypeVisitor} interface implemented
+ * by this class may have methods added to it in the future to
+ * accommodate new, currently unknown, language structures added to
+ * future versions of the Java™ programming language.
+ * Therefore, methods whose names begin with {@code "visit"} may be
+ * added to this class in the future; to avoid incompatibilities,
+ * classes which extend this class should not declare any instance
+ * methods with names beginning with {@code "visit"}.
+ *
+ * <p>When such a new visit method is added, the default
+ * implementation in this class will be to call the {@link
+ * #visitUnknown visitUnknown} method. A new abstract type visitor
+ * class will also be introduced to correspond to the new language
+ * level; this visitor will have different default behavior for the
+ * visit method in question. When the new visitor is introduced, all
+ * or portions of this visitor may be deprecated.
+ *
+ * @param <R> the return type of this visitor's methods. Use {@link
+ * Void} for visitors that do not need to return results.
+ * @param <P> the type of the additional parameter to this visitor's
+ * methods. Use {@code Void} for visitors that do not need an
+ * additional parameter.
+ *
+ * @see AbstractTypeVisitor6
+ * @see AbstractTypeVisitor7
+ * @see AbstractTypeVisitor8
+ * @see AbstractTypeVisitor9
+ * @since 14
+ */
+@SupportedSourceVersion(RELEASE_14)
+public abstract class AbstractTypeVisitor14<R, P> extends AbstractTypeVisitor9<R, P> {
+ /**
+ * Constructor for concrete subclasses to call.
+ */
+ protected AbstractTypeVisitor14() {
+ }
+}
diff -r 5573a7098439 src/java.compiler/share/classes/javax/lang/model/util/AbstractTypeVisitor6.java
--- a/src/java.compiler/share/classes/javax/lang/model/util/AbstractTypeVisitor6.java Sat Nov 02 10:02:18 2019 +0000
+++ b/src/java.compiler/share/classes/javax/lang/model/util/AbstractTypeVisitor6.java Tue Nov 19 07:52:45 2019 -0500
@@ -65,6 +65,7 @@
* @see AbstractTypeVisitor7
* @see AbstractTypeVisitor8
* @see AbstractTypeVisitor9
+ * @see AbstractTypeVisitor14
* @since 1.6
*/
@SupportedSourceVersion(RELEASE_6)
diff -r 5573a7098439 src/java.compiler/share/classes/javax/lang/model/util/AbstractTypeVisitor7.java
--- a/src/java.compiler/share/classes/javax/lang/model/util/AbstractTypeVisitor7.java Sat Nov 02 10:02:18 2019 +0000
+++ b/src/java.compiler/share/classes/javax/lang/model/util/AbstractTypeVisitor7.java Tue Nov 19 07:52:45 2019 -0500
@@ -61,6 +61,7 @@
* @see AbstractTypeVisitor6
* @see AbstractTypeVisitor8
* @see AbstractTypeVisitor9
+ * @see AbstractTypeVisitor14
* @since 1.7
*/
@SupportedSourceVersion(RELEASE_7)
diff -r 5573a7098439 src/java.compiler/share/classes/javax/lang/model/util/AbstractTypeVisitor8.java
--- a/src/java.compiler/share/classes/javax/lang/model/util/AbstractTypeVisitor8.java Sat Nov 02 10:02:18 2019 +0000
+++ b/src/java.compiler/share/classes/javax/lang/model/util/AbstractTypeVisitor8.java Tue Nov 19 07:52:45 2019 -0500
@@ -61,6 +61,7 @@
* @see AbstractTypeVisitor6
* @see AbstractTypeVisitor7
* @see AbstractTypeVisitor9
+ * @see AbstractTypeVisitor14
* @since 1.8
*/
@SupportedSourceVersion(RELEASE_8)
diff -r 5573a7098439 src/java.compiler/share/classes/javax/lang/model/util/AbstractTypeVisitor9.java
--- a/src/java.compiler/share/classes/javax/lang/model/util/AbstractTypeVisitor9.java Sat Nov 02 10:02:18 2019 +0000
+++ b/src/java.compiler/share/classes/javax/lang/model/util/AbstractTypeVisitor9.java Tue Nov 19 07:52:45 2019 -0500
@@ -61,6 +61,7 @@
* @see AbstractTypeVisitor6
* @see AbstractTypeVisitor7
* @see AbstractTypeVisitor8
+ * @see AbstractTypeVisitor14
* @since 9
*/
@SupportedSourceVersion(RELEASE_14)
diff -r 5573a7098439 src/java.compiler/share/classes/javax/lang/model/util/ElementFilter.java
--- a/src/java.compiler/share/classes/javax/lang/model/util/ElementFilter.java Sat Nov 02 10:02:18 2019 +0000
+++ b/src/java.compiler/share/classes/javax/lang/model/util/ElementFilter.java Tue Nov 19 07:52:45 2019 -0500
@@ -105,6 +112,48 @@
}
/**
+ * {@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
+ */
+ @jdk.internal.PreviewFeature(feature=jdk.internal.PreviewFeature.Feature.RECORDS,
+ essentialAPI=false)
+ @SuppressWarnings("preview")
+ public static List<RecordComponentElement>
+ recordComponentsIn(Iterable<? extends Element> elements) {
+ }
+
+ /**
+ * {@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
+ */
+ @jdk.internal.PreviewFeature(feature=jdk.internal.PreviewFeature.Feature.RECORDS,
+ essentialAPI=false)
+ @SuppressWarnings("preview")
+ public static Set<RecordComponentElement>
+ recordComponentsIn(Set<? extends Element> elements) {
+ }
+
+ /**
* Returns a list of constructors in {@code elements}.
* @return a list of constructors in {@code elements}
* @param elements the elements to filter
diff -r 5573a7098439 src/java.compiler/share/classes/javax/lang/model/util/ElementKindVisitor14.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/java.compiler/share/classes/javax/lang/model/util/ElementKindVisitor14.java Tue Nov 19 07:52:45 2019 -0500
@@ -0,0 +1,139 @@
+package javax.lang.model.util;
+
+import javax.lang.model.element.*;
+import javax.annotation.processing.SupportedSourceVersion;
+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.
+ *
+ * For {@linkplain
+ * Element elements} <code><i>Xyz</i></code> that may have more than one
+ * kind, the <code>visit<i>Xyz</i></code> methods in this class delegate
+ * to the <code>visit<i>Xyz</i>As<i>Kind</i></code> method corresponding to the
+ * first argument's kind. The <code>visit<i>Xyz</i>As<i>Kind</i></code> methods
+ * call {@link #defaultAction defaultAction}, passing their arguments
+ * to {@code defaultAction}'s corresponding parameters.
+ *
+ * <p> Methods in this class may be overridden subject to their
+ * general contract. Note that annotating methods in concrete
+ * subclasses with {@link java.lang.Override @Override} will help
+ * ensure that methods are overridden as intended.
+ *
+ * <p> <b>WARNING:</b> The {@code ElementVisitor} interface
+ * implemented by this class may have methods added to it or the
+ * {@code ElementKind} {@code enum} used in this case may have
+ * constants added to it in the future to accommodate new, currently
+ * unknown, language structures added to future versions of the
+ * Java™ programming language. Therefore, methods whose names
+ * begin with {@code "visit"} may be added to this class in the
+ * future; to avoid incompatibilities, classes which extend this class
+ * should not declare any instance methods with names beginning with
+ * {@code "visit"}.
+ *
+ * <p>When such a new visit method is added, the default
+ * implementation in this class will be to call the {@link
+ * #visitUnknown visitUnknown} method. A new abstract element kind
+ * visitor class will also be introduced to correspond to the new
+ * language level; this visitor will have different default behavior
+ * for the visit method in question. When the new visitor is
+ * introduced, all or portions of this visitor may be deprecated.
+ *
+ * @param <R> the return type of this visitor's methods. Use {@link
+ * Void} for visitors that do not need to return results.
+ * @param <P> the type of the additional parameter to this visitor's
+ * methods. Use {@code Void} for visitors that do not need an
+ * additional parameter.
+ *
+ * @see ElementKindVisitor6
+ * @see ElementKindVisitor7
+ * @see ElementKindVisitor8
+ * @see ElementKindVisitor9
+ * @since 14
+ */
+@jdk.internal.PreviewFeature(feature=jdk.internal.PreviewFeature.Feature.RECORDS,
+ essentialAPI=false)
+@SupportedSourceVersion(RELEASE_14)
+public class ElementKindVisitor14<R, P> extends ElementKindVisitor9<R, P> {
+ /**
+ * Constructor for concrete subclasses; uses {@code null} for the
+ * default value.
+ */
+ protected ElementKindVisitor14() {
+ }
+
+ /**
+ * Constructor for concrete subclasses; uses the argument for the
+ * default value.
+ *
+ * @param defaultValue the value to assign to {@link #DEFAULT_VALUE}
+ */
+ protected ElementKindVisitor14(R defaultValue) {
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @implSpec This implementation calls {@code defaultAction}.
+ *
+ * @param e the element to visit
+ * @param p a visitor-specified parameter
+ * @return the result of {@code defaultAction}
+ */
+ @SuppressWarnings("preview")
+ @Override
+ public R visitRecordComponent(RecordComponentElement e, P p) {
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @implSpec This implementation calls {@code defaultAction}.
+ *.
+ * @param e the element to visit
+ * @param p a visitor-specified parameter
+ * @return the result of {@code defaultAction}
+ */
+ @Override
+ public R visitTypeAsRecord(TypeElement e, P p) {
+ }
+}
diff -r 5573a7098439 src/java.compiler/share/classes/javax/lang/model/util/ElementKindVisitor6.java
--- a/src/java.compiler/share/classes/javax/lang/model/util/ElementKindVisitor6.java Sat Nov 02 10:02:18 2019 +0000
+++ b/src/java.compiler/share/classes/javax/lang/model/util/ElementKindVisitor6.java Tue Nov 19 07:52:45 2019 -0500
@@ -80,6 +80,7 @@
* @see ElementKindVisitor7
* @see ElementKindVisitor8
* @see ElementKindVisitor9
+ * @see ElementKindVisitor14
* @since 1.6
*/
@SupportedSourceVersion(RELEASE_6)
@@ -138,6 +139,7 @@
* @param p {@inheritDoc}
* @return the result of the kind-specific visit method
*/
+ @SuppressWarnings("preview")
@Override
public R visitType(TypeElement e, P p) {
ElementKind k = e.getKind();
@@ -212,6 +217,30 @@
}
/**
+ * {@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}.
+ *.
+ * @param e the element to visit
+ * @param p a visitor-specified parameter
+ * @return the result of {@code visitUnknown}
+ *
+ * @since 14
+ */
+ @jdk.internal.PreviewFeature(feature=jdk.internal.PreviewFeature.Feature.RECORDS,
+ essentialAPI=false)
+ public R visitTypeAsRecord(TypeElement e, P p) {
+ }
+
+ /**
* Visits a variable element
*
* @implSpec This implementation dispatches to the visit method for
diff -r 5573a7098439 src/java.compiler/share/classes/javax/lang/model/util/ElementKindVisitor7.java
--- a/src/java.compiler/share/classes/javax/lang/model/util/ElementKindVisitor7.java Sat Nov 02 10:02:18 2019 +0000
+++ b/src/java.compiler/share/classes/javax/lang/model/util/ElementKindVisitor7.java Tue Nov 19 07:52:45 2019 -0500
@@ -74,6 +74,7 @@
* @see ElementKindVisitor6
* @see ElementKindVisitor8
* @see ElementKindVisitor9
+ * @see ElementKindVisitor14
* @since 1.7
*/
@SupportedSourceVersion(RELEASE_7)
diff -r 5573a7098439 src/java.compiler/share/classes/javax/lang/model/util/ElementKindVisitor8.java
--- a/src/java.compiler/share/classes/javax/lang/model/util/ElementKindVisitor8.java Sat Nov 02 10:02:18 2019 +0000
+++ b/src/java.compiler/share/classes/javax/lang/model/util/ElementKindVisitor8.java Tue Nov 19 07:52:45 2019 -0500
@@ -74,6 +74,7 @@
* @see ElementKindVisitor6
* @see ElementKindVisitor7
* @see ElementKindVisitor9
+ * @see ElementKindVisitor14
* @since 1.8
*/
@SupportedSourceVersion(RELEASE_8)
diff -r 5573a7098439 src/java.compiler/share/classes/javax/lang/model/util/ElementScanner14.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/java.compiler/share/classes/javax/lang/model/util/ElementScanner14.java Tue Nov 19 07:52:45 2019 -0500
@@ -0,0 +1,137 @@
+package javax.lang.model.util;
+
+import javax.lang.model.element.*;
+import javax.annotation.processing.SupportedSourceVersion;
+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.
+ *
+ * The <code>visit<i>Xyz</i></code> methods in this
+ * class scan their component elements by calling {@code scan} on
+ * their {@linkplain Element#getEnclosedElements enclosed elements},
+ * {@linkplain ExecutableElement#getParameters parameters}, etc., as
+ * indicated in the individual method specifications. A subclass can
+ * control the order elements are visited by overriding the
+ * <code>visit<i>Xyz</i></code> methods. Note that clients of a scanner
+ * may get the desired behavior be invoking {@code v.scan(e, p)} rather
+ * than {@code v.visit(e, p)} on the root objects of interest.
+ *
+ * <p>When a subclass overrides a <code>visit<i>Xyz</i></code> method, the
+ * new method can cause the enclosed elements to be scanned in the
+ * default way by calling <code>super.visit<i>Xyz</i></code>. In this
+ * fashion, the concrete visitor can control the ordering of traversal
+ * over the component elements with respect to the additional
+ * processing; for example, consistently calling
+ * <code>super.visit<i>Xyz</i></code> at the start of the overridden
+ * methods will yield a preorder traversal, etc. If the component
+ * elements should be traversed in some other order, instead of
+ * calling <code>super.visit<i>Xyz</i></code>, an overriding visit method
+ * should call {@code scan} with the elements in the desired order.
+ *
+ * <p> Methods in this class may be overridden subject to their
+ * general contract. Note that annotating methods in concrete
+ * subclasses with {@link java.lang.Override @Override} will help
+ * ensure that methods are overridden as intended.
+ *
+ * <p> <b>WARNING:</b> The {@code ElementVisitor} interface
+ * implemented by this class may have methods added to it in the
+ * future to accommodate new, currently unknown, language structures
+ * added to future versions of the Java™ programming language.
+ * Therefore, methods whose names begin with {@code "visit"} may be
+ * added to this class in the future; to avoid incompatibilities,
+ * classes which extend this class should not declare any instance
+ * methods with names beginning with {@code "visit"}.
+ *
+ * <p>When such a new visit method is added, the default
+ * implementation in this class will be to call the {@link
+ * #visitUnknown visitUnknown} method. A new element scanner visitor
+ * class will also be introduced to correspond to the new language
+ * level; this visitor will have different default behavior for the
+ * visit method in question. When the new visitor is introduced, all
+ * or portions of this visitor may be deprecated.
+ *
+ * @param <R> the return type of this visitor's methods. Use {@link
+ * Void} for visitors that do not need to return results.
+ * @param <P> the type of the additional parameter to this visitor's
+ * methods. Use {@code Void} for visitors that do not need an
+ * additional parameter.
+ *
+ * @see ElementScanner6
+ * @see ElementScanner7
+ * @see ElementScanner8
+ * @see ElementScanner9
+ * @since 14
+ */
+@jdk.internal.PreviewFeature(feature=jdk.internal.PreviewFeature.Feature.RECORDS,
+ essentialAPI=false)
+@SupportedSourceVersion(RELEASE_14)
+public class ElementScanner14<R, P> extends ElementScanner9<R, P> {
+ /**
+ * Constructor for concrete subclasses; uses {@code null} for the
+ * default value.
+ */
+ protected ElementScanner14(){
+ }
+
+ /**
+ * Constructor for concrete subclasses; uses the argument for the
+ * default value.
+ *
+ * @param defaultValue the default value
+ */
+ protected ElementScanner14(R defaultValue){
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @implSpec This implementation scans the enclosed elements.
+ *
+ * @param e the element to visit
+ * @param p a visitor-specified parameter
+ * @return the result of the scan
+ */
+ @SuppressWarnings("preview")
+ @Override
+ public R visitRecordComponent(RecordComponentElement e, P p) {
+ }
+}
diff -r 5573a7098439 src/java.compiler/share/classes/javax/lang/model/util/ElementScanner6.java
--- a/src/java.compiler/share/classes/javax/lang/model/util/ElementScanner6.java Sat Nov 02 10:02:18 2019 +0000
+++ b/src/java.compiler/share/classes/javax/lang/model/util/ElementScanner6.java Tue Nov 19 07:52:45 2019 -0500
@@ -91,6 +91,7 @@
* @see ElementScanner7
* @see ElementScanner8
* @see ElementScanner9
+ * @see ElementScanner14
* @since 1.6
*/
@SupportedSourceVersion(RELEASE_6)
diff -r 5573a7098439 src/java.compiler/share/classes/javax/lang/model/util/ElementScanner7.java
--- a/src/java.compiler/share/classes/javax/lang/model/util/ElementScanner7.java Sat Nov 02 10:02:18 2019 +0000
+++ b/src/java.compiler/share/classes/javax/lang/model/util/ElementScanner7.java Tue Nov 19 07:52:45 2019 -0500
@@ -87,6 +87,7 @@
* @see ElementScanner6
* @see ElementScanner8
* @see ElementScanner9
+ * @see ElementScanner14
* @since 1.7
*/
@SupportedSourceVersion(RELEASE_7)
diff -r 5573a7098439 src/java.compiler/share/classes/javax/lang/model/util/ElementScanner8.java
--- a/src/java.compiler/share/classes/javax/lang/model/util/ElementScanner8.java Sat Nov 02 10:02:18 2019 +0000
+++ b/src/java.compiler/share/classes/javax/lang/model/util/ElementScanner8.java Tue Nov 19 07:52:45 2019 -0500
@@ -87,6 +87,7 @@
* @see ElementScanner6
* @see ElementScanner7
* @see ElementScanner9
+ * @see ElementScanner14
* @since 1.8
*/
@SupportedSourceVersion(RELEASE_8)
diff -r 5573a7098439 src/java.compiler/share/classes/javax/lang/model/util/ElementScanner9.java
--- a/src/java.compiler/share/classes/javax/lang/model/util/ElementScanner9.java Sat Nov 02 10:02:18 2019 +0000
+++ b/src/java.compiler/share/classes/javax/lang/model/util/ElementScanner9.java Tue Nov 19 07:52:45 2019 -0500
@@ -89,6 +89,7 @@
* @see ElementScanner6
* @see ElementScanner7
* @see ElementScanner8
+ * @see ElementScanner14
* @since 9
* @spec JPMS
*/
diff -r 5573a7098439 src/java.compiler/share/classes/javax/lang/model/util/Elements.java
--- a/src/java.compiler/share/classes/javax/lang/model/util/Elements.java Sat Nov 02 10:02:18 2019 +0000
+++ b/src/java.compiler/share/classes/javax/lang/model/util/Elements.java Tue Nov 19 07:52:45 2019 -0500
@@ -31,6 +31,7 @@
import java.util.Map;
import java.util.Set;
import java.util.LinkedHashSet;
+import java.util.Objects;
import javax.lang.model.AnnotatedConstruct;
import javax.lang.model.element.*;
@@ -629,4 +630,42 @@
* @since 1.8
*/
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.
+ *
+ * @implSpec The default implementation of this method checks if the element
+ * enclosing the accessor has kind {@link ElementKind#RECORD RECORD} if that is
+ * the case, then all the record components on the accessor's enclosing element
+ * are retrieved by invoking {@link ElementFilter#recordComponentsIn(Iterable)}.
+ * If the accessor of at least one of the record components retrieved happen to
+ * be equal to the accessor passed as a parameter to this method, then that
+ * record component is returned, in any other case {@code null} is returned.
+ *
+ * @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
+ */
+ @jdk.internal.PreviewFeature(feature=jdk.internal.PreviewFeature.Feature.RECORDS,
+ essentialAPI=false)
+ @SuppressWarnings("preview")
+ default RecordComponentElement recordComponentFor(ExecutableElement accessor) {
+ }
}
diff -r 5573a7098439 src/java.compiler/share/classes/javax/lang/model/util/SimpleAnnotationValueVisitor14.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/java.compiler/share/classes/javax/lang/model/util/SimpleAnnotationValueVisitor14.java Tue Nov 19 07:52:45 2019 -0500
@@ -0,0 +1,90 @@
+package javax.lang.model.util;
+
+import javax.annotation.processing.SupportedSourceVersion;
+import javax.lang.model.SourceVersion;
+import static javax.lang.model.SourceVersion.*;
+
+/**
+ * A simple visitor for annotation values with default behavior
+ * appropriate for source version {@link SourceVersion#RELEASE_14 RELEASE_14}.
+ *
+ * Visit methods call {@link #defaultAction
+ * defaultAction} passing their arguments to {@code defaultAction}'s
+ * corresponding parameters.
+ *
+ * <p> Methods in this class may be overridden subject to their
+ * general contract. Note that annotating methods in concrete
+ * subclasses with {@link java.lang.Override @Override} will help
+ * ensure that methods are overridden as intended.
+ *
+ * <p> <b>WARNING:</b> The {@code AnnotationValueVisitor} interface
+ * implemented by this class may have methods added to it in the
+ * future to accommodate new, currently unknown, language structures
+ * added to future versions of the Java™ programming language.
+ * Therefore, methods whose names begin with {@code "visit"} may be
+ * added to this class in the future; to avoid incompatibilities,
+ * classes which extend this class should not declare any instance
+ * methods with names beginning with {@code "visit"}.
+ *
+ * <p>When such a new visit method is added, the default
+ * implementation in this class will be to call the {@link
+ * #visitUnknown visitUnknown} method. A new simple annotation
+ * value visitor class will also be introduced to correspond to the
+ * new language level; this visitor will have different default
+ * behavior for the visit method in question. When the new visitor is
+ * introduced, all or portions of this visitor may be deprecated.
+ *
+ * @param <R> the return type of this visitor's methods
+ * @param <P> the type of the additional parameter to this visitor's methods.
+ *
+ * @see SimpleAnnotationValueVisitor6
+ * @see SimpleAnnotationValueVisitor7
+ * @see SimpleAnnotationValueVisitor8
+ * @see SimpleAnnotationValueVisitor9
+ * @since 14
+ */
+@SupportedSourceVersion(RELEASE_14)
+public class SimpleAnnotationValueVisitor14<R, P> extends SimpleAnnotationValueVisitor9<R, P> {
+ /**
+ * Constructor for concrete subclasses; uses {@code null} for the
+ * default value.
+ */
+ protected SimpleAnnotationValueVisitor14() {
+ }
+
+ /**
+ * Constructor for concrete subclasses; uses the argument for the
+ * default value.
+ *
+ * @param defaultValue the value to assign to {@link #DEFAULT_VALUE}
+ */
+ protected SimpleAnnotationValueVisitor14(R defaultValue) {
+ }
+}
diff -r 5573a7098439 src/java.compiler/share/classes/javax/lang/model/util/SimpleAnnotationValueVisitor6.java
--- a/src/java.compiler/share/classes/javax/lang/model/util/SimpleAnnotationValueVisitor6.java Sat Nov 02 10:02:18 2019 +0000
+++ b/src/java.compiler/share/classes/javax/lang/model/util/SimpleAnnotationValueVisitor6.java Tue Nov 19 07:52:45 2019 -0500
@@ -73,6 +73,7 @@
* @see SimpleAnnotationValueVisitor7
* @see SimpleAnnotationValueVisitor8
* @see SimpleAnnotationValueVisitor9
+ * @see SimpleAnnotationValueVisitor14
* @since 1.6
*/
@SupportedSourceVersion(RELEASE_6)
diff -r 5573a7098439 src/java.compiler/share/classes/javax/lang/model/util/SimpleAnnotationValueVisitor7.java
--- a/src/java.compiler/share/classes/javax/lang/model/util/SimpleAnnotationValueVisitor7.java Sat Nov 02 10:02:18 2019 +0000
+++ b/src/java.compiler/share/classes/javax/lang/model/util/SimpleAnnotationValueVisitor7.java Tue Nov 19 07:52:45 2019 -0500
@@ -64,6 +64,7 @@
* @see SimpleAnnotationValueVisitor6
* @see SimpleAnnotationValueVisitor8
* @see SimpleAnnotationValueVisitor9
+ * @see SimpleAnnotationValueVisitor14
* @since 1.7
*/
@SupportedSourceVersion(RELEASE_7)
diff -r 5573a7098439 src/java.compiler/share/classes/javax/lang/model/util/SimpleAnnotationValueVisitor8.java
--- a/src/java.compiler/share/classes/javax/lang/model/util/SimpleAnnotationValueVisitor8.java Sat Nov 02 10:02:18 2019 +0000
+++ b/src/java.compiler/share/classes/javax/lang/model/util/SimpleAnnotationValueVisitor8.java Tue Nov 19 07:52:45 2019 -0500
@@ -64,6 +64,7 @@
* @see SimpleAnnotationValueVisitor6
* @see SimpleAnnotationValueVisitor7
* @see SimpleAnnotationValueVisitor8
+ * @see SimpleAnnotationValueVisitor14
* @since 1.8
*/
@SupportedSourceVersion(RELEASE_8)
diff -r 5573a7098439 src/java.compiler/share/classes/javax/lang/model/util/SimpleAnnotationValueVisitor9.java
--- a/src/java.compiler/share/classes/javax/lang/model/util/SimpleAnnotationValueVisitor9.java Sat Nov 02 10:02:18 2019 +0000
+++ b/src/java.compiler/share/classes/javax/lang/model/util/SimpleAnnotationValueVisitor9.java Tue Nov 19 07:52:45 2019 -0500
@@ -66,6 +66,7 @@
* @see SimpleAnnotationValueVisitor6
* @see SimpleAnnotationValueVisitor7
* @see SimpleAnnotationValueVisitor8
+ * @see SimpleAnnotationValueVisitor14
* @since 9
*/
@SupportedSourceVersion(RELEASE_14)
diff -r 5573a7098439 src/java.compiler/share/classes/javax/lang/model/util/SimpleElementVisitor14.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/java.compiler/share/classes/javax/lang/model/util/SimpleElementVisitor14.java Tue Nov 19 07:52:45 2019 -0500
@@ -0,0 +1,120 @@
+package javax.lang.model.util;
+
+import javax.annotation.processing.SupportedSourceVersion;
+import javax.lang.model.SourceVersion;
+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.
+ *
+ * Visit methods corresponding to {@code RELEASE_14} and earlier
+ * language constructs call {@link #defaultAction defaultAction},
+ * passing their arguments to {@code defaultAction}'s corresponding
+ * parameters.
+ *
+ * <p> Methods in this class may be overridden subject to their
+ * general contract. Note that annotating methods in concrete
+ * subclasses with {@link java.lang.Override @Override} will help
+ * ensure that methods are overridden as intended.
+ *
+ * <p> <b>WARNING:</b> The {@code ElementVisitor} interface
+ * implemented by this class may have methods added to it in the
+ * future to accommodate new, currently unknown, language structures
+ * added to future versions of the Java™ programming language.
+ * Therefore, methods whose names begin with {@code "visit"} may be
+ * added to this class in the future; to avoid incompatibilities,
+ * classes which extend this class should not declare any instance
+ * methods with names beginning with {@code "visit"}.
+ *
+ * <p>When such a new visit method is added, the default
+ * implementation in this class will be to call the {@link
+ * #visitUnknown visitUnknown} method. A new simple element visitor
+ * class will also be introduced to correspond to the new language
+ * level; this visitor will have different default behavior for the
+ * visit method in question. When the new visitor is introduced, all
+ * or portions of this visitor may be deprecated.
+ *
+ * @param <R> the return type of this visitor's methods. Use {@code Void}
+ * for visitors that do not need to return results.
+ * @param <P> the type of the additional parameter to this visitor's methods. Use {@code Void}
+ * for visitors that do not need an additional parameter.
+ *
+ * @see SimpleElementVisitor6
+ * @see SimpleElementVisitor7
+ * @see SimpleElementVisitor8
+ * @see SimpleElementVisitor9
+ * @since 14
+ */
+@jdk.internal.PreviewFeature(feature=jdk.internal.PreviewFeature.Feature.RECORDS,
+ essentialAPI=false)
+@SupportedSourceVersion(RELEASE_14)
+public class SimpleElementVisitor14<R, P> extends SimpleElementVisitor9<R, P> {
+ /**
+ * Constructor for concrete subclasses; uses {@code null} for the
+ * default value.
+ */
+ protected SimpleElementVisitor14(){
+ }
+
+ /**
+ * Constructor for concrete subclasses; uses the argument for the
+ * default value.
+ *
+ * @param defaultValue the value to assign to {@link #DEFAULT_VALUE}
+ */
+ protected SimpleElementVisitor14(R defaultValue){
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @implSpec Visits a {@code RecordComponentElement} by calling {@code
+ * defaultAction}.
+ *
+ * @param e the element to visit
+ * @param p a visitor-specified parameter
+ * @return {@inheritDoc}
+ */
+ @SuppressWarnings("preview")
+ @Override
+ public R visitRecordComponent(RecordComponentElement e, P p) {
+ }
+}
diff -r 5573a7098439 src/java.compiler/share/classes/javax/lang/model/util/SimpleElementVisitor6.java
--- a/src/java.compiler/share/classes/javax/lang/model/util/SimpleElementVisitor6.java Sat Nov 02 10:02:18 2019 +0000
+++ b/src/java.compiler/share/classes/javax/lang/model/util/SimpleElementVisitor6.java Tue Nov 19 07:52:45 2019 -0500
@@ -77,6 +77,7 @@
* @see SimpleElementVisitor7
* @see SimpleElementVisitor8
* @see SimpleElementVisitor9
+ * @see SimpleElementVisitor14
* @since 1.6
*/
@SupportedSourceVersion(RELEASE_6)
diff -r 5573a7098439 src/java.compiler/share/classes/javax/lang/model/util/SimpleElementVisitor7.java
--- a/src/java.compiler/share/classes/javax/lang/model/util/SimpleElementVisitor7.java Sat Nov 02 10:02:18 2019 +0000
+++ b/src/java.compiler/share/classes/javax/lang/model/util/SimpleElementVisitor7.java Tue Nov 19 07:52:45 2019 -0500
@@ -70,6 +70,7 @@
* @see SimpleElementVisitor6
* @see SimpleElementVisitor8
* @see SimpleElementVisitor9
+ * @see SimpleElementVisitor14
* @since 1.7
*/
@SupportedSourceVersion(RELEASE_7)
diff -r 5573a7098439 src/java.compiler/share/classes/javax/lang/model/util/SimpleElementVisitor8.java
--- a/src/java.compiler/share/classes/javax/lang/model/util/SimpleElementVisitor8.java Sat Nov 02 10:02:18 2019 +0000
+++ b/src/java.compiler/share/classes/javax/lang/model/util/SimpleElementVisitor8.java Tue Nov 19 07:52:45 2019 -0500
@@ -69,6 +69,7 @@
* @see SimpleElementVisitor6
* @see SimpleElementVisitor7
* @see SimpleElementVisitor9
+ * @see SimpleElementVisitor14
* @since 1.8
*/
@SupportedSourceVersion(RELEASE_8)
diff -r 5573a7098439 src/java.compiler/share/classes/javax/lang/model/util/SimpleElementVisitor9.java
--- a/src/java.compiler/share/classes/javax/lang/model/util/SimpleElementVisitor9.java Sat Nov 02 10:02:18 2019 +0000
+++ b/src/java.compiler/share/classes/javax/lang/model/util/SimpleElementVisitor9.java Tue Nov 19 07:52:45 2019 -0500
@@ -70,6 +70,7 @@
* @see SimpleElementVisitor6
* @see SimpleElementVisitor7
* @see SimpleElementVisitor8
+ * @see SimpleElementVisitor14
* @since 9
* @spec JPMS
*/
diff -r 5573a7098439 src/java.compiler/share/classes/javax/lang/model/util/SimpleTypeVisitor14.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/java.compiler/share/classes/javax/lang/model/util/SimpleTypeVisitor14.java Tue Nov 19 07:52:45 2019 -0500
@@ -0,0 +1,94 @@
+package javax.lang.model.util;
+
+import javax.annotation.processing.SupportedSourceVersion;
+import javax.lang.model.SourceVersion;
+import static javax.lang.model.SourceVersion.*;
+
+/**
+ * A simple visitor of types with default behavior appropriate for
+ * source version {@link SourceVersion#RELEASE_14 RELEASE_14}.
+ *
+ * Visit methods corresponding to {@code RELEASE_14} and earlier
+ * language constructs call {@link #defaultAction defaultAction},
+ * passing their arguments to {@code defaultAction}'s corresponding
+ * parameters.
+ *
+ * <p> Methods in this class may be overridden subject to their
+ * general contract. Note that annotating methods in concrete
+ * subclasses with {@link java.lang.Override @Override} will help
+ * ensure that methods are overridden as intended.
+ *
+ * <p> <b>WARNING:</b> The {@code TypeVisitor} interface implemented
+ * by this class may have methods added to it in the future to
+ * accommodate new, currently unknown, language structures added to
+ * future versions of the Java™ programming language.
+ * Therefore, methods whose names begin with {@code "visit"} may be
+ * added to this class in the future; to avoid incompatibilities,
+ * classes which extend this class should not declare any instance
+ * methods with names beginning with {@code "visit"}.
+ *
+ * <p>When such a new visit method is added, the default
+ * implementation in this class will be to call the {@link
+ * #visitUnknown visitUnknown} method. A new simple type visitor
+ * class will also be introduced to correspond to the new language
+ * level; this visitor will have different default behavior for the
+ * visit method in question. When the new visitor is introduced, all
+ * or portions of this visitor may be deprecated.
+ *
+ * @param <R> the return type of this visitor's methods. Use {@link
+ * Void} for visitors that do not need to return results.
+ * @param <P> the type of the additional parameter to this visitor's
+ * methods. Use {@code Void} for visitors that do not need an
+ * additional parameter.
+ *
+ * @see SimpleTypeVisitor6
+ * @see SimpleTypeVisitor7
+ * @see SimpleTypeVisitor8
+ * @see SimpleTypeVisitor9
+ * @since 14
+ */
+@SupportedSourceVersion(RELEASE_14)
+public class SimpleTypeVisitor14<R, P> extends SimpleTypeVisitor9<R, P> {
+ /**
+ * Constructor for concrete subclasses; uses {@code null} for the
+ * default value.
+ */
+ protected SimpleTypeVisitor14(){
+ }
+
+ /**
+ * Constructor for concrete subclasses; uses the argument for the
+ * default value.
+ *
+ * @param defaultValue the value to assign to {@link #DEFAULT_VALUE}
+ */
+ protected SimpleTypeVisitor14(R defaultValue){
+ }
+}
diff -r 5573a7098439 src/java.compiler/share/classes/javax/lang/model/util/SimpleTypeVisitor6.java
--- a/src/java.compiler/share/classes/javax/lang/model/util/SimpleTypeVisitor6.java Sat Nov 02 10:02:18 2019 +0000
+++ b/src/java.compiler/share/classes/javax/lang/model/util/SimpleTypeVisitor6.java Tue Nov 19 07:52:45 2019 -0500
@@ -77,6 +77,7 @@
* @see SimpleTypeVisitor7
* @see SimpleTypeVisitor8
* @see SimpleTypeVisitor9
+ * @see SimpleTypeVisitor14
* @since 1.6
*/
@SupportedSourceVersion(RELEASE_6)
diff -r 5573a7098439 src/java.compiler/share/classes/javax/lang/model/util/SimpleTypeVisitor7.java
--- a/src/java.compiler/share/classes/javax/lang/model/util/SimpleTypeVisitor7.java Sat Nov 02 10:02:18 2019 +0000
+++ b/src/java.compiler/share/classes/javax/lang/model/util/SimpleTypeVisitor7.java Tue Nov 19 07:52:45 2019 -0500
@@ -70,6 +70,7 @@
* @see SimpleTypeVisitor6
* @see SimpleTypeVisitor8
* @see SimpleTypeVisitor9
+ * @see SimpleTypeVisitor14
* @since 1.7
*/
@SupportedSourceVersion(RELEASE_7)
diff -r 5573a7098439 src/java.compiler/share/classes/javax/lang/model/util/SimpleTypeVisitor8.java
--- a/src/java.compiler/share/classes/javax/lang/model/util/SimpleTypeVisitor8.java Sat Nov 02 10:02:18 2019 +0000
+++ b/src/java.compiler/share/classes/javax/lang/model/util/SimpleTypeVisitor8.java Tue Nov 19 07:52:45 2019 -0500
@@ -70,6 +70,7 @@
* @see SimpleTypeVisitor6
* @see SimpleTypeVisitor7
* @see SimpleTypeVisitor9
+ * @see SimpleTypeVisitor14
* @since 1.8
*/
@SupportedSourceVersion(RELEASE_8)
diff -r 5573a7098439 src/java.compiler/share/classes/javax/lang/model/util/SimpleTypeVisitor9.java
--- a/src/java.compiler/share/classes/javax/lang/model/util/SimpleTypeVisitor9.java Sat Nov 02 10:02:18 2019 +0000
+++ b/src/java.compiler/share/classes/javax/lang/model/util/SimpleTypeVisitor9.java Tue Nov 19 07:52:45 2019 -0500
@@ -71,6 +71,7 @@
* @see SimpleTypeVisitor6
* @see SimpleTypeVisitor7
* @see SimpleTypeVisitor8
+ * @see SimpleTypeVisitor14
* @since 9
*/
@SupportedSourceVersion(RELEASE_14)
diff -r 5573a7098439 src/java.compiler/share/classes/javax/lang/model/util/TypeKindVisitor14.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/java.compiler/share/classes/javax/lang/model/util/TypeKindVisitor14.java Tue Nov 19 07:52:45 2019 -0500
@@ -0,0 +1,99 @@
+package javax.lang.model.util;
+
+import javax.annotation.processing.SupportedSourceVersion;
+import javax.lang.model.SourceVersion;
+import javax.lang.model.type.*;
+import static javax.lang.model.SourceVersion.*;
+
+/**
+ * A visitor of types based on their {@linkplain TypeKind kind} with
+ * default behavior appropriate for source version {@link
+ * SourceVersion#RELEASE_14 RELEASE_14}.
+ *
+ * For {@linkplain
+ * TypeMirror types} <code><i>Xyz</i></code> that may have more than one
+ * kind, the <code>visit<i>Xyz</i></code> methods in this class delegate
+ * to the <code>visit<i>Xyz</i>As<i>Kind</i></code> method corresponding to the
+ * first argument's kind. The <code>visit<i>Xyz</i>As<i>Kind</i></code> methods
+ * call {@link #defaultAction defaultAction}, passing their arguments
+ * to {@code defaultAction}'s corresponding parameters.
+ *
+ * <p> Methods in this class may be overridden subject to their
+ * general contract. Note that annotating methods in concrete
+ * subclasses with {@link java.lang.Override @Override} will help
+ * ensure that methods are overridden as intended.
+ *
+ * <p> <b>WARNING:</b> The {@code TypeVisitor} interface implemented
+ * by this class may have methods added to it in the future to
+ * accommodate new, currently unknown, language structures added to
+ * future versions of the Java™ programming language.
+ * Therefore, methods whose names begin with {@code "visit"} may be
+ * added to this class in the future; to avoid incompatibilities,
+ * classes which extend this class should not declare any instance
+ * methods with names beginning with {@code "visit"}.
+ *
+ * <p>When such a new visit method is added, the default
+ * implementation in this class will be to call the {@link
+ * #visitUnknown visitUnknown} method. A new type kind visitor class
+ * will also be introduced to correspond to the new language level;
+ * this visitor will have different default behavior for the visit
+ * method in question. When the new visitor is introduced, all or
+ * portions of this visitor may be deprecated.
+ *
+ * @param <R> the return type of this visitor's methods. Use {@link
+ * Void} for visitors that do not need to return results.
+ * @param <P> the type of the additional parameter to this visitor's
+ * methods. Use {@code Void} for visitors that do not need an
+ * additional parameter.
+ *
+ * @see TypeKindVisitor6
+ * @see TypeKindVisitor7
+ * @see TypeKindVisitor8
+ * @see TypeKindVisitor9
+ * @since 14
+ */
+@SupportedSourceVersion(RELEASE_14)
+public class TypeKindVisitor14<R, P> extends TypeKindVisitor9<R, P> {
+ /**
+ * Constructor for concrete subclasses to call; uses {@code null}
+ * for the default value.
+ */
+ protected TypeKindVisitor14() {
+ }
+
+ /**
+ * Constructor for concrete subclasses to call; uses the argument
+ * for the default value.
+ *
+ * @param defaultValue the value to assign to {@link #DEFAULT_VALUE}
+ */
+ protected TypeKindVisitor14(R defaultValue) {
+ }
+}
diff -r 5573a7098439 src/java.compiler/share/classes/javax/lang/model/util/TypeKindVisitor6.java
--- a/src/java.compiler/share/classes/javax/lang/model/util/TypeKindVisitor6.java Sat Nov 02 10:02:18 2019 +0000
+++ b/src/java.compiler/share/classes/javax/lang/model/util/TypeKindVisitor6.java Tue Nov 19 07:52:45 2019 -0500
@@ -75,6 +75,8 @@
*
* @see TypeKindVisitor7
* @see TypeKindVisitor8
+ * @see TypeKindVisitor9
+ * @see TypeKindVisitor14
* @since 1.6
*/
@SupportedSourceVersion(RELEASE_6)
diff -r 5573a7098439 src/java.compiler/share/classes/javax/lang/model/util/TypeKindVisitor7.java
--- a/src/java.compiler/share/classes/javax/lang/model/util/TypeKindVisitor7.java Sat Nov 02 10:02:18 2019 +0000
+++ b/src/java.compiler/share/classes/javax/lang/model/util/TypeKindVisitor7.java Tue Nov 19 07:52:45 2019 -0500
@@ -71,6 +71,8 @@
*
* @see TypeKindVisitor6
* @see TypeKindVisitor8
+ * @see TypeKindVisitor9
+ * @see TypeKindVisitor14
* @since 1.7
*/
@SupportedSourceVersion(RELEASE_7)
diff -r 5573a7098439 src/java.compiler/share/classes/javax/lang/model/util/TypeKindVisitor8.java
--- a/src/java.compiler/share/classes/javax/lang/model/util/TypeKindVisitor8.java Sat Nov 02 10:02:18 2019 +0000
+++ b/src/java.compiler/share/classes/javax/lang/model/util/TypeKindVisitor8.java Tue Nov 19 07:52:45 2019 -0500
@@ -71,6 +71,8 @@
*
* @see TypeKindVisitor6
* @see TypeKindVisitor7
+ * @see TypeKindVisitor9
+ * @see TypeKindVisitor14
* @since 1.8
*/
@SupportedSourceVersion(RELEASE_8)
diff -r 5573a7098439 src/java.compiler/share/classes/javax/lang/model/util/TypeKindVisitor9.java
--- a/src/java.compiler/share/classes/javax/lang/model/util/TypeKindVisitor9.java Sat Nov 02 10:02:18 2019 +0000
+++ b/src/java.compiler/share/classes/javax/lang/model/util/TypeKindVisitor9.java Tue Nov 19 07:52:45 2019 -0500
@@ -75,6 +75,7 @@
* @see TypeKindVisitor6
* @see TypeKindVisitor7
* @see TypeKindVisitor8
+ * @see TypeKindVisitor14
* @since 9
*/
@SupportedSourceVersion(RELEASE_14)
diff -r 5573a7098439 src/java.compiler/share/classes/javax/annotation/processing/RoundEnvironment.java
--- a/src/java.compiler/share/classes/javax/annotation/processing/RoundEnvironment.java Sat Nov 02 10:02:18 2019 +0000
+++ b/src/java.compiler/share/classes/javax/annotation/processing/RoundEnvironment.java Tue Nov 19 07:52:47 2019 -0500
@@ -78,8 +78,8 @@
* The annotation may appear directly or be inherited. Only
* package elements, module elements, and type elements <i>included</i> in this
* round of annotation processing, or declarations of members,
- * constructors, parameters, or type parameters declared within
- * those, are returned. Included type elements are {@linkplain
+ * constructors, parameters, type parameters, or record components
+ * declared within those, are returned. Included type elements are {@linkplain
* #getRootElements root types} and any member types nested within
* them. Elements of a package are not considered included simply
* because a {@code package-info} file for that package was
@@ -133,8 +133,8 @@
* The annotation may appear directly or be inherited. Only
* package elements, module elements, and type elements <i>included</i> in this
* round of annotation processing, or declarations of members,
- * constructors, parameters, or type parameters declared within
- * those, are returned. Included type elements are {@linkplain
+ * constructors, parameters, type parameters, or record components
+ * declared within those, are returned. Included type elements are {@linkplain
* #getRootElements root types} and any member types nested within
* them. Elements in a package are not considered included simply
* because a {@code package-info} file for that package was
Additional links
-------
* javadoc: http://cr.openjdk.java.net/~vromero/records.review/CSRs/javax.lang.model/javadoc.03/java.compiler/module-summary.html
* specdiff: http://cr.openjdk.java.net/~vromero/records.review/CSRs/javax.lang.model/specdiff.03/java.compiler/module-summary.html