8267465: remove superfluous preview related annotations and test options

Reviewed-by: jlahoda
This commit is contained in:
Vicente Romero 2021-06-07 13:57:15 +00:00
parent 728a411a54
commit 4f9d6b7d68
33 changed files with 25 additions and 111 deletions

View File

@ -193,7 +193,6 @@ public class TreeScanner<R,P> implements TreeVisitor<R,P> {
* @param p {@inheritDoc}
* @return the result of scanning
*/
@SuppressWarnings("preview")
@Override
public R visitClass(ClassTree node, P p) {
R r = scan(node.getModifiers(), p);

View File

@ -415,7 +415,6 @@ public class Flags {
LocalVarFlags = FINAL | PARAMETER,
ReceiverParamFlags = PARAMETER;
@SuppressWarnings("preview")
public static Set<Modifier> asModifierSet(long flags) {
Set<Modifier> modifiers = modifierSets.get(flags);
if (modifiers == null) {

View File

@ -1472,7 +1472,6 @@ public abstract class Symbol extends AnnoConstruct implements PoolConstant, Elem
@DefinedBy(Api.LANGUAGE_MODEL)
@SuppressWarnings("preview")
public ElementKind getKind() {
apiComplete();
long flags = flags();
@ -1521,7 +1520,6 @@ public abstract class Symbol extends AnnoConstruct implements PoolConstant, Elem
}
@Override @DefinedBy(Api.LANGUAGE_MODEL)
@SuppressWarnings("preview")
public List<? extends RecordComponent> getRecordComponents() {
return recordComponents;
}
@ -1705,7 +1703,6 @@ public abstract class Symbol extends AnnoConstruct implements PoolConstant, Elem
} else if (isResourceVariable()) {
return ElementKind.RESOURCE_VARIABLE;
} else if ((flags & MATCH_BINDING) != 0) {
@SuppressWarnings("preview")
ElementKind kind = ElementKind.BINDING_VARIABLE;
return kind;
} else {
@ -1774,7 +1771,6 @@ public abstract class Symbol extends AnnoConstruct implements PoolConstant, Elem
}
}
@SuppressWarnings("preview")
public static class RecordComponent extends VarSymbol implements RecordComponentElement {
public MethodSymbol accessor;
public JCTree.JCMethodDecl accessorMeth;
@ -1817,7 +1813,6 @@ public abstract class Symbol extends AnnoConstruct implements PoolConstant, Elem
}
@Override @DefinedBy(Api.LANGUAGE_MODEL)
@SuppressWarnings("preview")
public ElementKind getKind() {
return ElementKind.RECORD_COMPONENT;
}
@ -1828,7 +1823,6 @@ public abstract class Symbol extends AnnoConstruct implements PoolConstant, Elem
}
@Override @DefinedBy(Api.LANGUAGE_MODEL)
@SuppressWarnings("preview")
public <R, P> R accept(ElementVisitor<R, P> v, P p) {
return v.visitRecordComponent(this, p);
}

View File

@ -3344,7 +3344,6 @@ public class Check {
return targets.isEmpty() || targets.isPresent() && !targets.get().isEmpty();
}
@SuppressWarnings("preview")
Optional<Set<Name>> getApplicableTargets(JCAnnotation a, Symbol s) {
Attribute.Array arr = getAttributeTargetAttribute(a.annotationType.type.tsym);
Name[] targets;

View File

@ -971,7 +971,6 @@ public class JavacProcessingEnvironment implements ProcessingEnvironment, Closea
* Computes the set of annotations on the symbol in question.
* Leave class public for external testing purposes.
*/
@SuppressWarnings("preview")
public static class ComputeAnnotationSet extends
ElementScanner14<Set<TypeElement>, Set<TypeElement>> {
final Elements elements;

View File

@ -123,7 +123,6 @@ public class JavacRoundEnvironment implements RoundEnvironment {
throwIfNotAnnotation(a);
Set<Element> result = Collections.emptySet();
@SuppressWarnings("preview")
var scanner = new AnnotationSetScanner(result);
for (Element element : rootElements)
@ -144,7 +143,6 @@ public class JavacRoundEnvironment implements RoundEnvironment {
}
Set<Element> result = Collections.emptySet();
@SuppressWarnings("preview")
var scanner = new AnnotationSetMultiScanner(result);
for (Element element : rootElements)
@ -154,7 +152,6 @@ public class JavacRoundEnvironment implements RoundEnvironment {
}
// Could be written as a local class inside getElementsAnnotatedWith
@SuppressWarnings("preview")
private class AnnotationSetScanner extends
ElementScanner14<Set<Element>, TypeElement> {
// Insertion-order preserving set
@ -190,7 +187,6 @@ public class JavacRoundEnvironment implements RoundEnvironment {
}
// Could be written as a local class inside getElementsAnnotatedWithAny
@SuppressWarnings("preview")
private class AnnotationSetMultiScanner extends
ElementScanner14<Set<Element>, Set<TypeElement>> {
// Insertion-order preserving set

View File

@ -88,7 +88,6 @@ public class PrintingProcessor extends AbstractProcessor {
/**
* Used for the -Xprint option and called by Elements.printElements
*/
@SuppressWarnings("preview")
public static class PrintingElementVisitor
extends SimpleElementVisitor14<PrintingElementVisitor, Boolean> {
int indentation; // Indentation level;

View File

@ -818,7 +818,6 @@ public abstract class JCTree implements Tree, Cloneable, DiagnosticPosition {
@Override
public void accept(Visitor v) { v.visitClassDef(this); }
@SuppressWarnings("preview")
@DefinedBy(Api.COMPILER_TREE)
public Kind getKind() {
if ((mods.flags & Flags.ANNOTATION) != 0)

View File

@ -52,7 +52,6 @@ import com.sun.tools.sjavac.pubapi.TypeDesc;
* This code and its internal interfaces are subject to change or
* deletion without notice.</b>
*/
@SuppressWarnings("preview")
public class PubapiVisitor extends ElementScanner14<Void, Void> {
private PubApi collectedApi = new PubApi();
@ -124,7 +123,6 @@ public class PubapiVisitor extends ElementScanner14<Void, Void> {
return null;
}
@SuppressWarnings("preview")
@Override @DefinedBy(Api.LANGUAGE_MODEL)
public Void visitRecordComponent(RecordComponentElement e, Void p) {
PubVar v = new PubVar(e.getModifiers(),

View File

@ -63,10 +63,4 @@ public class SealedClassesTest extends KullaTesting {
assertEval("class I2 extends I {}");
assertEval("new I2()");
}
@BeforeMethod
public void setUp() {
setUp(b -> b.compilerOptions("--enable-preview", "-source", String.valueOf(SourceVersion.latest().ordinal()))
.remoteVMOptions("--enable-preview"));
}
}

View File

@ -26,7 +26,7 @@ import java.lang.annotation.*;
/**
* @test
* @bug 8006547
* @compile --enable-preview -source ${jdk.version} NoTargetOnContainer.java
* @compile NoTargetOnContainer.java
*/
@interface FooContainer {

View File

@ -26,7 +26,7 @@ import java.lang.annotation.*;
/**
* @test
* @bug 8006547
* @compile --enable-preview -source ${jdk.version} NoTargetOnContainer2.java
* @compile NoTargetOnContainer2.java
*/
@interface FooContainer {

View File

@ -410,8 +410,6 @@ public class CombinationsTargetTest2 extends ClassfileTestHelper {
" boolean dataIsString = ( data instanceof _As_ _Bs_ String str && str.isEmpty());\n" +
"}\n").concat(sourceBase).replace("_OTHER_", annot2).replace("_As_",As).replace("_Bs_",Bs) +
"\n\n";
extraOptions = List.of("--enable-preview",
"-source", JDK_VERSION);
hasInnerClass=false;
break;
case src8: // (repeating) type annotations in use of instanceof
@ -464,8 +462,6 @@ public class CombinationsTargetTest2 extends ClassfileTestHelper {
" }\n" +
"}\n").concat(sourceBase).replace("_OTHER_", annot2).replace("_As_",As).replace("_Bs_",Bs) +
"\n\n";
extraOptions = List.of("--enable-preview",
"-source", JDK_VERSION);
hasInnerClass=false;
break;

View File

@ -28,8 +28,7 @@
* @modules java.compiler
* jdk.jdeps/com.sun.tools.javap
* @build toolbox.JavapTask
* @compile --enable-preview -source ${jdk.version} Patterns.java
* @run main/othervm --enable-preview Patterns
* @run main Patterns
*/
import java.lang.annotation.*;

View File

@ -70,9 +70,7 @@ public class TestGetElementReference {
}
}
DiagnosticCollector<JavaFileObject> diagnostics = new DiagnosticCollector<>();
List<String> options = List.of("-Xjcov",
"--enable-preview",
"-source", JDK_VERSION);
List<String> options = List.of("-Xjcov");
JavacTask ct = (JavacTask) ToolProvider.getSystemJavaCompiler().getTask(null, null, diagnostics, options, null, files);
Trees trees = Trees.instance(ct);
CompilationUnitTree cut = ct.parse().iterator().next();

View File

@ -704,9 +704,7 @@ public class TestGetScopeResult {
}
Context ctx = new Context();
TestAnalyzer.preRegister(ctx);
List<String> options = List.of("--enable-preview",
"-source", System.getProperty("java.specification.version"));
JavacTask t = (JavacTask) c.getTask(null, fm, null, options, null,
JavacTask t = (JavacTask) c.getTask(null, fm, null, null, null,
List.of(new MyFileObject()), ctx);
CompilationUnitTree cut = t.parse().iterator().next();
t.analyze();

View File

@ -26,8 +26,7 @@
* @bug 8240658 8266281
* @summary Verify that broken method invocations with lambdas get type inference done
* @modules jdk.compiler
* @compile --enable-preview -source ${jdk.version} TestGetTypeMirrorReference.java
* @run main/othervm --enable-preview TestGetTypeMirrorReference
* @run main TestGetTypeMirrorReference
*/
import com.sun.source.tree.CompilationUnitTree;

View File

@ -23,7 +23,6 @@
// key: compiler.err.illegal.start.of.stmt
// key: compiler.err.expected4
// options: --enable-preview -source ${jdk.version}
class IllegalStartOfStmt {
void m() {

View File

@ -94,8 +94,7 @@ public class DeduplicationTest {
"-d",
".",
"-XDdebug.dumpLambdaToMethodDeduplication",
"-XDdebug.dumpLambdaToMethodStats",
"--enable-preview", "-source", sourceVersion),
"-XDdebug.dumpLambdaToMethodStats"),
null,
fileManager.getJavaFileObjects(file));
Map<JCLambda, JCLambda> dedupedLambdas = new LinkedHashMap<>();

View File

@ -1497,8 +1497,7 @@ public class JavacParserTest extends TestCase {
void testStartAndEndPositionForClassesInPermitsClause() throws IOException {
String code = "package t; sealed class Test permits Sub1, Sub2 {} final class Sub1 extends Test {} final class Sub2 extends Test {}";
JavacTaskImpl ct = (JavacTaskImpl) tool.getTask(null, fm, null,
List.of("--enable-preview", "-source", Integer.toString(Runtime.version().feature())),
null, Arrays.asList(new MyFileObject(code)));
null, null, Arrays.asList(new MyFileObject(code)));
CompilationUnitTree cut = ct.parse().iterator().next();
ClassTree clazz = (ClassTree) cut.getTypeDecls().get(0);
List<? extends Tree> permitsList = clazz.getPermitsClause();

View File

@ -32,8 +32,7 @@
* jdk.compiler/com.sun.tools.javac.util
* @build toolbox.ToolBox toolbox.JavacTask
* @build JavacTestingAbstractProcessor
* @compile --enable-preview -source ${jdk.version} AnnoProcessorOnRecordsTest.java
* @run main/othervm --enable-preview AnnoProcessorOnRecordsTest
* @run main/othervm AnnoProcessorOnRecordsTest
*/
import java.io.*;
@ -149,10 +148,7 @@ public class AnnoProcessorOnRecordsTest extends TestRunner {
for (Mode mode : new Mode[] {Mode.API}) {
new JavacTask(tb, mode)
.options("-nowarn",
"-processor", Processor.class.getName(),
"--enable-preview",
"-source", Integer.toString(Runtime.version().feature()))
.options("-nowarn", "-processor", Processor.class.getName())
.files(findJavaFiles(src))
.outdir(classes)
.run()

View File

@ -32,8 +32,7 @@
* jdk.compiler/com.sun.tools.javac.util
* @build toolbox.ToolBox toolbox.JavacTask
* @build JavacTestingAbstractProcessor
* @compile --enable-preview -source ${jdk.version} CheckingTypeAnnotationsOnRecords.java
* @run main/othervm --enable-preview CheckingTypeAnnotationsOnRecords
* @run main/othervm CheckingTypeAnnotationsOnRecords
*/
import java.io.*;
@ -144,10 +143,7 @@ public class CheckingTypeAnnotationsOnRecords extends TestRunner {
for (Mode mode : new Mode[] {Mode.API}) {
new JavacTask(tb, mode)
.options("-nowarn",
"-processor", Processor.class.getName(),
"--enable-preview",
"-source", Integer.toString(Runtime.version().feature()))
.options("-nowarn", "-processor", Processor.class.getName())
.files(findJavaFiles(src))
.outdir(classes)
.run()

View File

@ -33,8 +33,7 @@
* jdk.compiler/com.sun.tools.javac.util
* @build toolbox.ToolBox toolbox.JavacTask
* @build JavacTestingAbstractProcessor
* @compile --enable-preview -source ${jdk.version} ErrorOnAnnoWithTargetMethod.java
* @run main/othervm --enable-preview ErrorOnAnnoWithTargetMethod
* @run main/othervm ErrorOnAnnoWithTargetMethod
*/
import java.io.*;
@ -157,10 +156,7 @@ public class ErrorOnAnnoWithTargetMethod extends TestRunner {
String source = SOURCE.replaceFirst("#ANNO", anno);
tb.writeJavaFiles(r, source);
new JavacTask(tb, Mode.API)
.options("-nowarn",
"-processor", Processor.class.getName(),
"--enable-preview",
"-source", Integer.toString(Runtime.version().feature()))
.options("-nowarn", "-processor", Processor.class.getName())
.files(findJavaFiles(src))
.outdir(classes)
.run()

View File

@ -24,10 +24,7 @@
/*
* @test 8242529
* @summary javac defines type annotations incorrectly for record members (constructor and property accessor)
* @modules
* jdk.compiler/com.sun.tools.javac.util
* @compile --enable-preview -source ${jdk.version} RecordNotPreservingNestedTypeAnnotationsTest.java
* @run main/othervm --enable-preview RecordNotPreservingNestedTypeAnnotationsTest
* @modules jdk.compiler/com.sun.tools.javac.util
*/
import java.lang.annotation.Annotation;

View File

@ -29,7 +29,7 @@
* @modules jdk.compiler
* @build JavacTestingAbstractProcessor
* @compile TestBindingVariable.java
* @compile --enable-preview -source ${jdk.version} -processor TestBindingVariable -proc:only TestBindingVariableData.java
* @compile -processor TestBindingVariable -proc:only TestBindingVariableData.java
*/
import javax.annotation.processing.*;

View File

@ -32,8 +32,7 @@
* jdk.compiler/com.sun.tools.javac.util
* @build toolbox.ToolBox toolbox.JavacTask
* @build JavacTestingAbstractProcessor
* @compile --enable-preview -source ${jdk.version} TestRecord.java
* @run main/othervm --enable-preview TestRecord
* @run main/othervm TestRecord
*/
import java.io.*;
@ -143,10 +142,7 @@ public class TestRecord extends TestRunner {
for (Mode mode : new Mode[] {Mode.API}) {
new JavacTask(tb, mode)
.options("-nowarn",
"-processor", Processor.class.getName(),
"--enable-preview",
"-source", Integer.toString(Runtime.version().feature()))
.options("-nowarn", "-processor", Processor.class.getName())
.files(findJavaFiles(src))
.outdir(classes)
.run()

View File

@ -27,8 +27,7 @@
* @library /tools/javac/lib
* @modules jdk.compiler
* @build JavacTestingAbstractProcessor
* @compile --enable-preview -source ${jdk.version} TestRecordDesugar.java
* @run main/othervm --enable-preview TestRecordDesugar
* @run main TestRecordDesugar
*/
import java.io.*;
@ -50,8 +49,6 @@ public class TestRecordDesugar extends JavacTestingAbstractProcessor {
String testSrc = System.getProperty("test.src");
String testClasspath = System.getProperty("test.class.path");
List<String> options = List.of(
"--enable-preview",
"-source", Integer.toString(Runtime.version().feature()),
"-classpath", testClasspath,
"-processor", "TestRecordDesugar",
"-proc:only",

View File

@ -33,8 +33,7 @@
* jdk.compiler/com.sun.tools.javac.util
* @build toolbox.ToolBox toolbox.JavacTask
* @build JavacTestingAbstractProcessor
* @compile --enable-preview -source ${jdk.version} RepeatingAnnotationsOnRecords.java
* @run main/othervm --enable-preview RepeatingAnnotationsOnRecords
* @run main/othervm RepeatingAnnotationsOnRecords
*/
import java.io.*;
@ -175,10 +174,7 @@ public class RepeatingAnnotationsOnRecords extends TestRunner {
for (Mode mode : new Mode[] {Mode.API}) {
new JavacTask(tb, mode)
.options("-nowarn",
"-processor", Processor.class.getName(),
"--enable-preview",
"-source", Integer.toString(Runtime.version().feature()))
.options("-nowarn", "-processor", Processor.class.getName())
.files(findJavaFiles(src))
.outdir(classes)
.run()

View File

@ -168,15 +168,12 @@ public class BinaryCompatibilityTests extends TestRunner {
Files.createDirectories(out);
new JavacTask(tb)
.options("--enable-preview",
"-source", Integer.toString(Runtime.version().feature()))
.outdir(out)
.files(findJavaFiles(pkg))
.run();
// let's execute to check that it's working
String output = new JavaTask(tb)
.vmOptions("--enable-preview")
.classpath(out.toString())
.classArgs("pkg.Super")
.run()
@ -192,8 +189,6 @@ public class BinaryCompatibilityTests extends TestRunner {
tb.writeJavaFiles(superClass, superClassCode2);
new JavacTask(tb)
.options("--enable-preview",
"-source", Integer.toString(Runtime.version().feature()))
.classpath(out)
.outdir(out)
.files(findJavaFiles(superClass))
@ -202,7 +197,6 @@ public class BinaryCompatibilityTests extends TestRunner {
if (shouldFail) {
// let's now check that there is an IncompatibleClassChangeError
output = new JavaTask(tb)
.vmOptions("--enable-preview")
.classpath(out.toString())
.classArgs("pkg.Super")
.run(Task.Expect.FAIL)
@ -213,7 +207,6 @@ public class BinaryCompatibilityTests extends TestRunner {
}
} else {
new JavaTask(tb)
.vmOptions("--enable-preview")
.classpath(out.toString())
.classArgs("pkg.Super")
.run(Task.Expect.SUCCESS);
@ -414,15 +407,12 @@ public class BinaryCompatibilityTests extends TestRunner {
new JavacTask(tb)
.outdir(out)
.options("--enable-preview",
"-source", Integer.toString(Runtime.version().feature()))
.files(findJavaFiles(pkg))
.run();
// let's execute to check that it's working
String output = new JavaTask(tb)
.classpath(out.toString())
.vmOptions("--enable-preview")
.classArgs("pkg.Super")
.run()
.writeAll()
@ -437,8 +427,6 @@ public class BinaryCompatibilityTests extends TestRunner {
tb.writeJavaFiles(sub, subClassCode2);
new JavacTask(tb)
.options("--enable-preview",
"-source", Integer.toString(Runtime.version().feature()))
.classpath(out)
.outdir(out)
.files(findJavaFiles(sub))
@ -446,7 +434,6 @@ public class BinaryCompatibilityTests extends TestRunner {
// should execute without issues
output = new JavaTask(tb)
.vmOptions("--enable-preview")
.classpath(out.toString())
.classArgs("pkg.Super")
.run()
@ -588,15 +575,12 @@ public class BinaryCompatibilityTests extends TestRunner {
Files.createDirectories(out);
new JavacTask(tb)
.options("--enable-preview",
"-source", Integer.toString(Runtime.version().feature()))
.outdir(out)
.files(findJavaFiles(pkg))
.run();
// let's execute to check that it's working
String output = new JavaTask(tb)
.vmOptions("--enable-preview")
.classpath(out.toString())
.classArgs("pkg.Super")
.run()
@ -614,15 +598,12 @@ public class BinaryCompatibilityTests extends TestRunner {
tb.writeJavaFiles(sub2, subClass2Code);
new JavacTask(tb)
.options("--enable-preview",
"-source", Integer.toString(Runtime.version().feature()))
.classpath(out)
.outdir(out)
.files(findJavaFiles(superClass)[0], findJavaFiles(sub2)[0])
.run();
new JavaTask(tb)
.vmOptions("--enable-preview")
.classpath(out.toString())
.classArgs("pkg.Super")
.run(Task.Expect.SUCCESS);

View File

@ -60,8 +60,7 @@ public class CheckSubtypesOfSealedTest extends TestBase {
}
void run() throws Exception {
InMemoryFileManager fileManager = compile(List.of("--enable-preview", "-source",
Integer.toString(Runtime.version().feature())), testSource);
InMemoryFileManager fileManager = compile(testSource);
checkClassFile(readClassFile(fileManager.getClasses().get("SealedClasses$SAC2")), CheckFor.SEALED);
checkClassFile(readClassFile(fileManager.getClasses().get("SealedClasses$SAC3")), CheckFor.FINAL);
checkClassFile(readClassFile(fileManager.getClasses().get("SealedClasses$SAC4")), CheckFor.FINAL);

View File

@ -648,7 +648,7 @@ public class SealedCompilationTests extends CompilationTestCase {
List<String> output = new JavacTask(tb)
.outdir(out)
.options("--enable-preview", "-source", Integer.toString(Runtime.version().feature()), "-Xprint")
.options("-Xprint")
.files(findJavaFiles(test))
.run()
.writeAll()

View File

@ -65,9 +65,7 @@ public class T8258662 extends TestRunner {
new JavacTask(tb)
.sources(code)
.classpath(".")
.options("--enable-preview", "-source", Integer.toString(Runtime.version().feature()))
.run()
.writeAll();
.run();
}
}

View File

@ -24,8 +24,7 @@
/*
* @test
* @bug 8071961
* @compile -Xlint:missing-explicit-ctor -Werror
* --enable-preview -source ${jdk.version} NoWarningRecord.java
* @compile -Xlint:missing-explicit-ctor -Werror NoWarningRecord.java
*/
public record NoWarningRecord(/* no components */) {