Skip to content

Commit

Permalink
8267465: remove superfluous preview related annotations and test options
Browse files Browse the repository at this point in the history
Reviewed-by: jlahoda
  • Loading branch information
Vicente Romero committed Jun 7, 2021
1 parent 728a411 commit 4f9d6b7
Show file tree
Hide file tree
Showing 33 changed files with 25 additions and 111 deletions.
Expand Up @@ -193,7 +193,6 @@ public R visitImport(ImportTree node, P 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);
Expand Down
Expand Up @@ -415,7 +415,6 @@ public static EnumSet<Flag> asFlagSet(long flags) {
LocalVarFlags = FINAL | PARAMETER,
ReceiverParamFlags = PARAMETER;

@SuppressWarnings("preview")
public static Set<Modifier> asModifierSet(long flags) {
Set<Modifier> modifiers = modifierSets.get(flags);
if (modifiers == null) {
Expand Down
Expand Up @@ -1472,7 +1472,6 @@ protected <A extends Annotation> A[] getInheritedAnnotations(Class<A> annoType)


@DefinedBy(Api.LANGUAGE_MODEL)
@SuppressWarnings("preview")
public ElementKind getKind() {
apiComplete();
long flags = flags();
Expand Down Expand Up @@ -1521,7 +1520,6 @@ public RecordComponent getRecordComponent(JCVariableDecl var, boolean addIfMissi
}

@Override @DefinedBy(Api.LANGUAGE_MODEL)
@SuppressWarnings("preview")
public List<? extends RecordComponent> getRecordComponents() {
return recordComponents;
}
Expand Down Expand Up @@ -1705,7 +1703,6 @@ public ElementKind getKind() {
} else if (isResourceVariable()) {
return ElementKind.RESOURCE_VARIABLE;
} else if ((flags & MATCH_BINDING) != 0) {
@SuppressWarnings("preview")
ElementKind kind = ElementKind.BINDING_VARIABLE;
return kind;
} else {
Expand Down Expand Up @@ -1774,7 +1771,6 @@ public <R, P> R accept(Symbol.Visitor<R, P> v, P p) {
}
}

@SuppressWarnings("preview")
public static class RecordComponent extends VarSymbol implements RecordComponentElement {
public MethodSymbol accessor;
public JCTree.JCMethodDecl accessorMeth;
Expand Down Expand Up @@ -1817,7 +1813,6 @@ public boolean isVarargs() {
}

@Override @DefinedBy(Api.LANGUAGE_MODEL)
@SuppressWarnings("preview")
public ElementKind getKind() {
return ElementKind.RECORD_COMPONENT;
}
Expand All @@ -1828,7 +1823,6 @@ public ExecutableElement getAccessor() {
}

@Override @DefinedBy(Api.LANGUAGE_MODEL)
@SuppressWarnings("preview")
public <R, P> R accept(ElementVisitor<R, P> v, P p) {
return v.visitRecordComponent(this, p);
}
Expand Down
Expand Up @@ -3344,7 +3344,6 @@ boolean annotationApplicable(JCAnnotation a, Symbol s) {
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;
Expand Down
Expand Up @@ -971,7 +971,6 @@ private void discoverAndRunProcs(Set<TypeElement> annotationsPresent,
* 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;
Expand Down
Expand Up @@ -123,7 +123,6 @@ public Set<? extends Element> getElementsAnnotatedWith(TypeElement a) {
throwIfNotAnnotation(a);

Set<Element> result = Collections.emptySet();
@SuppressWarnings("preview")
var scanner = new AnnotationSetScanner(result);

for (Element element : rootElements)
Expand All @@ -144,7 +143,6 @@ public Set<? extends Element> getElementsAnnotatedWithAny(TypeElement... annotat
}

Set<Element> result = Collections.emptySet();
@SuppressWarnings("preview")
var scanner = new AnnotationSetMultiScanner(result);

for (Element element : rootElements)
Expand All @@ -154,7 +152,6 @@ public Set<? extends Element> getElementsAnnotatedWithAny(TypeElement... annotat
}

// Could be written as a local class inside getElementsAnnotatedWith
@SuppressWarnings("preview")
private class AnnotationSetScanner extends
ElementScanner14<Set<Element>, TypeElement> {
// Insertion-order preserving set
Expand Down Expand Up @@ -190,7 +187,6 @@ public Set<Element> visitPackage(PackageElement e, TypeElement annotation) {
}

// Could be written as a local class inside getElementsAnnotatedWithAny
@SuppressWarnings("preview")
private class AnnotationSetMultiScanner extends
ElementScanner14<Set<Element>, Set<TypeElement>> {
// Insertion-order preserving set
Expand Down
Expand Up @@ -88,7 +88,6 @@ void print(Element element) {
/**
* Used for the -Xprint option and called by Elements.printElements
*/
@SuppressWarnings("preview")
public static class PrintingElementVisitor
extends SimpleElementVisitor14<PrintingElementVisitor, Boolean> {
int indentation; // Indentation level;
Expand Down
Expand Up @@ -818,7 +818,6 @@ protected JCClassDecl(JCModifiers mods,
@Override
public void accept(Visitor v) { v.visitClassDef(this); }

@SuppressWarnings("preview")
@DefinedBy(Api.COMPILER_TREE)
public Kind getKind() {
if ((mods.flags & Flags.ANNOTATION) != 0)
Expand Down
Expand Up @@ -52,7 +52,6 @@
* 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();
Expand Down Expand Up @@ -124,7 +123,6 @@ public Void visitVariable(VariableElement e, Void p) {
return null;
}

@SuppressWarnings("preview")
@Override @DefinedBy(Api.LANGUAGE_MODEL)
public Void visitRecordComponent(RecordComponentElement e, Void p) {
PubVar v = new PubVar(e.getModifiers(),
Expand Down
6 changes: 0 additions & 6 deletions test/langtools/jdk/jshell/SealedClassesTest.java
Expand Up @@ -63,10 +63,4 @@ public void testNonSealed() {
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"));
}
}
Expand Up @@ -26,7 +26,7 @@
/**
* @test
* @bug 8006547
* @compile --enable-preview -source ${jdk.version} NoTargetOnContainer.java
* @compile NoTargetOnContainer.java
*/

@interface FooContainer {
Expand Down
Expand Up @@ -26,7 +26,7 @@
/**
* @test
* @bug 8006547
* @compile --enable-preview -source ${jdk.version} NoTargetOnContainer2.java
* @compile NoTargetOnContainer2.java
*/

@interface FooContainer {
Expand Down
Expand Up @@ -410,8 +410,6 @@ String sourceString(String testname, String retentn, String annot2,
" 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
Expand Down Expand Up @@ -464,8 +462,6 @@ String sourceString(String testname, String retentn, String annot2,
" }\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;

Expand Down
Expand Up @@ -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.*;
Expand Down
4 changes: 1 addition & 3 deletions test/langtools/tools/javac/api/TestGetElementReference.java
Expand Up @@ -70,9 +70,7 @@ private static void analyze(boolean allowErrors, String... fileNames) throws IOE
}
}
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();
Expand Down
4 changes: 1 addition & 3 deletions test/langtools/tools/javac/api/TestGetScopeResult.java
Expand Up @@ -704,9 +704,7 @@ public String getCharContent(boolean ignoreEncodingErrors) {
}
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();
Expand Down
Expand Up @@ -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;
Expand Down
Expand Up @@ -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() {
Expand Down
Expand Up @@ -94,8 +94,7 @@ public static void main(String[] args) throws Exception {
"-d",
".",
"-XDdebug.dumpLambdaToMethodDeduplication",
"-XDdebug.dumpLambdaToMethodStats",
"--enable-preview", "-source", sourceVersion),
"-XDdebug.dumpLambdaToMethodStats"),
null,
fileManager.getJavaFileObjects(file));
Map<JCLambda, JCLambda> dedupedLambdas = new LinkedHashMap<>();
Expand Down
3 changes: 1 addition & 2 deletions test/langtools/tools/javac/parser/JavacParserTest.java
Expand Up @@ -1497,8 +1497,7 @@ void testCompoundAssignment() throws IOException {
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();
Expand Down
Expand Up @@ -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.*;
Expand Down Expand Up @@ -149,10 +148,7 @@ public void testAnnoProcessing(Path base) throws Exception {

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()
Expand Down
Expand Up @@ -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.*;
Expand Down Expand Up @@ -144,10 +143,7 @@ public void testAnnoProcessing(Path base) throws Exception {

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()
Expand Down
Expand Up @@ -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.*;
Expand Down Expand Up @@ -157,10 +156,7 @@ public void testAnnoProcessing(Path base) throws Exception {
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()
Expand Down
Expand Up @@ -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;
Expand Down
Expand Up @@ -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.*;
Expand Down
Expand Up @@ -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.*;
Expand Down Expand Up @@ -143,10 +142,7 @@ public void testAnnoProcessing(Path base) throws Exception {

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()
Expand Down
Expand Up @@ -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.*;
Expand All @@ -50,8 +49,6 @@ public static void main(String... args) {
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",
Expand Down

1 comment on commit 4f9d6b7

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

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

Please sign in to comment.