8255009: delta apply fixes for JDK-8246774 and JDK-8253455, pushed too soon

Reviewed-by: jlahoda
This commit is contained in:
Vicente Romero 2020-10-19 15:55:54 +00:00
parent a0382cd17c
commit 1da28de82f
121 changed files with 923 additions and 312 deletions

View file

@ -3567,6 +3567,12 @@ bool ClassFileParser::supports_sealed_types() {
Arguments::enable_preview(); Arguments::enable_preview();
} }
bool ClassFileParser::supports_records() {
return _major_version == JVM_CLASSFILE_MAJOR_VERSION &&
_minor_version == JAVA_PREVIEW_MINOR_VERSION &&
Arguments::enable_preview();
}
void ClassFileParser::parse_classfile_attributes(const ClassFileStream* const cfs, void ClassFileParser::parse_classfile_attributes(const ClassFileStream* const cfs,
ConstantPool* cp, ConstantPool* cp,
ClassFileParser::ClassAnnotationCollector* parsed_annotations, ClassFileParser::ClassAnnotationCollector* parsed_annotations,
@ -3814,28 +3820,12 @@ void ClassFileParser::parse_classfile_attributes(const ClassFileStream* const cf
"Nest-host class_info_index %u has bad constant type in class file %s", "Nest-host class_info_index %u has bad constant type in class file %s",
class_info_index, CHECK); class_info_index, CHECK);
_nest_host = class_info_index; _nest_host = class_info_index;
} else if (_major_version >= JAVA_14_VERSION) {
} else if (_major_version >= JAVA_15_VERSION) {
// Check for PermittedSubclasses tag
if (tag == vmSymbols::tag_permitted_subclasses()) {
if (supports_sealed_types()) {
if (parsed_permitted_subclasses_attribute) {
classfile_parse_error("Multiple PermittedSubclasses attributes in class file %s", CHECK);
}
// Classes marked ACC_FINAL cannot have a PermittedSubclasses attribute.
if (_access_flags.is_final()) {
classfile_parse_error("PermittedSubclasses attribute in final class file %s", CHECK);
}
parsed_permitted_subclasses_attribute = true;
permitted_subclasses_attribute_start = cfs->current();
permitted_subclasses_attribute_length = attribute_length;
}
cfs->skip_u1(attribute_length, CHECK);
} else if (_major_version >= JAVA_16_VERSION) {
if (tag == vmSymbols::tag_record()) { if (tag == vmSymbols::tag_record()) {
// Skip over Record attribute if super class is not java.lang.Record. // Skip over Record attribute if not supported or if super class is
if (cp->klass_name_at(_super_class_index) == vmSymbols::java_lang_Record()) { // not java.lang.Record.
if (supports_records() &&
cp->klass_name_at(_super_class_index) == vmSymbols::java_lang_Record()) {
if (parsed_record_attribute) { if (parsed_record_attribute) {
classfile_parse_error("Multiple Record attributes in class file %s", THREAD); classfile_parse_error("Multiple Record attributes in class file %s", THREAD);
return; return;
@ -3849,13 +3839,44 @@ void ClassFileParser::parse_classfile_attributes(const ClassFileStream* const cf
record_attribute_start = cfs->current(); record_attribute_start = cfs->current();
record_attribute_length = attribute_length; record_attribute_length = attribute_length;
} else if (log_is_enabled(Info, class, record)) { } else if (log_is_enabled(Info, class, record)) {
// Log why the Record attribute was ignored. Note that if the
// class file version is JVM_CLASSFILE_MAJOR_VERSION.65535 and
// --enable-preview wasn't specified then a java.lang.UnsupportedClassVersionError
// exception would have been thrown.
ResourceMark rm(THREAD); ResourceMark rm(THREAD);
if (supports_records()) {
log_info(class, record)( log_info(class, record)(
"Ignoring Record attribute in class %s because super type is not java.lang.Record", "Ignoring Record attribute in class %s because super type is not java.lang.Record",
_class_name->as_C_string()); _class_name->as_C_string());
} else {
log_info(class, record)(
"Ignoring Record attribute in class %s because class file version is not %d.65535",
_class_name->as_C_string(), JVM_CLASSFILE_MAJOR_VERSION);
} }
} }
cfs->skip_u1(attribute_length, CHECK); cfs->skip_u1(attribute_length, CHECK);
} else if (_major_version >= JAVA_15_VERSION) {
// Check for PermittedSubclasses tag
if (tag == vmSymbols::tag_permitted_subclasses()) {
if (supports_sealed_types()) {
if (parsed_permitted_subclasses_attribute) {
classfile_parse_error("Multiple PermittedSubclasses attributes in class file %s", THREAD);
return;
}
// Classes marked ACC_FINAL cannot have a PermittedSubclasses attribute.
if (_access_flags.is_final()) {
classfile_parse_error("PermittedSubclasses attribute in final class file %s", THREAD);
return;
}
parsed_permitted_subclasses_attribute = true;
permitted_subclasses_attribute_start = cfs->current();
permitted_subclasses_attribute_length = attribute_length;
}
cfs->skip_u1(attribute_length, CHECK);
} else {
// Unknown attribute
cfs->skip_u1(attribute_length, CHECK);
}
} else { } else {
// Unknown attribute // Unknown attribute
cfs->skip_u1(attribute_length, CHECK); cfs->skip_u1(attribute_length, CHECK);

View file

@ -2342,6 +2342,13 @@ public final class Class<T> implements java.io.Serializable,
} }
/** /**
* {@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 an array of {@code RecordComponent} objects representing all the * Returns an array of {@code RecordComponent} objects representing all the
* record components of this record class, or {@code null} if this class is * record components of this record class, or {@code null} if this class is
* not a record class. * not a record class.
@ -2378,8 +2385,11 @@ public final class Class<T> implements java.io.Serializable,
* </ul> * </ul>
* *
* @jls 8.10 Record Types * @jls 8.10 Record Types
* @since 16 * @since 14
*/ */
@jdk.internal.PreviewFeature(feature=jdk.internal.PreviewFeature.Feature.RECORDS,
essentialAPI=false)
@SuppressWarnings("preview")
@CallerSensitive @CallerSensitive
public RecordComponent[] getRecordComponents() { public RecordComponent[] getRecordComponents() {
SecurityManager sm = System.getSecurityManager(); SecurityManager sm = System.getSecurityManager();
@ -3678,6 +3688,13 @@ public final class Class<T> implements java.io.Serializable,
} }
/** /**
* {@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 {@code true} if and only if this class is a record class. * Returns {@code true} if and only if this class is a record class.
* *
* <p> The {@linkplain #getSuperclass() direct superclass} of a record * <p> The {@linkplain #getSuperclass() direct superclass} of a record
@ -3690,8 +3707,10 @@ public final class Class<T> implements java.io.Serializable,
* *
* @return true if and only if this class is a record class, otherwise false * @return true if and only if this class is a record class, otherwise false
* @jls 8.10 Record Types * @jls 8.10 Record Types
* @since 16 * @since 14
*/ */
@jdk.internal.PreviewFeature(feature=jdk.internal.PreviewFeature.Feature.RECORDS,
essentialAPI=false)
public boolean isRecord() { public boolean isRecord() {
return getSuperclass() == JAVA_LANG_RECORD_CLASS && isRecord0(); return getSuperclass() == JAVA_LANG_RECORD_CLASS && isRecord0();
} }

View file

@ -25,6 +25,14 @@
package java.lang; package java.lang;
/** /**
* {@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. Programs can only use this
* class when preview features are enabled. Preview features
* may be removed in a future release, or upgraded to permanent
* features of the Java language.}
*
* This is the common base class of all Java language record classes. * This is the common base class of all Java language record classes.
* *
* <p>More information about records, including descriptions of the * <p>More information about records, including descriptions of the
@ -78,8 +86,10 @@ package java.lang;
* <a href="{@docRoot}/java.base/java/io/ObjectInputStream.html#record-serialization">record serialization</a>. * <a href="{@docRoot}/java.base/java/io/ObjectInputStream.html#record-serialization">record serialization</a>.
* *
* @jls 8.10 Record Types * @jls 8.10 Record Types
* @since 16 * @since 14
*/ */
@jdk.internal.PreviewFeature(feature=jdk.internal.PreviewFeature.Feature.RECORDS,
essentialAPI=true)
public abstract class Record { public abstract class Record {
/** /**
* Constructor for record classes to call. * Constructor for record classes to call.

View file

@ -118,12 +118,22 @@ public enum ElementType {
MODULE, MODULE,
/** /**
* {@preview Associated with records, a preview feature of the Java language.
*
* This constant is associated with <i>records</i>, a preview
* feature of the Java language. Programs can only use this
* constant when preview features are enabled. Preview features
* may be removed in a future release, or upgraded to permanent
* features of the Java language.}
*
* Record component * Record component
* *
* @jls 8.10.3 Record Members * @jls 8.10.3 Record Members
* @jls 9.7.4 Where Annotations May Appear * @jls 9.7.4 Where Annotations May Appear
* *
* @since 16 * @since 14
*/ */
@jdk.internal.PreviewFeature(feature=jdk.internal.PreviewFeature.Feature.RECORDS,
essentialAPI=true)
RECORD_COMPONENT; RECORD_COMPONENT;
} }

View file

@ -38,14 +38,23 @@ import java.util.Map;
import java.util.Objects; import java.util.Objects;
/** /**
* {@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 {@code RecordComponent} provides information about, and dynamic access to, a * A {@code RecordComponent} provides information about, and dynamic access to, a
* component of a record class. * component of a record class.
* *
* @see Class#getRecordComponents() * @see Class#getRecordComponents()
* @see java.lang.Record * @see java.lang.Record
* @jls 8.10 Record Types * @jls 8.10 Record Types
* @since 16 * @since 14
*/ */
@jdk.internal.PreviewFeature(feature=jdk.internal.PreviewFeature.Feature.RECORDS,
essentialAPI=false)
public final class RecordComponent implements AnnotatedElement { public final class RecordComponent implements AnnotatedElement {
// declaring class // declaring class
private Class<?> clazz; private Class<?> clazz;

View file

@ -38,14 +38,23 @@ import java.util.List;
import java.util.Objects; import java.util.Objects;
/** /**
* {@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.}
*
* Bootstrap methods for state-driven implementations of core methods, * Bootstrap methods for state-driven implementations of core methods,
* including {@link Object#equals(Object)}, {@link Object#hashCode()}, and * including {@link Object#equals(Object)}, {@link Object#hashCode()}, and
* {@link Object#toString()}. These methods may be used, for example, by * {@link Object#toString()}. These methods may be used, for example, by
* Java compiler implementations to implement the bodies of {@link Object} * Java compiler implementations to implement the bodies of {@link Object}
* methods for record classes. * methods for record classes.
* *
* @since 16 * @since 14
*/ */
@jdk.internal.PreviewFeature(feature=jdk.internal.PreviewFeature.Feature.RECORDS,
essentialAPI=false)
public class ObjectMethods { public class ObjectMethods {
private ObjectMethods() { } private ObjectMethods() { }

View file

@ -62,11 +62,6 @@ public @interface PreviewFeature {
// JDK 15. Since the JDK 14 codebase uses the enum constant, it is // JDK 15. Since the JDK 14 codebase uses the enum constant, it is
// necessary for PreviewFeature in JDK 15 to declare the enum constant. // necessary for PreviewFeature in JDK 15 to declare the enum constant.
TEXT_BLOCKS, 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, RECORDS,
SEALED_CLASSES, SEALED_CLASSES,
; ;

View file

@ -92,8 +92,16 @@ public final class TypeAnnotation {
METHOD_FORMAL_PARAMETER, METHOD_FORMAL_PARAMETER,
THROWS, THROWS,
/** /**
* @since 16 * {@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.}
* @since 14
*/ */
@jdk.internal.PreviewFeature(feature=jdk.internal.PreviewFeature.Feature.RECORDS,
essentialAPI=false)
RECORD_COMPONENT; RECORD_COMPONENT;
} }

View file

@ -110,15 +110,33 @@ public enum ElementKind {
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. * A record type.
* @since 16 * @since 14
*/ */
@jdk.internal.PreviewFeature(feature=jdk.internal.PreviewFeature.Feature.RECORDS,
essentialAPI=false)
RECORD, 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}. * A record component of a {@code record}.
* @since 16 * @since 14
*/ */
@jdk.internal.PreviewFeature(feature=jdk.internal.PreviewFeature.Feature.RECORDS,
essentialAPI=false)
RECORD_COMPONENT, RECORD_COMPONENT,
/** /**

View file

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

View file

@ -26,10 +26,19 @@
package javax.lang.model.element; 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. * Represents a record component.
* *
* @since 16 * @since 14
*/ */
@jdk.internal.PreviewFeature(feature=jdk.internal.PreviewFeature.Feature.RECORDS,
essentialAPI=false)
public interface RecordComponentElement extends Element { public interface RecordComponentElement extends Element {
/** /**
* Returns the enclosing element of this record component. * Returns the enclosing element of this record component.

View file

@ -180,6 +180,13 @@ public interface TypeElement extends Element, Parameterizable, QualifiedNameable
List<? extends TypeParameterElement> getTypeParameters(); 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 * Returns the record components of this type element in
* declaration order. * declaration order.
* *
@ -189,8 +196,11 @@ public interface TypeElement extends Element, Parameterizable, QualifiedNameable
* @return the record components, or an empty list if there are * @return the record components, or an empty list if there are
* none * none
* *
* @since 16 * @since 14
*/ */
@jdk.internal.PreviewFeature(feature=jdk.internal.PreviewFeature.Feature.RECORDS,
essentialAPI=false)
@SuppressWarnings("preview")
default List<? extends RecordComponentElement> getRecordComponents() { default List<? extends RecordComponentElement> getRecordComponents() {
return List.of(); return List.of();
} }

View file

@ -31,6 +31,13 @@ import javax.lang.model.element.RecordComponentElement;
import static 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 skeletal visitor of program elements with default behavior * A skeletal visitor of program elements with default behavior
* appropriate for the {@link SourceVersion#RELEASE_14 RELEASE_14} * appropriate for the {@link SourceVersion#RELEASE_14 RELEASE_14}
* source version. * source version.
@ -47,8 +54,10 @@ import static javax.lang.model.SourceVersion.*;
* @see AbstractElementVisitor7 * @see AbstractElementVisitor7
* @see AbstractElementVisitor8 * @see AbstractElementVisitor8
* @see AbstractElementVisitor9 * @see AbstractElementVisitor9
* @since 16 * @since 14
*/ */
@jdk.internal.PreviewFeature(feature=jdk.internal.PreviewFeature.Feature.RECORDS,
essentialAPI=false)
@SupportedSourceVersion(RELEASE_16) @SupportedSourceVersion(RELEASE_16)
public abstract class AbstractElementVisitor14<R, P> extends AbstractElementVisitor9<R, P> { public abstract class AbstractElementVisitor14<R, P> extends AbstractElementVisitor9<R, P> {
/** /**
@ -68,6 +77,7 @@ public abstract class AbstractElementVisitor14<R, P> extends AbstractElementVisi
* @param p {@inheritDoc} * @param p {@inheritDoc}
* @return {@inheritDoc} * @return {@inheritDoc}
*/ */
@SuppressWarnings("preview")
@Override @Override
public abstract R visitRecordComponent(RecordComponentElement t, P p); public abstract R visitRecordComponent(RecordComponentElement t, P p);
} }

View file

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

View file

@ -31,6 +31,13 @@ import static javax.lang.model.SourceVersion.*;
import 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 * A visitor of program elements based on their {@linkplain
* ElementKind kind} with default behavior appropriate for the {@link * ElementKind kind} with default behavior appropriate for the {@link
* SourceVersion#RELEASE_14 RELEASE_14} source version. * SourceVersion#RELEASE_14 RELEASE_14} source version.
@ -59,8 +66,10 @@ import javax.lang.model.SourceVersion;
* @see ElementKindVisitor7 * @see ElementKindVisitor7
* @see ElementKindVisitor8 * @see ElementKindVisitor8
* @see ElementKindVisitor9 * @see ElementKindVisitor9
* @since 16 * @since 14
*/ */
@jdk.internal.PreviewFeature(feature=jdk.internal.PreviewFeature.Feature.RECORDS,
essentialAPI=false)
@SupportedSourceVersion(RELEASE_16) @SupportedSourceVersion(RELEASE_16)
public class ElementKindVisitor14<R, P> extends ElementKindVisitor9<R, P> { public class ElementKindVisitor14<R, P> extends ElementKindVisitor9<R, P> {
/** /**
@ -90,6 +99,7 @@ public class ElementKindVisitor14<R, P> extends ElementKindVisitor9<R, P> {
* @param p a visitor-specified parameter * @param p a visitor-specified parameter
* @return the result of {@code defaultAction} * @return the result of {@code defaultAction}
*/ */
@SuppressWarnings("preview")
@Override @Override
public R visitRecordComponent(RecordComponentElement e, P p) { public R visitRecordComponent(RecordComponentElement e, P p) {
return defaultAction(e, p); return defaultAction(e, p);

View file

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

View file

@ -33,6 +33,13 @@ import javax.lang.model.SourceVersion;
import static 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 * A scanning visitor of program elements with default behavior
* appropriate for the {@link SourceVersion#RELEASE_14 RELEASE_14} * appropriate for the {@link SourceVersion#RELEASE_14 RELEASE_14}
* source version. * source version.
@ -74,8 +81,10 @@ import static javax.lang.model.SourceVersion.*;
* @see ElementScanner7 * @see ElementScanner7
* @see ElementScanner8 * @see ElementScanner8
* @see ElementScanner9 * @see ElementScanner9
* @since 16 * @since 14
*/ */
@jdk.internal.PreviewFeature(feature=jdk.internal.PreviewFeature.Feature.RECORDS,
essentialAPI=false)
@SupportedSourceVersion(RELEASE_16) @SupportedSourceVersion(RELEASE_16)
public class ElementScanner14<R, P> extends ElementScanner9<R, P> { public class ElementScanner14<R, P> extends ElementScanner9<R, P> {
/** /**
@ -147,6 +156,7 @@ public class ElementScanner14<R, P> extends ElementScanner9<R, P> {
* @param p a visitor-specified parameter * @param p a visitor-specified parameter
* @return the result of the scan * @return the result of the scan
*/ */
@SuppressWarnings("preview")
@Override @Override
public R visitRecordComponent(RecordComponentElement e, P p) { public R visitRecordComponent(RecordComponentElement e, P p) {
return scan(e.getEnclosedElements(), p); return scan(e.getEnclosedElements(), p);

View file

@ -634,6 +634,13 @@ public interface Elements {
boolean isFunctionalInterface(TypeElement type); 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 * Returns the record component for the given accessor. Returns null if the
* given method is not a record component accessor. * given method is not a record component accessor.
* *
@ -648,8 +655,11 @@ public interface Elements {
* @param accessor the method for which the record component should be found. * @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 * @return the record component, or null if the given method is not an record
* component accessor * component accessor
* @since 16 * @since 14
*/ */
@jdk.internal.PreviewFeature(feature=jdk.internal.PreviewFeature.Feature.RECORDS,
essentialAPI=false)
@SuppressWarnings("preview")
default RecordComponentElement recordComponentFor(ExecutableElement accessor) { default RecordComponentElement recordComponentFor(ExecutableElement accessor) {
if (accessor.getEnclosingElement().getKind() == ElementKind.RECORD) { if (accessor.getEnclosingElement().getKind() == ElementKind.RECORD) {
for (RecordComponentElement rec : ElementFilter.recordComponentsIn(accessor.getEnclosingElement().getEnclosedElements())) { for (RecordComponentElement rec : ElementFilter.recordComponentsIn(accessor.getEnclosingElement().getEnclosedElements())) {

View file

@ -31,6 +31,13 @@ import javax.lang.model.element.RecordComponentElement;
import static 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 simple visitor of program elements with default behavior * A simple visitor of program elements with default behavior
* appropriate for the {@link SourceVersion#RELEASE_14 RELEASE_14} * appropriate for the {@link SourceVersion#RELEASE_14 RELEASE_14}
* source version. * source version.
@ -55,8 +62,10 @@ import static javax.lang.model.SourceVersion.*;
* @see SimpleElementVisitor7 * @see SimpleElementVisitor7
* @see SimpleElementVisitor8 * @see SimpleElementVisitor8
* @see SimpleElementVisitor9 * @see SimpleElementVisitor9
* @since 16 * @since 14
*/ */
@jdk.internal.PreviewFeature(feature=jdk.internal.PreviewFeature.Feature.RECORDS,
essentialAPI=false)
@SupportedSourceVersion(RELEASE_16) @SupportedSourceVersion(RELEASE_16)
public class SimpleElementVisitor14<R, P> extends SimpleElementVisitor9<R, P> { public class SimpleElementVisitor14<R, P> extends SimpleElementVisitor9<R, P> {
/** /**
@ -87,6 +96,7 @@ public class SimpleElementVisitor14<R, P> extends SimpleElementVisitor9<R, P> {
* @param p a visitor-specified parameter * @param p a visitor-specified parameter
* @return {@inheritDoc} * @return {@inheritDoc}
*/ */
@SuppressWarnings("preview")
@Override @Override
public R visitRecordComponent(RecordComponentElement e, P p) { public R visitRecordComponent(RecordComponentElement e, P p) {
return defaultAction(e, p); return defaultAction(e, p);

View file

@ -649,9 +649,19 @@ public interface Tree {
PROVIDES(ProvidesTree.class), PROVIDES(ProvidesTree.class),
/** /**
* {@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.}
*
* Used for instances of {@link ClassTree} representing records. * Used for instances of {@link ClassTree} representing records.
* @since 16 *
* @since 14
*/ */
@jdk.internal.PreviewFeature(feature=jdk.internal.PreviewFeature.Feature.RECORDS,
essentialAPI=false)
RECORD(ClassTree.class), RECORD(ClassTree.class),
/** /**

View file

@ -167,6 +167,7 @@ public class Preview {
public boolean isPreview(Feature feature) { public boolean isPreview(Feature feature) {
if (feature == Feature.PATTERN_MATCHING_IN_INSTANCEOF || if (feature == Feature.PATTERN_MATCHING_IN_INSTANCEOF ||
feature == Feature.REIFIABLE_TYPES_INSTANCEOF || feature == Feature.REIFIABLE_TYPES_INSTANCEOF ||
feature == Feature.RECORDS ||
feature == Feature.SEALED_CLASSES) feature == Feature.SEALED_CLASSES)
return true; return true;
//Note: this is a backdoor which allows to optionally treat all features as 'preview' (for testing). //Note: this is a backdoor which allows to optionally treat all features as 'preview' (for testing).

View file

@ -159,7 +159,8 @@ public class Check {
deferredLintHandler = DeferredLintHandler.instance(context); deferredLintHandler = DeferredLintHandler.instance(context);
allowRecords = Feature.RECORDS.allowedInSource(source); allowRecords = (!preview.isPreview(Feature.RECORDS) || preview.isEnabled()) &&
Feature.RECORDS.allowedInSource(source);
allowSealed = (!preview.isPreview(Feature.SEALED_CLASSES) || preview.isEnabled()) && allowSealed = (!preview.isPreview(Feature.SEALED_CLASSES) || preview.isEnabled()) &&
Feature.SEALED_CLASSES.allowedInSource(source); Feature.SEALED_CLASSES.allowedInSource(source);
} }

View file

@ -150,7 +150,8 @@ public class Resolve {
Feature.POST_APPLICABILITY_VARARGS_ACCESS_CHECK.allowedInSource(source); Feature.POST_APPLICABILITY_VARARGS_ACCESS_CHECK.allowedInSource(source);
polymorphicSignatureScope = WriteableScope.create(syms.noSymbol); polymorphicSignatureScope = WriteableScope.create(syms.noSymbol);
allowModules = Feature.MODULES.allowedInSource(source); allowModules = Feature.MODULES.allowedInSource(source);
allowRecords = Feature.RECORDS.allowedInSource(source); allowRecords = (!preview.isPreview(Feature.RECORDS) || preview.isEnabled()) &&
Feature.RECORDS.allowedInSource(source);
} }
/** error symbols, which are returned when resolution fails /** error symbols, which are returned when resolution fails

View file

@ -272,7 +272,8 @@ public class ClassReader {
Source source = Source.instance(context); Source source = Source.instance(context);
preview = Preview.instance(context); preview = Preview.instance(context);
allowModules = Feature.MODULES.allowedInSource(source); allowModules = Feature.MODULES.allowedInSource(source);
allowRecords = Feature.RECORDS.allowedInSource(source); allowRecords = (!preview.isPreview(Feature.RECORDS) || preview.isEnabled()) &&
Feature.RECORDS.allowedInSource(source);
allowSealedTypes = (!preview.isPreview(Feature.SEALED_CLASSES) || preview.isEnabled()) && allowSealedTypes = (!preview.isPreview(Feature.SEALED_CLASSES) || preview.isEnabled()) &&
Feature.SEALED_CLASSES.allowedInSource(source); Feature.SEALED_CLASSES.allowedInSource(source);

View file

@ -184,7 +184,8 @@ public class JavacParser implements Parser {
endPosTable = newEndPosTable(keepEndPositions); endPosTable = newEndPosTable(keepEndPositions);
this.allowYieldStatement = (!preview.isPreview(Feature.SWITCH_EXPRESSION) || preview.isEnabled()) && this.allowYieldStatement = (!preview.isPreview(Feature.SWITCH_EXPRESSION) || preview.isEnabled()) &&
Feature.SWITCH_EXPRESSION.allowedInSource(source); Feature.SWITCH_EXPRESSION.allowedInSource(source);
this.allowRecords = Feature.RECORDS.allowedInSource(source); this.allowRecords = (!preview.isPreview(Feature.RECORDS) || preview.isEnabled()) &&
Feature.RECORDS.allowedInSource(source);
this.allowSealedTypes = (!preview.isPreview(Feature.SEALED_CLASSES) || preview.isEnabled()) && this.allowSealedTypes = (!preview.isPreview(Feature.SEALED_CLASSES) || preview.isEnabled()) &&
Feature.SEALED_CLASSES.allowedInSource(source); Feature.SEALED_CLASSES.allowedInSource(source);
} }
@ -3716,7 +3717,7 @@ public class JavacParser implements Parser {
} else { } else {
int pos = token.pos; int pos = token.pos;
List<JCTree> errs; List<JCTree> errs;
if (token.kind == IDENTIFIER && token.name() == names.record) { if (token.kind == IDENTIFIER && token.name() == names.record && preview.isEnabled()) {
checkSourceLevel(Feature.RECORDS); checkSourceLevel(Feature.RECORDS);
JCErroneous erroneousTree = syntaxError(token.pos, List.of(mods), Errors.RecordHeaderExpected); JCErroneous erroneousTree = syntaxError(token.pos, List.of(mods), Errors.RecordHeaderExpected);
return toP(F.Exec(erroneousTree)); return toP(F.Exec(erroneousTree));

View file

@ -23,15 +23,15 @@
/* /*
* @test * @test
* @bug 8246774
* @library /test/lib * @library /test/lib
* @summary Test that a class that is a record can be redefined. * @summary Test that a class that is a record can be redefined.
* @modules java.base/jdk.internal.misc * @modules java.base/jdk.internal.misc
* @modules java.instrument * @modules java.instrument
* jdk.jartool/sun.tools.jar * jdk.jartool/sun.tools.jar
* @requires vm.jvmti * @requires vm.jvmti
* @run main RedefineRecord buildagent * @compile --enable-preview -source ${jdk.version} RedefineRecord.java
* @run main/othervm/timeout=6000 RedefineRecord runtest * @run main/othervm --enable-preview RedefineRecord buildagent
* @run main/othervm/timeout=6000 --enable-preview RedefineRecord runtest
*/ */
import java.io.FileNotFoundException; import java.io.FileNotFoundException;
@ -100,6 +100,7 @@ public class RedefineRecord {
"-XX:MetaspaceSize=12m", "-XX:MetaspaceSize=12m",
"-XX:MaxMetaspaceSize=12m", "-XX:MaxMetaspaceSize=12m",
"-javaagent:redefineagent.jar", "-javaagent:redefineagent.jar",
"--enable-preview",
"RedefineRecord"); "RedefineRecord");
OutputAnalyzer output = new OutputAnalyzer(pb.start()); OutputAnalyzer output = new OutputAnalyzer(pb.start());
output.shouldNotContain("processing of -javaagent failed"); output.shouldNotContain("processing of -javaagent failed");

View file

@ -28,7 +28,7 @@
// ClassFormatError exception. // ClassFormatError exception.
class abstractRecord { class abstractRecord {
0xCAFEBABE; 0xCAFEBABE;
0; // minor version 65535; // minor version
60; // version 60; // version
[69] { // Constant Pool [69] { // Constant Pool
; // first element is empty ; // first element is empty

View file

@ -28,7 +28,7 @@
// Utf8. It should result in a ClassFormatError exception. // Utf8. It should result in a ClassFormatError exception.
class badRecordAttribute { class badRecordAttribute {
0xCAFEBABE; 0xCAFEBABE;
0; // minor version 65535; // minor version
60; // version 60; // version
[69] { // Constant Pool [69] { // Constant Pool
; // first element is empty ; // first element is empty

View file

@ -23,10 +23,9 @@
/* /*
* @test * @test
* @bug 8246774
* @summary test logging of reasons for ignoring Record attribute * @summary test logging of reasons for ignoring Record attribute
* @library /test/lib * @library /test/lib
* @compile superNotJLRecord.jcod * @compile superNotJLRecord.jcod recordIgnoredVersion.jcod
* @run driver ignoreRecordAttribute * @run driver ignoreRecordAttribute
*/ */
@ -37,11 +36,17 @@ public class ignoreRecordAttribute {
public static void main(String[] args) throws Exception { public static void main(String[] args) throws Exception {
String MAJOR_VERSION = Integer.toString(44 + Runtime.version().feature()); String MAJOR_VERSION = Integer.toString(44 + Runtime.version().feature());
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("--enable-preview",
"-Xlog:class+record", "-Xshare:off", "superNotJLRecord"); "-Xlog:class+record", "-Xshare:off", "superNotJLRecord");
OutputAnalyzer output = new OutputAnalyzer(pb.start()); OutputAnalyzer output = new OutputAnalyzer(pb.start());
output.shouldContain("Ignoring Record attribute"); output.shouldContain("Ignoring Record attribute");
output.shouldContain("because super type is not java.lang.Record"); output.shouldContain("because super type is not java.lang.Record");
pb = ProcessTools.createJavaProcessBuilder("--enable-preview",
"-Xlog:class+record", "-Xshare:off", "recordIgnoredVersion");
output = new OutputAnalyzer(pb.start());
output.shouldContain("Ignoring Record attribute");
output.shouldContain("because class file version is not " + MAJOR_VERSION + ".65535");
} }
} }

View file

@ -28,7 +28,7 @@
// ClassFormatError exception. // ClassFormatError exception.
class notFinalRecord { class notFinalRecord {
0xCAFEBABE; 0xCAFEBABE;
0; // minor version 65535; // minor version
60; // version 60; // version
[69] { // Constant Pool [69] { // Constant Pool
; // first element is empty ; // first element is empty

View file

@ -23,10 +23,10 @@
/* /*
* @test * @test
* @bug 8246774
* @compile abstractRecord.jcod notFinalRecord.jcod oldRecordAttribute.jcod superNotJLRecord.jcod * @compile abstractRecord.jcod notFinalRecord.jcod oldRecordAttribute.jcod superNotJLRecord.jcod
* @compile shortRecordAttribute.jcod twoRecordAttributes.jcod badRecordAttribute.jcod * @compile shortRecordAttribute.jcod twoRecordAttributes.jcod badRecordAttribute.jcod
* @run main recordAttributeTest *
* @run main/othervm --enable-preview recordAttributeTest
*/ */
@ -37,7 +37,7 @@ public class recordAttributeTest {
public static void runTest(String className, String cfeMessage) { public static void runTest(String className, String cfeMessage) {
try { try {
Class newClass = Class.forName(className); Class newClass = Class.forName(className);
throw new RuntimeException("Expected ClassFormatError exception not thrown"); throw new RuntimeException("Expected ClasFormatError exception not thrown");
} catch (java.lang.ClassFormatError e) { } catch (java.lang.ClassFormatError e) {
String eMsg = e.getMessage(); String eMsg = e.getMessage();
if (!eMsg.contains(cfeMessage)) { if (!eMsg.contains(cfeMessage)) {

View file

@ -0,0 +1,256 @@
/*
* Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
// Record attribute is ignored because class file minor version is 0.
class recordIgnoredVersion {
0xCAFEBABE;
0; // minor version
60; // version
[52] { // Constant Pool
; // first element is empty
Method #2 #3; // #1 at 0x0A
class #4; // #2 at 0x0F
NameAndType #5 #6; // #3 at 0x12
Utf8 "java/lang/Record"; // #4 at 0x17
Utf8 "<init>"; // #5 at 0x2A
Utf8 "()V"; // #6 at 0x33
Field #8 #9; // #7 at 0x39
class #10; // #8 at 0x3E
NameAndType #11 #12; // #9 at 0x41
Utf8 "recordIgnoredVersion"; // #10 at 0x46
Utf8 "x"; // #11 at 0x56
Utf8 "I"; // #12 at 0x5A
Field #8 #9; // #13 at 0x5E
InvokeDynamic 0s #15; // #14 at 0x63
NameAndType #16 #17; // #15 at 0x68
Utf8 "toString"; // #16 at 0x6D
Utf8 "(LrecordIgnoredVersion;)Ljava/lang/String;"; // #17 at 0x78
InvokeDynamic 0s #19; // #18 at 0x9E
NameAndType #20 #21; // #19 at 0xA3
Utf8 "hashCode"; // #20 at 0xA8
Utf8 "(LrecordIgnoredVersion;)I"; // #21 at 0xB3
InvokeDynamic 0s #23; // #22 at 0xC8
NameAndType #24 #25; // #23 at 0xCD
Utf8 "equals"; // #24 at 0xD2
Utf8 "(LrecordIgnoredVersion;Ljava/lang/Object;)Z"; // #25 at 0xDB
Utf8 "(I)V"; // #26 at 0x0102
Utf8 "Code"; // #27 at 0x0109
Utf8 "LineNumberTable"; // #28 at 0x0110
Utf8 "MethodParameters"; // #29 at 0x0122
Utf8 "()Ljava/lang/String;"; // #30 at 0x0135
Utf8 "()I"; // #31 at 0x014C
Utf8 "(Ljava/lang/Object;)Z"; // #32 at 0x0152
Utf8 "SourceFile"; // #33 at 0x016A
Utf8 "recordIgnoredVersion.java"; // #34 at 0x0177
Utf8 "Record"; // #35 at 0x018C
Utf8 "BootstrapMethods"; // #36 at 0x0195
MethodHandle 6b #38; // #37 at 0x01A8
Method #39 #40; // #38 at 0x01AC
class #41; // #39 at 0x01B1
NameAndType #42 #43; // #40 at 0x01B4
Utf8 "java/lang/runtime/ObjectMethods"; // #41 at 0x01B9
Utf8 "bootstrap"; // #42 at 0x01DB
Utf8 "(Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/invoke/TypeDescriptor;Ljava/lang/Class;Ljava/lang/String;[Ljava/lang/invoke/MethodHandle;)Ljava/lang/Object;"; // #43 at 0x01E7
String #11; // #44 at 0x029B
MethodHandle 1b #7; // #45 at 0x029E
Utf8 "InnerClasses"; // #46 at 0x02A2
class #48; // #47 at 0x02B1
Utf8 "java/lang/invoke/MethodHandles$Lookup"; // #48 at 0x02B4
class #50; // #49 at 0x02DC
Utf8 "java/lang/invoke/MethodHandles"; // #50 at 0x02DF
Utf8 "Lookup"; // #51 at 0x0300
} // Constant Pool
0x0030; // access [ ACC_SUPER ACC_FINAL ]
#8;// this_cpx
#2;// super_cpx
[0] { // Interfaces
} // Interfaces
[1] { // fields
{ // Member at 0x0313
0x8012; // access
#11; // name_cpx
#12; // sig_cpx
[0] { // Attributes
} // Attributes
} // Member
} // fields
[5] { // methods
{ // Member at 0x031D
0x0001; // access
#5; // name_cpx
#26; // sig_cpx
[2] { // Attributes
Attr(#27, 34) { // Code at 0x0325
2; // max_stack
2; // max_locals
Bytes[10]{
0x2AB700012A1BB500;
0x07B1;
}
[0] { // Traps
} // end Traps
[1] { // Attributes
Attr(#28, 6) { // LineNumberTable at 0x0341
[1] { // LineNumberTable
0 1; // at 0x034D
}
} // end LineNumberTable
} // Attributes
} // end Code
;
Attr(#29, 5) { // MethodParameters at 0x034D
0x01000B8000;
} // end MethodParameters
} // Attributes
} // Member
;
{ // Member at 0x0358
0x8001; // access
#16; // name_cpx
#30; // sig_cpx
[1] { // Attributes
Attr(#27, 31) { // Code at 0x0360
1; // max_stack
1; // max_locals
Bytes[7]{
0x2ABA000E0000B0;
}
[0] { // Traps
} // end Traps
[1] { // Attributes
Attr(#28, 6) { // LineNumberTable at 0x0379
[1] { // LineNumberTable
0 1; // at 0x0385
}
} // end LineNumberTable
} // Attributes
} // end Code
} // Attributes
} // Member
;
{ // Member at 0x0385
0x8011; // access
#20; // name_cpx
#31; // sig_cpx
[1] { // Attributes
Attr(#27, 31) { // Code at 0x038D
1; // max_stack
1; // max_locals
Bytes[7]{
0x2ABA00120000AC;
}
[0] { // Traps
} // end Traps
[1] { // Attributes
Attr(#28, 6) { // LineNumberTable at 0x03A6
[1] { // LineNumberTable
0 1; // at 0x03B2
}
} // end LineNumberTable
} // Attributes
} // end Code
} // Attributes
} // Member
;
{ // Member at 0x03B2
0x8011; // access
#24; // name_cpx
#32; // sig_cpx
[1] { // Attributes
Attr(#27, 32) { // Code at 0x03BA
2; // max_stack
2; // max_locals
Bytes[8]{
0x2A2BBA00160000AC;
}
[0] { // Traps
} // end Traps
[1] { // Attributes
Attr(#28, 6) { // LineNumberTable at 0x03D4
[1] { // LineNumberTable
0 1; // at 0x03E0
}
} // end LineNumberTable
} // Attributes
} // end Code
} // Attributes
} // Member
;
{ // Member at 0x03E0
0x8001; // access
#11; // name_cpx
#31; // sig_cpx
[1] { // Attributes
Attr(#27, 29) { // Code at 0x03E8
1; // max_stack
1; // max_locals
Bytes[5]{
0x2AB4000DAC;
}
[0] { // Traps
} // end Traps
[1] { // Attributes
Attr(#28, 6) { // LineNumberTable at 0x03FF
[1] { // LineNumberTable
0 1; // at 0x040B
}
} // end LineNumberTable
} // Attributes
} // end Code
} // Attributes
} // Member
} // methods
[4] { // Attributes
Attr(#33, 2) { // SourceFile at 0x040D
#34;
} // end SourceFile
;
Attr(#35, 8) { // Record at 0x0415
0x0001000B000C0000;
} // end Record
;
Attr(#36, 12) { // BootstrapMethods at 0x0423
[1] { // bootstrap_methods
{ // bootstrap_method
#37; // bootstrap_method_ref
[3] { // bootstrap_arguments
#8; // at 0x0431
#44; // at 0x0433
#45; // at 0x0435
} // bootstrap_arguments
} // bootstrap_method
}
} // end BootstrapMethods
;
Attr(#46, 10) { // InnerClasses at 0x0435
[1] { // InnerClasses
#47 #49 #51 25; // at 0x0445
}
} // end InnerClasses
} // Attributes
} // end class recordIgnoredVersion

View file

@ -23,8 +23,8 @@
/* /*
* @test * @test
* @bug 8246774 * @compile --enable-preview --source ${jdk.version} recordReflectionTest.java
* @summary testing reflection APIs for record classes * @run main/othervm --enable-preview recordReflectionTest
*/ */

View file

@ -28,7 +28,7 @@
// attribute_count field. It should result in a ClassFormatError exception. // attribute_count field. It should result in a ClassFormatError exception.
class shortRecordAttribute { class shortRecordAttribute {
0xCAFEBABE; 0xCAFEBABE;
0; // minor version 65535; // minor version
60; // version 60; // version
[69] { // Constant Pool [69] { // Constant Pool
; // first element is empty ; // first element is empty

View file

@ -28,7 +28,7 @@
// not java.lang.Record. So, the bogus Record attribute should be ignored. // not java.lang.Record. So, the bogus Record attribute should be ignored.
class superNotJLRecord { class superNotJLRecord {
0xCAFEBABE; 0xCAFEBABE;
0; // minor version 65535; // minor version
60; // version 60; // version
[69] { // Constant Pool [69] { // Constant Pool
; // first element is empty ; // first element is empty

View file

@ -28,7 +28,7 @@
// a ClassFormatError exception. // a ClassFormatError exception.
class twoRecordAttributes { class twoRecordAttributes {
0xCAFEBABE; 0xCAFEBABE;
0; // minor version 65535; // minor version
60; // version 60; // version
[69] { // Constant Pool [69] { // Constant Pool
; // first element is empty ; // first element is empty

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2019, 2020, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -23,10 +23,10 @@
/* /*
* @test * @test
* @bug 8246774
* @summary Checks that the appropriate default value is given to the canonical ctr * @summary Checks that the appropriate default value is given to the canonical ctr
* @run testng AbsentStreamValuesTest * @compile --enable-preview -source ${jdk.version} AbsentStreamValuesTest.java
* @run testng/othervm/java.security.policy=empty_security.policy AbsentStreamValuesTest * @run testng/othervm --enable-preview AbsentStreamValuesTest
* @run testng/othervm/java.security.policy=empty_security.policy --enable-preview AbsentStreamValuesTest
*/ */
import java.io.ByteArrayInputStream; import java.io.ByteArrayInputStream;

View file

@ -23,12 +23,12 @@
/* /*
* @test * @test
* @bug 8246774
* @summary InvalidClassException is thrown when the canonical constructor * @summary InvalidClassException is thrown when the canonical constructor
* cannot be found during deserialization. * cannot be found during deserialization.
* @library /test/lib * @library /test/lib
* @modules java.base/jdk.internal.org.objectweb.asm * @modules java.base/jdk.internal.org.objectweb.asm
* @run testng BadCanonicalCtrTest * @compile --enable-preview -source ${jdk.version} BadCanonicalCtrTest.java
* @run testng/othervm --enable-preview BadCanonicalCtrTest
*/ */
import java.io.ByteArrayInputStream; import java.io.ByteArrayInputStream;
@ -59,6 +59,7 @@ import static org.testng.Assert.expectThrows;
* constructor cannot be found during deserialization. * constructor cannot be found during deserialization.
*/ */
public class BadCanonicalCtrTest { public class BadCanonicalCtrTest {
private static final String VERSION = Integer.toString(Runtime.version().feature());
// ClassLoader for creating instances of the records to test with. // ClassLoader for creating instances of the records to test with.
ClassLoader goodRecordClassLoader; ClassLoader goodRecordClassLoader;
@ -78,7 +79,8 @@ public class BadCanonicalCtrTest {
public void setup() { public void setup() {
{ {
byte[] byteCode = InMemoryJavaCompiler.compile("R1", byte[] byteCode = InMemoryJavaCompiler.compile("R1",
"public record R1 () implements java.io.Serializable { }"); "public record R1 () implements java.io.Serializable { }",
"--enable-preview", "-source", VERSION);
goodRecordClassLoader = new ByteCodeLoader("R1", byteCode, BadCanonicalCtrTest.class.getClassLoader()); goodRecordClassLoader = new ByteCodeLoader("R1", byteCode, BadCanonicalCtrTest.class.getClassLoader());
byte[] bc1 = removeConstructor(byteCode); byte[] bc1 = removeConstructor(byteCode);
missingCtrClassLoader = new ByteCodeLoader("R1", bc1, BadCanonicalCtrTest.class.getClassLoader()); missingCtrClassLoader = new ByteCodeLoader("R1", bc1, BadCanonicalCtrTest.class.getClassLoader());
@ -87,7 +89,8 @@ public class BadCanonicalCtrTest {
} }
{ {
byte[] byteCode = InMemoryJavaCompiler.compile("R2", byte[] byteCode = InMemoryJavaCompiler.compile("R2",
"public record R2 (int x, int y) implements java.io.Serializable { }"); "public record R2 (int x, int y) implements java.io.Serializable { }",
"--enable-preview", "-source", VERSION);
goodRecordClassLoader = new ByteCodeLoader("R2", byteCode, goodRecordClassLoader); goodRecordClassLoader = new ByteCodeLoader("R2", byteCode, goodRecordClassLoader);
byte[] bc1 = removeConstructor(byteCode); byte[] bc1 = removeConstructor(byteCode);
missingCtrClassLoader = new ByteCodeLoader("R2", bc1, missingCtrClassLoader); missingCtrClassLoader = new ByteCodeLoader("R2", bc1, missingCtrClassLoader);
@ -98,7 +101,8 @@ public class BadCanonicalCtrTest {
byte[] byteCode = InMemoryJavaCompiler.compile("R3", byte[] byteCode = InMemoryJavaCompiler.compile("R3",
"public record R3 (long l) implements java.io.Externalizable {" + "public record R3 (long l) implements java.io.Externalizable {" +
" public void writeExternal(java.io.ObjectOutput out) { }" + " public void writeExternal(java.io.ObjectOutput out) { }" +
" public void readExternal(java.io.ObjectInput in) { } }"); " public void readExternal(java.io.ObjectInput in) { } }",
"--enable-preview", "-source", VERSION);
goodRecordClassLoader = new ByteCodeLoader("R3", byteCode, goodRecordClassLoader); goodRecordClassLoader = new ByteCodeLoader("R3", byteCode, goodRecordClassLoader);
byte[] bc1 = removeConstructor(byteCode); byte[] bc1 = removeConstructor(byteCode);
missingCtrClassLoader = new ByteCodeLoader("R3", bc1, missingCtrClassLoader); missingCtrClassLoader = new ByteCodeLoader("R3", bc1, missingCtrClassLoader);

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2019, 2020, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -23,10 +23,10 @@
/* /*
* @test * @test
* @bug 8246774
* @summary Basic test that serializes and deserializes a number of records * @summary Basic test that serializes and deserializes a number of records
* @run testng BasicRecordSer * @compile --enable-preview -source ${jdk.version} BasicRecordSer.java
* @run testng/othervm/java.security.policy=empty_security.policy BasicRecordSer * @run testng/othervm --enable-preview BasicRecordSer
* @run testng/othervm/java.security.policy=empty_security.policy --enable-preview BasicRecordSer
*/ */
import java.io.ByteArrayInputStream; import java.io.ByteArrayInputStream;

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2019, 2020, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -23,11 +23,11 @@
/* /*
* @test * @test
* @bug 8246774
* @summary Ensures that the serialization implementation can *always* access * @summary Ensures that the serialization implementation can *always* access
* the record constructor * the record constructor
* @run testng ConstructorAccessTest * @compile --enable-preview -source ${jdk.version} ConstructorAccessTest.java
* @run testng/othervm/java.security.policy=empty_security.policy ConstructorAccessTest * @run testng/othervm --enable-preview ConstructorAccessTest
* @run testng/othervm/java.security.policy=empty_security.policy --enable-preview ConstructorAccessTest
*/ */
import java.io.ByteArrayInputStream; import java.io.ByteArrayInputStream;

View file

@ -23,10 +23,10 @@
/* /*
* @test * @test
* @bug 8246774
* @summary Verifies that privileged operations performed in the record * @summary Verifies that privileged operations performed in the record
* constructor throw, when run without the required permissions * constructor throw, when run without the required permissions
* @run testng/othervm/java.security.policy=empty_security.policy ConstructorPermissionTest * @compile --enable-preview -source ${jdk.version} ConstructorPermissionTest.java
* @run testng/othervm/java.security.policy=empty_security.policy --enable-preview ConstructorPermissionTest
*/ */
import java.io.ByteArrayInputStream; import java.io.ByteArrayInputStream;

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2019, 2020, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -23,10 +23,10 @@
/* /*
* @test * @test
* @bug 8246774
* @summary Ensures basic behavior of cycles from record components * @summary Ensures basic behavior of cycles from record components
* @run testng CycleTest * @compile --enable-preview -source ${jdk.version} CycleTest.java
* @run testng/othervm/java.security.policy=empty_security.policy CycleTest * @run testng/othervm --enable-preview CycleTest
* @run testng/othervm/java.security.policy=empty_security.policy --enable-preview CycleTest
*/ */
import java.io.ByteArrayInputStream; import java.io.ByteArrayInputStream;

View file

@ -23,11 +23,11 @@
/* /*
* @test * @test
* @bug 8246774
* @summary Checks that the appropriate value is given to the canonical ctr * @summary Checks that the appropriate value is given to the canonical ctr
* @library /test/lib * @library /test/lib
* @run testng DifferentStreamFieldsTest * @compile --enable-preview -source ${jdk.version} DifferentStreamFieldsTest.java
* @run testng/othervm/java.security.policy=empty_security.policy DifferentStreamFieldsTest * @run testng/othervm --enable-preview DifferentStreamFieldsTest
* @run testng/othervm/java.security.policy=empty_security.policy --enable-preview DifferentStreamFieldsTest
*/ */
import java.io.ByteArrayInputStream; import java.io.ByteArrayInputStream;

View file

@ -23,11 +23,11 @@
/* /*
* @test * @test
* @bug 8246774
* @summary Basic tests for prohibited magic serialization methods * @summary Basic tests for prohibited magic serialization methods
* @library /test/lib * @library /test/lib
* @modules java.base/jdk.internal.org.objectweb.asm * @modules java.base/jdk.internal.org.objectweb.asm
* @run testng ProhibitedMethods * @compile --enable-preview -source ${jdk.version} ProhibitedMethods.java
* @run testng/othervm --enable-preview ProhibitedMethods
*/ */
import java.io.ByteArrayInputStream; import java.io.ByteArrayInputStream;
@ -69,6 +69,7 @@ import static org.testng.Assert.fail;
* record objects. * record objects.
*/ */
public class ProhibitedMethods { public class ProhibitedMethods {
private static final String VERSION = Integer.toString(Runtime.version().feature());
public interface ThrowingExternalizable extends Externalizable { public interface ThrowingExternalizable extends Externalizable {
default void writeExternal(ObjectOutput out) { default void writeExternal(ObjectOutput out) {
@ -105,7 +106,8 @@ public class ProhibitedMethods {
public void setup() { public void setup() {
{ {
byte[] byteCode = InMemoryJavaCompiler.compile("Foo", byte[] byteCode = InMemoryJavaCompiler.compile("Foo",
"public record Foo () implements java.io.Serializable { }"); "public record Foo () implements java.io.Serializable { }",
"--enable-preview", "-source", VERSION);
byteCode = addWriteObject(byteCode); byteCode = addWriteObject(byteCode);
byteCode = addReadObject(byteCode); byteCode = addReadObject(byteCode);
byteCode = addReadObjectNoData(byteCode); byteCode = addReadObjectNoData(byteCode);
@ -113,7 +115,8 @@ public class ProhibitedMethods {
} }
{ {
byte[] byteCode = InMemoryJavaCompiler.compile("Bar", byte[] byteCode = InMemoryJavaCompiler.compile("Bar",
"public record Bar (int x, int y) implements java.io.Serializable { }"); "public record Bar (int x, int y) implements java.io.Serializable { }",
"--enable-preview", "-source", VERSION);
byteCode = addWriteObject(byteCode); byteCode = addWriteObject(byteCode);
byteCode = addReadObject(byteCode); byteCode = addReadObject(byteCode);
byteCode = addReadObjectNoData(byteCode); byteCode = addReadObjectNoData(byteCode);
@ -122,7 +125,8 @@ public class ProhibitedMethods {
{ {
byte[] byteCode = InMemoryJavaCompiler.compile("Baz", byte[] byteCode = InMemoryJavaCompiler.compile("Baz",
"import java.io.Serializable;" + "import java.io.Serializable;" +
"public record Baz<U extends Serializable,V extends Serializable>(U u, V v) implements Serializable { }"); "public record Baz<U extends Serializable,V extends Serializable>(U u, V v) implements Serializable { }",
"--enable-preview", "-source", VERSION);
byteCode = addWriteObject(byteCode); byteCode = addWriteObject(byteCode);
byteCode = addReadObject(byteCode); byteCode = addReadObject(byteCode);
byteCode = addReadObjectNoData(byteCode); byteCode = addReadObjectNoData(byteCode);

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2019, 2020, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -23,10 +23,10 @@
/* /*
* @test * @test
* @bug 8246774
* @summary Basic tests for readResolve * @summary Basic tests for readResolve
* @run testng ReadResolveTest * @compile --enable-preview -source ${jdk.version} ReadResolveTest.java
* @run testng/othervm/java.security.policy=empty_security.policy ReadResolveTest * @run testng/othervm --enable-preview ReadResolveTest
* @run testng/othervm/java.security.policy=empty_security.policy --enable-preview ReadResolveTest
*/ */
import java.io.ByteArrayInputStream; import java.io.ByteArrayInputStream;

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2019, 2020, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -23,10 +23,10 @@
/* /*
* @test * @test
* @bug 8246774
* @summary Basic tests for serializing and deserializing record classes * @summary Basic tests for serializing and deserializing record classes
* @run testng RecordClassTest * @compile --enable-preview -source ${jdk.version} RecordClassTest.java
* @run testng/othervm/java.security.policy=empty_security.policy RecordClassTest * @run testng/othervm --enable-preview RecordClassTest
* @run testng/othervm/java.security.policy=empty_security.policy --enable-preview RecordClassTest
*/ */
import java.io.ByteArrayInputStream; import java.io.ByteArrayInputStream;

View file

@ -23,11 +23,11 @@
/* /*
* @test * @test
* @bug 8246774
* @summary Basic tests for prohibited magic serialPersistentFields * @summary Basic tests for prohibited magic serialPersistentFields
* @library /test/lib * @library /test/lib
* @modules java.base/jdk.internal.org.objectweb.asm * @modules java.base/jdk.internal.org.objectweb.asm
* @run testng SerialPersistentFieldsTest * @compile --enable-preview -source ${jdk.version} SerialPersistentFieldsTest.java
* @run testng/othervm --enable-preview SerialPersistentFieldsTest
*/ */
import java.io.ByteArrayInputStream; import java.io.ByteArrayInputStream;
@ -62,6 +62,7 @@ import static org.testng.Assert.assertTrue;
* Checks that the serialPersistentFields declaration is effectively ignored. * Checks that the serialPersistentFields declaration is effectively ignored.
*/ */
public class SerialPersistentFieldsTest { public class SerialPersistentFieldsTest {
private static final String VERSION = Integer.toString(Runtime.version().feature());
ClassLoader serializableRecordLoader; ClassLoader serializableRecordLoader;
@ -82,7 +83,8 @@ public class SerialPersistentFieldsTest {
public void setup() { public void setup() {
{ // R1 { // R1
byte[] byteCode = InMemoryJavaCompiler.compile("R1", byte[] byteCode = InMemoryJavaCompiler.compile("R1",
"public record R1 () implements java.io.Serializable { }"); "public record R1 () implements java.io.Serializable { }",
"--enable-preview", "-source", VERSION);
ObjectStreamField[] serialPersistentFields = { ObjectStreamField[] serialPersistentFields = {
new ObjectStreamField("s", String.class), new ObjectStreamField("s", String.class),
new ObjectStreamField("i", int.class), new ObjectStreamField("i", int.class),
@ -94,7 +96,8 @@ public class SerialPersistentFieldsTest {
} }
{ // R2 { // R2
byte[] byteCode = InMemoryJavaCompiler.compile("R2", byte[] byteCode = InMemoryJavaCompiler.compile("R2",
"public record R2 (int x) implements java.io.Serializable { }"); "public record R2 (int x) implements java.io.Serializable { }",
"--enable-preview", "-source", VERSION);
ObjectStreamField[] serialPersistentFields = { ObjectStreamField[] serialPersistentFields = {
new ObjectStreamField("s", String.class) new ObjectStreamField("s", String.class)
}; };
@ -103,7 +106,8 @@ public class SerialPersistentFieldsTest {
} }
{ // R3 { // R3
byte[] byteCode = InMemoryJavaCompiler.compile("R3", byte[] byteCode = InMemoryJavaCompiler.compile("R3",
"public record R3 (int x, int y) implements java.io.Serializable { }"); "public record R3 (int x, int y) implements java.io.Serializable { }",
"--enable-preview", "-source", VERSION);
ObjectStreamField[] serialPersistentFields = new ObjectStreamField[0]; ObjectStreamField[] serialPersistentFields = new ObjectStreamField[0];
byteCode = addSerialPersistentFields(byteCode, serialPersistentFields); byteCode = addSerialPersistentFields(byteCode, serialPersistentFields);
serializableRecordLoader = new ByteCodeLoader("R3", byteCode, serializableRecordLoader); serializableRecordLoader = new ByteCodeLoader("R3", byteCode, serializableRecordLoader);
@ -111,7 +115,8 @@ public class SerialPersistentFieldsTest {
{ // R4 { // R4
byte[] byteCode = InMemoryJavaCompiler.compile("R4", byte[] byteCode = InMemoryJavaCompiler.compile("R4",
"import java.io.Serializable;" + "import java.io.Serializable;" +
"public record R4<U extends Serializable,V extends Serializable>(U u, V v) implements Serializable { }"); "public record R4<U extends Serializable,V extends Serializable>(U u, V v) implements Serializable { }",
"--enable-preview", "-source", VERSION);
ObjectStreamField[] serialPersistentFields = { ObjectStreamField[] serialPersistentFields = {
new ObjectStreamField("v", String.class) new ObjectStreamField("v", String.class)
}; };
@ -127,7 +132,8 @@ public class SerialPersistentFieldsTest {
" }\n" + " }\n" +
" @Override public void readExternal(ObjectInput in) {\n" + " @Override public void readExternal(ObjectInput in) {\n" +
" throw new AssertionError(\"should not reach here\");\n" + " throw new AssertionError(\"should not reach here\");\n" +
" } }"); " } }",
"--enable-preview", "-source", VERSION);
ObjectStreamField[] serialPersistentFields = { ObjectStreamField[] serialPersistentFields = {
new ObjectStreamField("v", String.class) new ObjectStreamField("v", String.class)
}; };

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2019, 2020, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -23,10 +23,10 @@
/* /*
* @test * @test
* @bug 8246774
* @summary Basic tests for SUID in the serial stream * @summary Basic tests for SUID in the serial stream
* @run testng SerialVersionUIDTest * @compile --enable-preview -source ${jdk.version} SerialVersionUIDTest.java
* @run testng/othervm/java.security.policy=empty_security.policy SerialVersionUIDTest * @run testng/othervm --enable-preview SerialVersionUIDTest
* @run testng/othervm/java.security.policy=empty_security.policy --enable-preview SerialVersionUIDTest
*/ */
import java.io.ByteArrayInputStream; import java.io.ByteArrayInputStream;

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2019, 2020, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -23,9 +23,9 @@
/* /*
* @test * @test
* @bug 8246774
* @summary Tests for stream references * @summary Tests for stream references
* @run testng StreamRefTest * @compile --enable-preview -source ${jdk.version} StreamRefTest.java
* @run testng/othervm --enable-preview StreamRefTest
*/ */
import java.io.ByteArrayInputStream; import java.io.ByteArrayInputStream;

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2019, 2020, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -23,10 +23,10 @@
/* /*
* @test * @test
* @bug 8246774
* @summary Tests constructor invocation exceptions are handled appropriately * @summary Tests constructor invocation exceptions are handled appropriately
* @run testng ThrowingConstructorTest * @compile --enable-preview -source ${jdk.version} ThrowingConstructorTest.java
* @run testng/othervm/java.security.policy=empty_security.policy ThrowingConstructorTest * @run testng/othervm --enable-preview ThrowingConstructorTest
* @run testng/othervm/java.security.policy=empty_security.policy --enable-preview ThrowingConstructorTest
*/ */
import java.io.ByteArrayInputStream; import java.io.ByteArrayInputStream;

View file

@ -23,9 +23,10 @@
/* /*
* @test * @test
* @bug 8238763 8246774 * @bug 8238763
* @summary ObjectInputStream readUnshared method handling of Records * @summary ObjectInputStream readUnshared method handling of Records
* @run testng UnsharedTest * @compile --enable-preview -source ${jdk.version} UnsharedTest.java
* @run testng/othervm --enable-preview UnsharedTest
*/ */
import java.io.ByteArrayInputStream; import java.io.ByteArrayInputStream;

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2019, 2020, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -23,10 +23,10 @@
/* /*
* @test * @test
* @bug 8246774
* @summary Basic tests for writeReplace * @summary Basic tests for writeReplace
* @run testng WriteReplaceTest * @compile --enable-preview -source ${jdk.version} WriteReplaceTest.java
* @run testng/othervm/java.security.policy=empty_security.policy WriteReplaceTest * @run testng/othervm --enable-preview WriteReplaceTest
* @run testng/othervm/java.security.policy=empty_security.policy --enable-preview WriteReplaceTest
*/ */
import java.io.ByteArrayInputStream; import java.io.ByteArrayInputStream;

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2019, 2020, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -44,6 +44,8 @@ import static org.testng.Assert.*;
*/ */
public class AbstractTest { public class AbstractTest {
private static final String VERSION = Integer.toString(Runtime.version().feature());
static final String TEST_SRC = System.getProperty("test.src", "."); static final String TEST_SRC = System.getProperty("test.src", ".");
static final String TEST_CLASSES = System.getProperty("test.classes", "."); static final String TEST_CLASSES = System.getProperty("test.classes", ".");
static final Path TEST_CLASSES_DIR = Path.of(TEST_CLASSES); static final Path TEST_CLASSES_DIR = Path.of(TEST_CLASSES);
@ -57,9 +59,11 @@ public class AbstractTest {
@BeforeTest @BeforeTest
public void setup() throws IOException { public void setup() throws IOException {
assertTrue(CompilerUtils.compile(PLAIN_SRC_DIR, PLAIN_DEST_DIR, assertTrue(CompilerUtils.compile(PLAIN_SRC_DIR, PLAIN_DEST_DIR,
"--enable-preview", "-source", VERSION,
"--class-path", TEST_CLASSES_DIR.toString())); "--class-path", TEST_CLASSES_DIR.toString()));
assertTrue(CompilerUtils.compile(RECORD_SRC_DIR, RECORD_DEST_DIR, assertTrue(CompilerUtils.compile(RECORD_SRC_DIR, RECORD_DEST_DIR,
"--enable-preview", "-source", VERSION,
"--class-path", TEST_CLASSES_DIR.toString())); "--class-path", TEST_CLASSES_DIR.toString()));
} }

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2019, 2020, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -23,13 +23,12 @@
/* /*
* @test * @test
* @bug 8246774
* @summary Test for subtype stream field value assign-ability * @summary Test for subtype stream field value assign-ability
* @library /test/lib * @library /test/lib
* @modules jdk.compiler * @modules jdk.compiler
* @compile AssignableFrom.java Point.java * @compile --enable-preview -source ${jdk.version} AssignableFrom.java Point.java
* DefaultValues.java SuperStreamFields.java * DefaultValues.java SuperStreamFields.java AssignableFromTest.java
* @run testng AssignableFromTest * @run testng/othervm --enable-preview AssignableFromTest
*/ */
import java.math.BigDecimal; import java.math.BigDecimal;

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2019, 2020, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -23,12 +23,12 @@
/* /*
* @test * @test
* @bug 8246774
* @summary Checks that the appropriate default value is given to the canonical ctr * @summary Checks that the appropriate default value is given to the canonical ctr
* @library /test/lib * @library /test/lib
* @modules jdk.compiler * @modules jdk.compiler
* @compile AssignableFrom.java Point.java DefaultValues.java SuperStreamFields.java * @compile --enable-preview -source ${jdk.version} AssignableFrom.java Point.java
* @run testng DefaultValuesTest * DefaultValues.java SuperStreamFields.java DefaultValuesTest.java
* @run testng/othervm --enable-preview DefaultValuesTest
*/ */
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2019, 2020, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -23,12 +23,12 @@
/* /*
* @test * @test
* @bug 8246774
* @summary superclass fields in the stream should be discarded * @summary superclass fields in the stream should be discarded
* @library /test/lib * @library /test/lib
* @modules jdk.compiler * @modules jdk.compiler
* @compile AssignableFrom.java Point.java DefaultValues.java SuperStreamFields.java * @compile --enable-preview -source ${jdk.version} AssignableFrom.java Point.java
* @run testng SuperStreamFieldsTest * DefaultValues.java SuperStreamFields.java SuperStreamFieldsTest.java
* @run testng/othervm --enable-preview SuperStreamFieldsTest
*/ */
import org.testng.annotations.DataProvider; import org.testng.annotations.DataProvider;

View file

@ -23,7 +23,6 @@
/* /*
* @test * @test
* @bug 8246774
* @summary Class redefinition must preclude changes to Record attributes * @summary Class redefinition must preclude changes to Record attributes
* @comment This is a copy of test/jdk/java/lang/instrument/RedefineNestmateAttr/ * @comment This is a copy of test/jdk/java/lang/instrument/RedefineNestmateAttr/
* @comment modified for records and the Record attribute. * @comment modified for records and the Record attribute.
@ -34,14 +33,15 @@
* java.instrument * java.instrument
* @compile ../NamedBuffer.java * @compile ../NamedBuffer.java
* @run main RedefineClassHelper * @run main RedefineClassHelper
* @compile Host/Host.java * @compile --enable-preview -source ${jdk.version} Host/Host.java
* @run main/othervm -javaagent:redefineagent.jar -Xlog:redefine+class+record=trace TestRecordAttr Host * @compile --enable-preview -source ${jdk.version} TestRecordAttr.java
* @compile HostA/Host.java * @run main/othervm -javaagent:redefineagent.jar --enable-preview -Xlog:redefine+class+record=trace TestRecordAttr Host
* @run main/othervm -javaagent:redefineagent.jar -Xlog:redefine+class+record=trace TestRecordAttr HostA * @compile --enable-preview -source ${jdk.version} HostA/Host.java
* @compile HostAB/Host.java * @run main/othervm -javaagent:redefineagent.jar --enable-preview -Xlog:redefine+class+record=trace TestRecordAttr HostA
* @run main/othervm -javaagent:redefineagent.jar -Xlog:redefine+class+record=trace TestRecordAttr HostAB * @compile --enable-preview -source ${jdk.version} HostAB/Host.java
* @compile HostABC/Host.java * @run main/othervm -javaagent:redefineagent.jar --enable-preview -Xlog:redefine+class+record=trace TestRecordAttr HostAB
* @run main/othervm -javaagent:redefineagent.jar -Xlog:redefine+class+record=trace TestRecordAttr HostABC * @compile --enable-preview -source ${jdk.version} HostABC/Host.java
* @run main/othervm -javaagent:redefineagent.jar --enable-preview -Xlog:redefine+class+record=trace TestRecordAttr HostABC
*/ */
/* Test Description /* Test Description
@ -269,6 +269,8 @@ public class TestRecordAttr {
" to: " + dst); " to: " + dst);
CompilerUtils.compile(src.toPath(), CompilerUtils.compile(src.toPath(),
dst.toPath(), dst.toPath(),
false /* don't recurse */); false /* don't recurse */,
"--enable-preview",
"--source", VERSION);
} }
} }

View file

@ -23,7 +23,6 @@
/* /*
* @test * @test
* @bug 8246774
* @summary Class redefinition must preclude changes to Record attributes * @summary Class redefinition must preclude changes to Record attributes
* @comment This is a copy of test/jdk/java/lang/instrument/RedefineNestmateAttr/ * @comment This is a copy of test/jdk/java/lang/instrument/RedefineNestmateAttr/
* @comment modified for records and the Record attribute. * @comment modified for records and the Record attribute.
@ -34,10 +33,11 @@
* java.instrument * java.instrument
* @compile ../NamedBuffer.java * @compile ../NamedBuffer.java
* @run main RedefineClassHelper * @run main RedefineClassHelper
* @compile Host/Host.java * @compile --enable-preview --source ${jdk.version} Host/Host.java
* @run main/othervm -javaagent:redefineagent.jar -Xlog:redefine+class+record=trace TestRecordAttrGenericSig Host * @compile --enable-preview --source ${jdk.version} TestRecordAttrGenericSig.java
* @compile HostA/Host.java * @run main/othervm -javaagent:redefineagent.jar -Xlog:redefine+class+record=trace --enable-preview TestRecordAttrGenericSig Host
* @run main/othervm -javaagent:redefineagent.jar -Xlog:redefine+class+record=trace TestRecordAttrGenericSig HostA * @compile --enable-preview --source ${jdk.version} HostA/Host.java
* @run main/othervm -javaagent:redefineagent.jar -Xlog:redefine+class+record=trace --enable-preview TestRecordAttrGenericSig HostA
*/ */
/* Test Description /* Test Description
@ -207,6 +207,8 @@ public class TestRecordAttrGenericSig {
" to: " + dst); " to: " + dst);
CompilerUtils.compile(src.toPath(), CompilerUtils.compile(src.toPath(),
dst.toPath(), dst.toPath(),
false /* don't recurse */); false /* don't recurse */,
"--enable-preview",
"--source", VERSION);
} }
} }

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2019, 2020, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -23,10 +23,10 @@
/* /*
* @test * @test
* @bug 8246774
* @summary Basic tests for ObjectMethods * @summary Basic tests for ObjectMethods
* @run testng ObjectMethodsTest * @compile --enable-preview -source ${jdk.version} ObjectMethodsTest.java
* @run testng/othervm/java.security.policy=empty.policy ObjectMethodsTest * @run testng/othervm --enable-preview ObjectMethodsTest
* @run testng/othervm/java.security.policy=empty.policy --enable-preview ObjectMethodsTest
*/ */
import java.lang.invoke.CallSite; import java.lang.invoke.CallSite;

View file

@ -23,11 +23,12 @@
/* /*
* @test * @test
* @bug 8236539 8246774 * @bug 8236539
* @summary Relative link tags in record javadoc don't resolve * @summary Relative link tags in record javadoc don't resolve
* @library /tools/lib ../../lib * @library /tools/lib ../../lib
* @modules jdk.javadoc/jdk.javadoc.internal.tool * @modules jdk.javadoc/jdk.javadoc.internal.tool
* @build toolbox.ToolBox javadoc.tester.* * @build toolbox.ToolBox javadoc.tester.*
* @compile TestRecordLinks.java
* @run main TestRecordLinks * @run main TestRecordLinks
*/ */
@ -73,6 +74,7 @@ public class TestRecordLinks extends JavadocTester {
javadoc("-d", base.resolve("out").toString(), javadoc("-d", base.resolve("out").toString(),
"-sourcepath", src.toString(), "-sourcepath", src.toString(),
"--enable-preview", "--source", thisRelease,
"example"); "example");
checkExit(Exit.OK); checkExit(Exit.OK);

View file

@ -23,12 +23,13 @@
/* /*
* @test * @test
* @bug 8225055 8239804 8246774 * @bug 8225055 8239804
* @summary Record types * @summary Record types
* @library /tools/lib ../../lib * @library /tools/lib ../../lib
* @modules jdk.javadoc/jdk.javadoc.internal.tool * @modules jdk.javadoc/jdk.javadoc.internal.tool
* @build toolbox.ToolBox javadoc.tester.* * @build toolbox.ToolBox javadoc.tester.*
* @run main TestRecordTypes * @compile --enable-preview --source ${jdk.version} TestRecordTypes.java
* @run main/othervm --enable-preview TestRecordTypes
*/ */
@ -68,6 +69,7 @@ public class TestRecordTypes extends JavadocTester {
javadoc("-d", base.resolve("out").toString(), javadoc("-d", base.resolve("out").toString(),
"-quiet", "-noindex", "-quiet", "-noindex",
"-sourcepath", src.toString(), "-sourcepath", src.toString(),
"--enable-preview", "--source", thisRelease,
src.resolve("R.java").toString()); src.resolve("R.java").toString());
checkExit(Exit.OK); checkExit(Exit.OK);
@ -89,6 +91,7 @@ public class TestRecordTypes extends JavadocTester {
javadoc("-d", base.resolve("out").toString(), javadoc("-d", base.resolve("out").toString(),
"-quiet", "-noindex", "-quiet", "-noindex",
"-sourcepath", src.toString(), "-sourcepath", src.toString(),
"--enable-preview", "--source", thisRelease,
"p"); "p");
checkExit(Exit.OK); checkExit(Exit.OK);
@ -110,6 +113,7 @@ public class TestRecordTypes extends JavadocTester {
javadoc("-d", base.resolve("out").toString(), javadoc("-d", base.resolve("out").toString(),
"-quiet", "-noindex", "-quiet", "-noindex",
"-sourcepath", src.toString(), "-sourcepath", src.toString(),
"--enable-preview", "--source", thisRelease,
"p"); "p");
checkExit(Exit.OK); checkExit(Exit.OK);
@ -135,6 +139,7 @@ public class TestRecordTypes extends JavadocTester {
javadoc("-d", base.resolve("out").toString(), javadoc("-d", base.resolve("out").toString(),
"-quiet", "-noindex", "-quiet", "-noindex",
"-sourcepath", src.toString(), "-sourcepath", src.toString(),
"--enable-preview", "--source", thisRelease,
"p"); "p");
checkExit(Exit.OK); checkExit(Exit.OK);
@ -166,6 +171,7 @@ public class TestRecordTypes extends JavadocTester {
javadoc("-d", base.resolve("out").toString(), javadoc("-d", base.resolve("out").toString(),
"-quiet", "-noindex", "-quiet", "-noindex",
"-sourcepath", src.toString(), "-sourcepath", src.toString(),
"--enable-preview", "--source", thisRelease,
"p"); "p");
checkExit(Exit.OK); checkExit(Exit.OK);
@ -198,6 +204,7 @@ public class TestRecordTypes extends JavadocTester {
javadoc("-d", base.resolve("out").toString(), javadoc("-d", base.resolve("out").toString(),
"-quiet", "-noindex", "-quiet", "-noindex",
"-sourcepath", src.toString(), "-sourcepath", src.toString(),
"--enable-preview", "--source", thisRelease,
"p"); "p");
checkExit(Exit.OK); checkExit(Exit.OK);
@ -261,6 +268,7 @@ public class TestRecordTypes extends JavadocTester {
"-quiet", "-noindex", "-quiet", "-noindex",
"-sourcepath", src.toString(), "-sourcepath", src.toString(),
"-linkoffline", externalDocs, localDocs, "-linkoffline", externalDocs, localDocs,
"--enable-preview", "--source", thisRelease,
"p"); "p");
checkExit(Exit.OK); checkExit(Exit.OK);
@ -341,6 +349,7 @@ public class TestRecordTypes extends JavadocTester {
"-quiet", "-noindex", "-quiet", "-noindex",
"--no-platform-links", "--no-platform-links",
"-sourcepath", src.toString(), "-sourcepath", src.toString(),
"--enable-preview", "--source", thisRelease,
"p"); "p");
checkExit(Exit.OK); checkExit(Exit.OK);
@ -366,6 +375,7 @@ public class TestRecordTypes extends JavadocTester {
javadoc("-d", base.resolve("out").toString(), javadoc("-d", base.resolve("out").toString(),
"-quiet", "-noindex", "-quiet", "-noindex",
"-sourcepath", src.toString(), "-sourcepath", src.toString(),
"--enable-preview", "--source", thisRelease,
"p"); "p");
checkExit(Exit.OK); checkExit(Exit.OK);
@ -396,6 +406,7 @@ public class TestRecordTypes extends JavadocTester {
"-quiet", "-noindex", "-quiet", "-noindex",
"-sourcepath", testSrc.toString(), "-sourcepath", testSrc.toString(),
"-linksource", "-linksource",
"--enable-preview", "--source", thisRelease,
"examples"); "examples");
checkExit(Exit.OK); checkExit(Exit.OK);
@ -404,11 +415,13 @@ public class TestRecordTypes extends JavadocTester {
"-sourcepath", testSrc.toString(), "-sourcepath", testSrc.toString(),
"-linksource", "-linksource",
"-linkoffline", externalDocs, localDocs, "-linkoffline", externalDocs, localDocs,
"--enable-preview", "--source", thisRelease,
"examples"); "examples");
checkExit(Exit.OK); checkExit(Exit.OK);
} }
@Test @Test
@SuppressWarnings("preview")
public void testAnnotations(Path base) throws IOException { public void testAnnotations(Path base) throws IOException {
ElementType[] types = { ElementType[] types = {
ElementType.FIELD, ElementType.FIELD,
@ -455,6 +468,7 @@ public class TestRecordTypes extends JavadocTester {
"--no-platform-links", "--no-platform-links",
"-sourcepath", src.toString(), "-sourcepath", src.toString(),
"-private", "-private",
"--enable-preview", "--source", thisRelease,
"p"); "p");
checkExit(Exit.OK); checkExit(Exit.OK);

View file

@ -23,7 +23,7 @@
/* /*
* @test * @test
* @bug 6493690 8246774 * @bug 6493690
* @summary javadoc should have a javax.tools.Tool service provider * @summary javadoc should have a javax.tools.Tool service provider
* @modules java.compiler * @modules java.compiler
* jdk.compiler * jdk.compiler
@ -78,7 +78,7 @@ public class GetTask_DiagListenerTest extends APITest {
} }
List<String> expect = Arrays.asList( List<String> expect = Arrays.asList(
"javadoc.note.msg", // Loading source file "javadoc.note.msg", // Loading source file
"compiler.err.expected4", // class, interface, enum, or record expected "compiler.err.expected3", // class, interface, enum, or __datum expected
"javadoc.note.msg"); // 1 error "javadoc.note.msg"); // 1 error
if (!diagCodes.equals(expect)) if (!diagCodes.equals(expect))
throw new Exception("unexpected diagnostics occurred"); throw new Exception("unexpected diagnostics occurred");

View file

@ -23,7 +23,7 @@
/* /*
* @test * @test
* @bug 8149524 8131024 8165211 8080071 8130454 8167343 8129559 8114842 8182268 8223782 8235474 8246774 * @bug 8149524 8131024 8165211 8080071 8130454 8167343 8129559 8114842 8182268 8223782 8235474
* @summary Test SourceCodeAnalysis * @summary Test SourceCodeAnalysis
* @build KullaTesting TestingInputStream * @build KullaTesting TestingInputStream
* @run testng CompletenessTest * @run testng CompletenessTest
@ -379,4 +379,10 @@ public class CompletenessTest extends KullaTesting {
assertStatus("int[] m = {1, 2}, n = new int[0]; int i;", COMPLETE, assertStatus("int[] m = {1, 2}, n = new int[0]; int i;", COMPLETE,
"int[] m = {1, 2}, n = new int[0];"); "int[] m = {1, 2}, n = new int[0];");
} }
@BeforeMethod
public void setUp() {
setUp(b -> b.compilerOptions("--enable-preview", "-source", String.valueOf(SourceVersion.latest().ordinal())));
}
} }

View file

@ -23,7 +23,7 @@
/* /*
* @test * @test
* @bug 8235474 8236715 8246774 * @bug 8235474 8236715
* @summary Tests for evalution of records * @summary Tests for evalution of records
* @modules jdk.jshell * @modules jdk.jshell
* @build KullaTesting TestingInputStream ExpectedDiagnostic * @build KullaTesting TestingInputStream ExpectedDiagnostic
@ -76,4 +76,10 @@ public class RecordsTest extends KullaTesting {
assertEval("record(\"r\")", "\"rr\""); assertEval("record(\"r\")", "\"rr\"");
assertEval("record(\"r\").length()", "2"); assertEval("record(\"r\").length()", "2");
} }
@BeforeMethod
public void setUp() {
setUp(b -> b.compilerOptions("--enable-preview", "-source", String.valueOf(SourceVersion.latest().ordinal()))
.remoteVMOptions("--enable-preview"));
}
} }

View file

@ -23,14 +23,14 @@
/* /*
* @test * @test
* @bug 8153716 8143955 8151754 8150382 8153920 8156910 8131024 8160089 8153897 8167128 8154513 8170015 8170368 8172102 8172103 8165405 8173073 8173848 8174041 8173916 8174028 8174262 8174797 8177079 8180508 8177466 8172154 8192979 8191842 8198573 8198801 8210596 8210959 8215099 8199623 8236715 8239536 8247456 8246774 * @bug 8153716 8143955 8151754 8150382 8153920 8156910 8131024 8160089 8153897 8167128 8154513 8170015 8170368 8172102 8172103 8165405 8173073 8173848 8174041 8173916 8174028 8174262 8174797 8177079 8180508 8177466 8172154 8192979 8191842 8198573 8198801 8210596 8210959 8215099 8199623 8236715 8239536 8247456
* @summary Simple jshell tool tests * @summary Simple jshell tool tests
* @modules jdk.compiler/com.sun.tools.javac.api * @modules jdk.compiler/com.sun.tools.javac.api
* jdk.compiler/com.sun.tools.javac.main * jdk.compiler/com.sun.tools.javac.main
* jdk.jdeps/com.sun.tools.javap * jdk.jdeps/com.sun.tools.javap
* jdk.jshell/jdk.internal.jshell.tool * jdk.jshell/jdk.internal.jshell.tool
* @build KullaTesting TestingInputStream * @build KullaTesting TestingInputStream
* @run testng ToolSimpleTest * @run testng/othervm ToolSimpleTest
*/ */
import java.util.ArrayList; import java.util.ArrayList;
@ -917,7 +917,7 @@ public class ToolSimpleTest extends ReplToolTesting {
@Test @Test
public void testRecords() { public void testRecords() {
test(new String[] {}, test(new String[] {"--enable-preview"},
(a) -> assertCommandOutputContains(a, "record R(int i) { public int g() { return j; } }", (a) -> assertCommandOutputContains(a, "record R(int i) { public int g() { return j; } }",
"| created record R, however, it cannot be instantiated or its methods invoked until variable j is declared"), "| created record R, however, it cannot be instantiated or its methods invoked until variable j is declared"),
(a) -> assertCommandOutputContains(a, "new R(0)", (a) -> assertCommandOutputContains(a, "new R(0)",

View file

@ -1,9 +1,10 @@
/** /**
* @test /nodynamiccopyright/ * @test /nodynamiccopyright/
* @bug 5012028 6384539 8074364 8250741 8246774 * @bug 5012028 6384539 8074364 8250741
* @summary javac crash when declare an annotation type illegally * @summary javac crash when declare an annotation type illegally
* *
* @compile/fail/ref=IllegalAnnotation.out -XDrawDiagnostics IllegalAnnotation.java * @compile/fail/ref=IllegalAnnotation.out -XDrawDiagnostics IllegalAnnotation.java
* @compile/fail/ref=IllegalAnnotation.out -XDrawDiagnostics --enable-preview -source ${jdk.version} IllegalAnnotation.java
*/ */
class IllegalAnnotation { class IllegalAnnotation {
{ {

View file

@ -1,2 +1,2 @@
IllegalAnnotation.java:10:10: compiler.err.annotation.decl.not.allowed.here IllegalAnnotation.java:11:10: compiler.err.annotation.decl.not.allowed.here
1 error 1 error

View file

@ -1,9 +1,9 @@
/** /**
* @test /nodynamiccopyright/ * @test /nodynamiccopyright/
* @bug 8242478 8246774 * @bug 8242478
* @summary test for local interfaces * @summary test for local interfaces
* @compile/fail/ref=LocalInterface.out -XDrawDiagnostics -source 15 LocalInterface.java * @compile/fail/ref=LocalInterface.out -XDrawDiagnostics LocalInterface.java
* @compile LocalInterface.java * @compile --enable-preview -source ${jdk.version} LocalInterface.java
*/ */
class LocalInterface { class LocalInterface {
void m() { void m() {

View file

@ -1,4 +1,2 @@
- compiler.warn.source.no.system.modules.path: 15
LocalInterface.java:10:9: compiler.err.intf.not.allowed.here LocalInterface.java:10:9: compiler.err.intf.not.allowed.here
1 error 1 error
1 warning

View file

@ -23,9 +23,9 @@
/* /*
* @test * @test
* @bug 8242478 8246774 * @bug 8242478
* @summary test local records * @summary test local records
* @compile LocalRecord.java * @compile --enable-preview -source ${jdk.version} LocalRecord.java
*/ */
class LocalRecord { class LocalRecord {
void m() { void m() {

View file

@ -24,11 +24,12 @@
/* /*
* @test * @test
* @summary test for com.sun.tools.javac.comp.Check::validateAnnotation, com.sun.tools.javac.code.SymbolMetadata::removeDeclarationMetadata and ::removeFromCompoundList * @summary test for com.sun.tools.javac.comp.Check::validateAnnotation, com.sun.tools.javac.code.SymbolMetadata::removeDeclarationMetadata and ::removeFromCompoundList
* @bug 8241312 8246774 * @bug 8241312
* @library /tools/lib * @library /tools/lib
* @modules jdk.compiler/com.sun.tools.javac.util * @modules jdk.compiler/com.sun.tools.javac.util
* jdk.jdeps/com.sun.tools.classfile * jdk.jdeps/com.sun.tools.classfile
* @run main ApplicableAnnotationsOnRecords * @compile --enable-preview -source ${jdk.version} ApplicableAnnotationsOnRecords.java
* @run main/othervm --enable-preview ApplicableAnnotationsOnRecords
*/ */
import com.sun.tools.classfile.*; import com.sun.tools.classfile.*;
import com.sun.tools.javac.util.Assert; import com.sun.tools.javac.util.Assert;

View file

@ -23,7 +23,7 @@
/* /*
* @test * @test
* @bug 7151010 8006547 8007766 8029017 8246774 * @bug 7151010 8006547 8007766 8029017
* @summary Default test cases for running combinations for Target values * @summary Default test cases for running combinations for Target values
* @modules jdk.compiler * @modules jdk.compiler
* @build Helper * @build Helper
@ -204,22 +204,25 @@ public class TargetAnnoCombo {
} }
} }
// options to be passed if target RECORD_COMPONENT can't be considered // options to be passed if all targets, including RECORD_COMPONENTS, are to be considered
List<String> source8 = List.of("-source", "8"); List<String> previewOptions = List.of(
"--enable-preview",
"-source", Integer.toString(Runtime.version().feature())
);
private void generate() { private void generate() {
// Adding test cases to run. // Adding test cases to run.
testCases.addAll(Arrays.asList( testCases.addAll(Arrays.asList(
// No base target against no container target. // No base target against no container target.
/* 0*/ new TestCase(noSet, noSet), new TestCase(noSet, noSet),
// No base target against empty container target. // No base target against empty container target.
/* 1*/ new TestCase(noSet, empty), new TestCase(noSet, empty),
// No base target against TYPE_USE only container target. // No base target against TYPE_USE only container target.
new TestCase(noSet, less(jdk8, TYPE_PARAMETER), source8), new TestCase(noSet, less(jdk8, TYPE_PARAMETER)),
// No base target against TYPE_PARAMETER only container target. // No base target against TYPE_PARAMETER only container target.
new TestCase(noSet, less(jdk8, TYPE_USE), source8), new TestCase(noSet, less(jdk8, TYPE_USE)),
// No base target against TYPE_USE + TYPE_PARAMETER only container target. // No base target against TYPE_USE + TYPE_PARAMETER only container target.
new TestCase(noSet, jdk8, source8), new TestCase(noSet, jdk8),
// No base target against TYPE_USE + some selection of jdk7 targets. // No base target against TYPE_USE + some selection of jdk7 targets.
new TestCase(noSet, new TestCase(noSet,
plus(EnumSet.range(TYPE, LOCAL_VARIABLE), TYPE_USE)), plus(EnumSet.range(TYPE, LOCAL_VARIABLE), TYPE_USE)),
@ -230,7 +233,7 @@ public class TargetAnnoCombo {
new TestCase(noSet, plus(empty, TYPE)), new TestCase(noSet, plus(empty, TYPE)),
new TestCase(noSet, plus(empty, PARAMETER)), new TestCase(noSet, plus(empty, PARAMETER)),
new TestCase(noSet, plus(empty, PACKAGE)), new TestCase(noSet, plus(empty, PACKAGE)),
/* 10*/ new TestCase(noSet, plus(empty, METHOD)), new TestCase(noSet, plus(empty, METHOD)),
new TestCase(noSet, plus(empty, LOCAL_VARIABLE)), new TestCase(noSet, plus(empty, LOCAL_VARIABLE)),
new TestCase(noSet, plus(empty, FIELD)), new TestCase(noSet, plus(empty, FIELD)),
new TestCase(noSet, plus(empty, CONSTRUCTOR)), new TestCase(noSet, plus(empty, CONSTRUCTOR)),
@ -243,32 +246,32 @@ public class TargetAnnoCombo {
new TestCase(empty, plus(empty, TYPE)), new TestCase(empty, plus(empty, TYPE)),
new TestCase(empty, plus(empty, PARAMETER)), new TestCase(empty, plus(empty, PARAMETER)),
new TestCase(empty, plus(empty, PACKAGE)), new TestCase(empty, plus(empty, PACKAGE)),
/* 20*/ new TestCase(empty, plus(empty, METHOD)), new TestCase(empty, plus(empty, METHOD)),
new TestCase(empty, plus(empty, LOCAL_VARIABLE)), new TestCase(empty, plus(empty, LOCAL_VARIABLE)),
new TestCase(empty, plus(empty, FIELD)), new TestCase(empty, plus(empty, FIELD)),
new TestCase(empty, plus(empty, CONSTRUCTOR)), new TestCase(empty, plus(empty, CONSTRUCTOR)),
new TestCase(empty, plus(empty, ANNOTATION_TYPE)), new TestCase(empty, plus(empty, ANNOTATION_TYPE)),
new TestCase(empty, less(jdk8, TYPE_USE), source8), new TestCase(empty, less(jdk8, TYPE_USE)),
new TestCase(empty, less(jdk8, TYPE_PARAMETER), source8), new TestCase(empty, less(jdk8, TYPE_PARAMETER)),
// No container target against all all-but one jdk7 targets. // No container target against all all-but one jdk7 targets.
new TestCase(less(jdk7, TYPE), noSet, source8), new TestCase(less(jdk7, TYPE), noSet),
new TestCase(less(jdk7, PARAMETER), noSet, source8), new TestCase(less(jdk7, PARAMETER), noSet),
new TestCase(less(jdk7, PACKAGE), noSet, source8), new TestCase(less(jdk7, PACKAGE), noSet),
/* 30*/ new TestCase(less(jdk7, METHOD), noSet, source8), new TestCase(less(jdk7, METHOD), noSet),
new TestCase(less(jdk7, LOCAL_VARIABLE), noSet, source8), new TestCase(less(jdk7, LOCAL_VARIABLE), noSet),
new TestCase(less(jdk7, FIELD), noSet, source8), new TestCase(less(jdk7, FIELD), noSet),
new TestCase(less(jdk7, CONSTRUCTOR), noSet, source8), new TestCase(less(jdk7, CONSTRUCTOR), noSet),
new TestCase(less(jdk7, ANNOTATION_TYPE), noSet, source8), new TestCase(less(jdk7, ANNOTATION_TYPE), noSet),
// No container against all but TYPE and ANNOTATION_TYPE // No container against all but TYPE and ANNOTATION_TYPE
new TestCase(less(jdk7, TYPE, ANNOTATION_TYPE), noSet), new TestCase(less(jdk7, TYPE, ANNOTATION_TYPE), noSet),
// No container against jdk7 targets. // No container against jdk7 targets.
new TestCase(jdk7, noSet, source8), new TestCase(jdk7, noSet),
// No container against jdk7 targets plus one or both of TYPE_USE, TYPE_PARAMETER // No container against jdk7 targets plus one or both of TYPE_USE, TYPE_PARAMETER
new TestCase(plus(jdk7, TYPE_USE), noSet, source8), new TestCase(plus(jdk7, TYPE_USE), noSet),
new TestCase(plus(jdk7, TYPE_PARAMETER), noSet, source8), new TestCase(plus(jdk7, TYPE_PARAMETER), noSet),
new TestCase(allTargets, noSet, null), new TestCase(allTargets, noSet, previewOptions),
// Empty container target against any lone target. // Empty container target against any lone target.
/* 40*/ new TestCase(plus(empty, TYPE), empty), new TestCase(plus(empty, TYPE), empty),
new TestCase(plus(empty, PARAMETER), empty), new TestCase(plus(empty, PARAMETER), empty),
new TestCase(plus(empty, PACKAGE), empty), new TestCase(plus(empty, PACKAGE), empty),
new TestCase(plus(empty, METHOD), empty), new TestCase(plus(empty, METHOD), empty),
@ -279,34 +282,34 @@ public class TargetAnnoCombo {
new TestCase(plus(empty, TYPE_USE), empty), new TestCase(plus(empty, TYPE_USE), empty),
new TestCase(plus(empty, TYPE_PARAMETER), empty), new TestCase(plus(empty, TYPE_PARAMETER), empty),
// All base targets against all container targets. // All base targets against all container targets.
/* 50*/ new TestCase(allTargets, allTargets), new TestCase(allTargets, allTargets, previewOptions),
// All base targets against all but one container targets. // All base targets against all but one container targets.
new TestCase(allTargets, less(allTargets, TYPE)), new TestCase(allTargets, less(allTargets, TYPE), previewOptions),
new TestCase(allTargets, less(allTargets, PARAMETER)), new TestCase(allTargets, less(allTargets, PARAMETER), previewOptions),
new TestCase(allTargets, less(allTargets, PACKAGE)), new TestCase(allTargets, less(allTargets, PACKAGE), previewOptions),
new TestCase(allTargets, less(allTargets, METHOD)), new TestCase(allTargets, less(allTargets, METHOD), previewOptions),
new TestCase(allTargets, less(allTargets, LOCAL_VARIABLE)), new TestCase(allTargets, less(allTargets, LOCAL_VARIABLE), previewOptions),
new TestCase(allTargets, less(allTargets, FIELD)), new TestCase(allTargets, less(allTargets, FIELD), previewOptions),
new TestCase(allTargets, less(allTargets, CONSTRUCTOR)), new TestCase(allTargets, less(allTargets, CONSTRUCTOR), previewOptions),
new TestCase(allTargets, less(allTargets, ANNOTATION_TYPE)), new TestCase(allTargets, less(allTargets, ANNOTATION_TYPE), previewOptions),
new TestCase(allTargets, less(allTargets, TYPE_USE)), new TestCase(allTargets, less(allTargets, TYPE_USE), previewOptions),
/* 60*/ new TestCase(allTargets, less(allTargets, TYPE_PARAMETER)), new TestCase(allTargets, less(allTargets, TYPE_PARAMETER), previewOptions),
// All container targets against all but one base targets. // All container targets against all but one base targets.
new TestCase(less(allTargets, TYPE), allTargets), new TestCase(less(allTargets, TYPE), allTargets, previewOptions),
new TestCase(less(allTargets, PARAMETER), allTargets), new TestCase(less(allTargets, PARAMETER), allTargets, previewOptions),
new TestCase(less(allTargets, PACKAGE), allTargets), new TestCase(less(allTargets, PACKAGE), allTargets, previewOptions),
new TestCase(less(allTargets, METHOD), allTargets), new TestCase(less(allTargets, METHOD), allTargets, previewOptions),
new TestCase(less(allTargets, LOCAL_VARIABLE), allTargets), new TestCase(less(allTargets, LOCAL_VARIABLE), allTargets, previewOptions),
new TestCase(less(allTargets, FIELD), allTargets), new TestCase(less(allTargets, FIELD), allTargets, previewOptions),
new TestCase(less(allTargets, CONSTRUCTOR), allTargets), new TestCase(less(allTargets, CONSTRUCTOR), allTargets, previewOptions),
new TestCase(less(allTargets, ANNOTATION_TYPE), allTargets), new TestCase(less(allTargets, ANNOTATION_TYPE), allTargets, previewOptions),
new TestCase(less(allTargets, TYPE_USE), allTargets), new TestCase(less(allTargets, TYPE_USE), allTargets, previewOptions),
/* 70*/ new TestCase(less(allTargets, TYPE_PARAMETER), allTargets))); new TestCase(less(allTargets, TYPE_PARAMETER), allTargets, previewOptions)));
// Generates 100 test cases for any lone base target contained in Set // Generates 100 test cases for any lone base target contained in Set
// allTargets against any lone container target. // allTargets against any lone container target.
for (ElementType b : allTargets) { for (ElementType b : allTargets) {
for (ElementType c : allTargets) { for (ElementType c : allTargets) {
testCases.add(new TestCase(plus(empty, b), plus(empty, c))); testCases.add(new TestCase(plus(empty, b), plus(empty, c), previewOptions));
} }
} }
} }
@ -453,7 +456,7 @@ public class TargetAnnoCombo {
if (allDiagnostics.stream().noneMatch(d -> d.getKind() == javax.tools.Diagnostic.Kind.ERROR)) { if (allDiagnostics.stream().noneMatch(d -> d.getKind() == javax.tools.Diagnostic.Kind.ERROR)) {
ok = true; ok = true;
} else { } else {
errMesg = "Test failed, should have compiled successfully."; errMesg = "Test failed, compiled unexpectedly.";
ok = false; ok = false;
} }
} else { } else {

View file

@ -23,7 +23,6 @@
/* /*
* @test * @test
* @bug 8246774
* @summary Verify location of type annotations on records * @summary Verify location of type annotations on records
* @library /tools/lib * @library /tools/lib
* @modules * @modules
@ -33,7 +32,8 @@
* jdk.compiler/com.sun.tools.javac.code * jdk.compiler/com.sun.tools.javac.code
* jdk.compiler/com.sun.tools.javac.util * jdk.compiler/com.sun.tools.javac.util
* @build toolbox.ToolBox toolbox.JavacTask * @build toolbox.ToolBox toolbox.JavacTask
* @run main TypeAnnotationsPositionsOnRecords * @compile --enable-preview -source ${jdk.version} TypeAnnotationsPositionsOnRecords.java
* @run main/othervm --enable-preview TypeAnnotationsPositionsOnRecords
*/ */
import java.util.List; import java.util.List;
@ -105,6 +105,7 @@ public class TypeAnnotationsPositionsOnRecords {
void compileTestClass() throws Exception { void compileTestClass() throws Exception {
new JavacTask(tb) new JavacTask(tb)
.sources(src) .sources(src)
.options("--enable-preview", "-source", Integer.toString(Runtime.version().feature()))
.run(); .run();
} }

View file

@ -1,7 +1,7 @@
AnnotatedImport.java:10:13: compiler.err.expected: token.identifier AnnotatedImport.java:10:13: compiler.err.expected: token.identifier
AnnotatedImport.java:10:16: compiler.err.expected4: class, interface, enum, record AnnotatedImport.java:10:16: compiler.err.expected3: class, interface, enum
AnnotatedImport.java:11:7: compiler.err.expected: token.identifier AnnotatedImport.java:11:7: compiler.err.expected: token.identifier
AnnotatedImport.java:11:11: compiler.err.expected4: class, interface, enum, record AnnotatedImport.java:11:11: compiler.err.expected3: class, interface, enum
AnnotatedImport.java:12:18: compiler.err.expected: token.identifier AnnotatedImport.java:12:18: compiler.err.expected: token.identifier
AnnotatedImport.java:12:21: compiler.err.expected4: class, interface, enum, record AnnotatedImport.java:12:21: compiler.err.expected3: class, interface, enum
6 errors 6 errors

View file

@ -1,3 +1,3 @@
AnnotatedPackage1.java:9:14: compiler.err.expected: token.identifier AnnotatedPackage1.java:9:14: compiler.err.expected: token.identifier
AnnotatedPackage1.java:9:17: compiler.err.expected4: class, interface, enum, record AnnotatedPackage1.java:9:17: compiler.err.expected3: class, interface, enum
2 errors 2 errors

View file

@ -1,3 +1,3 @@
AnnotatedPackage2.java:9:8: compiler.err.expected: token.identifier AnnotatedPackage2.java:9:8: compiler.err.expected: token.identifier
AnnotatedPackage2.java:9:12: compiler.err.expected4: class, interface, enum, record AnnotatedPackage2.java:9:12: compiler.err.expected3: class, interface, enum
2 errors 2 errors

View file

@ -23,12 +23,13 @@
/* /*
* @test * @test
* @bug 8205418 8207229 8207230 8230847 8245786 8247334 8248641 8240658 8246774 * @bug 8205418 8207229 8207230 8230847 8245786 8247334 8248641 8240658
* @summary Test the outcomes from Trees.getScope * @summary Test the outcomes from Trees.getScope
* @modules jdk.compiler/com.sun.tools.javac.api * @modules jdk.compiler/com.sun.tools.javac.api
* jdk.compiler/com.sun.tools.javac.comp * jdk.compiler/com.sun.tools.javac.comp
* jdk.compiler/com.sun.tools.javac.tree * jdk.compiler/com.sun.tools.javac.tree
* jdk.compiler/com.sun.tools.javac.util * jdk.compiler/com.sun.tools.javac.util
* @compile TestGetScopeResult.java
*/ */
import java.io.IOException; import java.io.IOException;
@ -558,7 +559,9 @@ public class TestGetScopeResult {
} }
Context ctx = new Context(); Context ctx = new Context();
TestAnalyzer.preRegister(ctx); TestAnalyzer.preRegister(ctx);
JavacTask t = (JavacTask) c.getTask(null, fm, null, null, null, List<String> options = List.of("--enable-preview",
"-source", System.getProperty("java.specification.version"));
JavacTask t = (JavacTask) c.getTask(null, fm, null, options, null,
List.of(new MyFileObject()), ctx); List.of(new MyFileObject()), ctx);
CompilationUnitTree cut = t.parse().iterator().next(); CompilationUnitTree cut = t.parse().iterator().next();
t.analyze(); t.analyze();
@ -633,7 +636,9 @@ public class TestGetScopeResult {
} }
Context ctx = new Context(); Context ctx = new Context();
TestAnalyzer.preRegister(ctx); TestAnalyzer.preRegister(ctx);
JavacTask t = (JavacTask) c.getTask(null, fm, null, null, null, List<String> options = List.of("--enable-preview",
"-source", System.getProperty("java.specification.version"));
JavacTask t = (JavacTask) c.getTask(null, fm, null, options, null,
List.of(new MyFileObject()), ctx); List.of(new MyFileObject()), ctx);
CompilationUnitTree cut = t.parse().iterator().next(); CompilationUnitTree cut = t.parse().iterator().next();
t.analyze(); t.analyze();

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2019, 2020, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -23,6 +23,9 @@
// key: compiler.err.invalid.accessor.method.in.record // key: compiler.err.invalid.accessor.method.in.record
// key: compiler.misc.accessor.method.must.not.be.generic // key: compiler.misc.accessor.method.must.not.be.generic
// key: compiler.note.preview.filename
// key: compiler.note.preview.recompile
// options: --enable-preview -source ${jdk.version}
record R(int i) { record R(int i) {
public <T> int i() { public <T> int i() {

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2019, 2020, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -23,6 +23,9 @@
// key: compiler.err.invalid.accessor.method.in.record // key: compiler.err.invalid.accessor.method.in.record
// key: compiler.misc.accessor.method.cant.throw.exception // key: compiler.misc.accessor.method.cant.throw.exception
// key: compiler.note.preview.filename
// key: compiler.note.preview.recompile
// options: --enable-preview -source ${jdk.version}
record R(int i) { record R(int i) {
public int i() throws ArithmeticException { public int i() throws ArithmeticException {

View file

@ -23,6 +23,9 @@
// key: compiler.err.invalid.accessor.method.in.record // key: compiler.err.invalid.accessor.method.in.record
// key: compiler.misc.accessor.method.must.not.be.static // key: compiler.misc.accessor.method.must.not.be.static
// key: compiler.note.preview.filename
// key: compiler.note.preview.recompile
// options: --enable-preview -source ${jdk.version}
record R(int x) { record R(int x) {
static final int j = 0; static final int j = 0;

View file

@ -23,6 +23,9 @@
// key: compiler.err.invalid.accessor.method.in.record // key: compiler.err.invalid.accessor.method.in.record
// key: compiler.misc.accessor.return.type.doesnt.match // key: compiler.misc.accessor.return.type.doesnt.match
// key: compiler.note.preview.filename
// key: compiler.note.preview.recompile
// options: --enable-preview -source ${jdk.version}
import java.util.List; import java.util.List;
record R(List<String> x) { record R(List<String> x) {

View file

@ -23,7 +23,10 @@
// key: compiler.err.invalid.canonical.constructor.in.record // key: compiler.err.invalid.canonical.constructor.in.record
// key: compiler.misc.canonical.must.not.have.stronger.access // key: compiler.misc.canonical.must.not.have.stronger.access
// key: compiler.note.preview.filename
// key: compiler.note.preview.recompile
// key: compiler.misc.canonical // key: compiler.misc.canonical
// options: --enable-preview -source ${jdk.version}
public record CanonicalCantHaveStrongerAccessPrivileges() { public record CanonicalCantHaveStrongerAccessPrivileges() {
private CanonicalCantHaveStrongerAccessPrivileges {} private CanonicalCantHaveStrongerAccessPrivileges {}

View file

@ -23,7 +23,10 @@
// key: compiler.err.invalid.canonical.constructor.in.record // key: compiler.err.invalid.canonical.constructor.in.record
// key: compiler.misc.canonical.must.not.contain.explicit.constructor.invocation // key: compiler.misc.canonical.must.not.contain.explicit.constructor.invocation
// key: compiler.note.preview.filename
// key: compiler.note.preview.recompile
// key: compiler.misc.canonical // key: compiler.misc.canonical
// options: --enable-preview -source ${jdk.version}
record R(int x) { record R(int x) {
public R(int x) { super(); this.x = x; } public R(int x) { super(); this.x = x; }

View file

@ -23,7 +23,10 @@
// key: compiler.err.invalid.canonical.constructor.in.record // key: compiler.err.invalid.canonical.constructor.in.record
// key: compiler.misc.canonical.with.name.mismatch // key: compiler.misc.canonical.with.name.mismatch
// key: compiler.note.preview.filename
// key: compiler.note.preview.recompile
// key: compiler.misc.canonical // key: compiler.misc.canonical
// options: --enable-preview -source ${jdk.version}
record R(int x) { record R(int x) {
public R(int _x) { this.x = _x; } public R(int _x) { this.x = _x; }

View file

@ -23,7 +23,10 @@
// key: compiler.err.invalid.canonical.constructor.in.record // key: compiler.err.invalid.canonical.constructor.in.record
// key: compiler.misc.canonical.cant.have.return.statement // key: compiler.misc.canonical.cant.have.return.statement
// key: compiler.note.preview.filename
// key: compiler.note.preview.recompile
// key: compiler.misc.compact // key: compiler.misc.compact
// options: --enable-preview -source ${jdk.version}
record R() { record R() {
public R { public R {

View file

@ -23,7 +23,10 @@
// key: compiler.err.invalid.canonical.constructor.in.record // key: compiler.err.invalid.canonical.constructor.in.record
// key: compiler.misc.throws.clause.not.allowed.for.canonical.constructor // key: compiler.misc.throws.clause.not.allowed.for.canonical.constructor
// key: compiler.note.preview.filename
// key: compiler.note.preview.recompile
// key: compiler.misc.canonical // key: compiler.misc.canonical
// options: --enable-preview -source ${jdk.version}
record R(int i) { record R(int i) {
public R(int i) throws Exception { public R(int i) throws Exception {

View file

@ -23,7 +23,10 @@
// key: compiler.err.invalid.canonical.constructor.in.record // key: compiler.err.invalid.canonical.constructor.in.record
// key: compiler.misc.canonical.must.not.declare.type.variables // key: compiler.misc.canonical.must.not.declare.type.variables
// key: compiler.note.preview.filename
// key: compiler.note.preview.recompile
// key: compiler.misc.canonical // key: compiler.misc.canonical
// options: --enable-preview -source ${jdk.version}
record R(int i) { record R(int i) {
public <T> R(int i) { public <T> R(int i) {

View file

@ -23,7 +23,10 @@
// key: compiler.err.invalid.canonical.constructor.in.record // key: compiler.err.invalid.canonical.constructor.in.record
// key: compiler.misc.type.must.be.identical.to.corresponding.record.component.type // key: compiler.misc.type.must.be.identical.to.corresponding.record.component.type
// key: compiler.note.preview.filename
// key: compiler.note.preview.recompile
// key: compiler.misc.canonical // key: compiler.misc.canonical
// options: --enable-preview -source ${jdk.version}
import java.util.List; import java.util.List;

View file

@ -22,7 +22,5 @@
*/ */
// key: compiler.err.expected3 // key: compiler.err.expected3
// key: compiler.warn.source.no.system.modules.path
// options: -source 15
int Expected3; int Expected3;

View file

@ -22,6 +22,9 @@
*/ */
// key: compiler.err.first.statement.must.be.call.to.another.constructor // key: compiler.err.first.statement.must.be.call.to.another.constructor
// key: compiler.note.preview.filename
// key: compiler.note.preview.recompile
// options: --enable-preview -source ${jdk.version}
record R(int x) { record R(int x) {
public R(int x, int y) { this.x = x; } public R(int x, int y) { this.x = x; }

View file

@ -22,5 +22,8 @@
*/ */
// key: compiler.err.illegal.record.component.name // key: compiler.err.illegal.record.component.name
// key: compiler.note.preview.filename
// key: compiler.note.preview.recompile
// options: --enable-preview -source ${jdk.version}
record R(int hashCode) {} record R(int hashCode) {}

View file

@ -22,5 +22,8 @@
*/ */
// key: compiler.err.record.header.expected // key: compiler.err.record.header.expected
// key: compiler.note.preview.filename
// key: compiler.note.preview.recompile
// options: --enable-preview -source ${jdk.version}
record R {} record R {}

View file

@ -22,6 +22,9 @@
*/ */
// key: compiler.err.instance.initializer.not.allowed.in.records // key: compiler.err.instance.initializer.not.allowed.in.records
// key: compiler.note.preview.filename
// key: compiler.note.preview.recompile
// options: --enable-preview -source ${jdk.version}
record R(int x) { record R(int x) {
{} {}

View file

@ -22,8 +22,6 @@
*/ */
// key: compiler.err.intf.not.allowed.here // key: compiler.err.intf.not.allowed.here
// key: compiler.warn.source.no.system.modules.path
// options: -source 15
class InterfaceNotAllowed { class InterfaceNotAllowed {
void m() { void m() {

View file

@ -22,6 +22,7 @@
*/ */
// key: compiler.err.invalid.supertype.record // key: compiler.err.invalid.supertype.record
// options: --enable-preview -source ${jdk.version}
@SuppressWarnings("preview") @SuppressWarnings("preview")
class R extends Record {} class R extends Record {}

View file

@ -27,6 +27,10 @@
// key: compiler.misc.kindname.method // key: compiler.misc.kindname.method
// key: compiler.err.already.defined // key: compiler.err.already.defined
// key: compiler.err.error // key: compiler.err.error
// key: compiler.note.preview.filename
// key: compiler.note.preview.recompile
// key: compiler.note.note
// run: backdoor // run: backdoor
// options: --enable-preview -source ${jdk.version}
record R(int i, int i) {} record R(int i, int i) {}

View file

@ -22,8 +22,6 @@
*/ */
// key: compiler.err.local.enum // key: compiler.err.local.enum
// key: compiler.warn.source.no.system.modules.path
// options: -source 15
class LocalEnum { class LocalEnum {
void m() { void m() {

View file

@ -23,6 +23,9 @@
// key: compiler.err.invalid.accessor.method.in.record // key: compiler.err.invalid.accessor.method.in.record
// key: compiler.misc.method.must.be.public // key: compiler.misc.method.must.be.public
// key: compiler.note.preview.filename
// key: compiler.note.preview.recompile
// options: --enable-preview -source ${jdk.version}
record R(int x) { record R(int x) {
private int x() { return x; } private int x() { return x; }

View file

@ -22,8 +22,7 @@
*/ */
// key: compiler.misc.feature.records // key: compiler.misc.feature.records
// key: compiler.err.feature.not.supported.in.source.plural // key: compiler.warn.preview.feature.use.plural
// key: compiler.warn.source.no.system.modules.path // options: --enable-preview -source ${jdk.version} -Xlint:preview
// options: -source 15
record R() {} record R() {}

View file

@ -22,6 +22,9 @@
*/ */
// key: compiler.err.record.cannot.declare.instance.fields // key: compiler.err.record.cannot.declare.instance.fields
// key: compiler.note.preview.filename
// key: compiler.note.preview.recompile
// options: --enable-preview -source ${jdk.version}
record R(int i) { record R(int i) {
private final int y = 0; private final int y = 0;

Some files were not shown because too many files have changed in this diff Show more