From a8245e14333db3bf638aae114ffb77ca0cc0fa9c Mon Sep 17 00:00:00 2001
From: Akhilesh Singh
Date: Fri, 8 Oct 2021 11:08:53 +0530
Subject: [PATCH] [NETBEANS-5828] : NB-Javac Upgrade to JDK-17 (#29)
* [NETBEANS-5828] : Resolved auto merge conflicts from JDK-17+32
---
.../nb-javac/nbproject/project.properties | 2 +-
.../javax/lang/model/SourceVersion.java | 23 +-
.../javax/lang/model/element/Modifier.java | 24 +-
.../javax/lang/model/element/TypeElement.java | 12 +-
.../AbstractAnnotationValueVisitor14.java | 2 +-
.../model/util/AbstractElementVisitor14.java | 2 +-
.../model/util/AbstractTypeVisitor14.java | 2 +-
.../lang/model/util/ElementKindVisitor14.java | 2 +-
.../lang/model/util/ElementScanner14.java | 2 +-
.../javax/lang/model/util/Elements.java | 18 +-
.../util/SimpleAnnotationValueVisitor14.java | 2 +-
.../model/util/SimpleElementVisitor14.java | 2 +-
.../lang/model/util/SimpleTypeVisitor14.java | 2 +-
.../lang/model/util/TypeKindVisitor14.java | 2 +-
.../javax/tools/StandardJavaFileManager.java | 36 +-
.../classes/javax/tools/ToolProvider.java | 3 +-
.../com/sun/source/tree/CaseLabelTree.java | 36 ++
.../classes/com/sun/source/tree/CaseTree.java | 12 +
.../com/sun/source/tree/ClassTree.java | 13 +-
.../sun/source/tree/CompilationUnitTree.java | 28 +-
.../sun/source/tree/DefaultCaseLabelTree.java | 35 ++
.../com/sun/source/tree/ExpressionTree.java | 2 +-
.../sun/source/tree/GuardedPatternTree.java | 50 ++
.../source/tree/ParenthesizedPatternTree.java | 49 ++
.../com/sun/source/tree/PatternTree.java | 2 +-
.../classes/com/sun/source/tree/Tree.java | 26 +
.../com/sun/source/tree/TreeVisitor.java | 32 ++
.../com/sun/source/util/DocTreeFactory.java | 12 +-
.../com/sun/source/util/DocTreeScanner.java | 179 +++++--
.../classes/com/sun/source/util/DocTrees.java | 1 +
.../sun/source/util/SimpleDocTreeVisitor.java | 142 +++--
.../sun/source/util/SimpleTreeVisitor.java | 340 ++++++++++--
.../classes/com/sun/source/util/TreePath.java | 4 +-
.../com/sun/source/util/TreeScanner.java | 369 ++++++++++---
.../com/sun/tools/doclint/DocLint.java | 2 -
.../tools/javac/api/ClientCodeWrapper.java | 6 +-
.../com/sun/tools/javac/api/JavacScope.java | 7 +-
.../sun/tools/javac/api/JavacTaskImpl.java | 4 +-
.../sun/tools/javac/api/JavacTaskPool.java | 16 +-
.../com/sun/tools/javac/api/JavacTool.java | 12 +-
.../com/sun/tools/javac/api/JavacTrees.java | 22 +-
.../sun/tools/javac/code/AnnoConstruct.java | 4 +-
.../com/sun/tools/javac/code/Attribute.java | 4 +-
.../com/sun/tools/javac/code/ClassFinder.java | 2 +-
.../com/sun/tools/javac/code/Directive.java | 4 +-
.../com/sun/tools/javac/code/Flags.java | 22 +-
.../com/sun/tools/javac/code/Lint.java | 10 +-
.../com/sun/tools/javac/code/Preview.java | 57 +-
.../com/sun/tools/javac/code/Scope.java | 55 +-
.../com/sun/tools/javac/code/Source.java | 22 +-
.../com/sun/tools/javac/code/Symbol.java | 27 +-
.../sun/tools/javac/code/SymbolMetadata.java | 4 +-
.../com/sun/tools/javac/code/Symtab.java | 17 +-
.../com/sun/tools/javac/code/Type.java | 20 +-
.../javac/code/TypeAnnotationPosition.java | 20 +-
.../sun/tools/javac/code/TypeAnnotations.java | 13 +-
.../com/sun/tools/javac/code/Types.java | 100 ++--
.../com/sun/tools/javac/comp/Analyzer.java | 24 +-
.../com/sun/tools/javac/comp/Annotate.java | 18 +-
.../sun/tools/javac/comp/ArgumentAttr.java | 20 +-
.../com/sun/tools/javac/comp/Attr.java | 298 ++++++++---
.../com/sun/tools/javac/comp/AttrRecover.java | 2 +-
.../com/sun/tools/javac/comp/Check.java | 167 ++++--
.../com/sun/tools/javac/comp/ConstFold.java | 3 +-
.../sun/tools/javac/comp/DeferredAttr.java | 110 ++--
.../com/sun/tools/javac/comp/Enter.java | 29 +
.../com/sun/tools/javac/comp/Flow.java | 227 +++++---
.../com/sun/tools/javac/comp/Infer.java | 7 +-
.../tools/javac/comp/InferenceContext.java | 8 +-
.../sun/tools/javac/comp/LambdaToMethod.java | 31 +-
.../com/sun/tools/javac/comp/Lower.java | 210 ++++++--
.../javac/comp/MatchBindingsComputer.java | 43 +-
.../com/sun/tools/javac/comp/MemberEnter.java | 4 +
.../com/sun/tools/javac/comp/Modules.java | 3 +-
.../com/sun/tools/javac/comp/Repair.java | 11 +-
.../com/sun/tools/javac/comp/Resolve.java | 98 ++--
.../sun/tools/javac/comp/TransPatterns.java | 499 ++++++++++++++++--
.../com/sun/tools/javac/comp/TransTypes.java | 23 +-
.../com/sun/tools/javac/comp/TreeDiffer.java | 8 +-
.../com/sun/tools/javac/comp/TypeEnter.java | 11 +-
.../com/sun/tools/javac/file/JRTIndex.java | 2 +-
.../tools/javac/file/JavacFileManager.java | 23 +-
.../com/sun/tools/javac/file/Locations.java | 2 +-
.../sun/tools/javac/file/PathFileObject.java | 2 +-
.../sun/tools/javac/file/RelativePath.java | 2 +-
.../com/sun/tools/javac/jvm/CRTable.java | 7 +-
.../com/sun/tools/javac/jvm/ClassFile.java | 77 +--
.../com/sun/tools/javac/jvm/ClassReader.java | 60 ++-
.../com/sun/tools/javac/jvm/ClassWriter.java | 11 +-
.../classes/com/sun/tools/javac/jvm/Code.java | 2 +-
.../classes/com/sun/tools/javac/jvm/Gen.java | 39 +-
.../com/sun/tools/javac/jvm/JNIWriter.java | 25 +-
.../com/sun/tools/javac/jvm/PoolConstant.java | 2 +-
.../com/sun/tools/javac/jvm/PoolWriter.java | 2 +-
.../com/sun/tools/javac/jvm/Target.java | 13 +-
.../com/sun/tools/javac/launcher/Main.java | 8 +-
.../com/sun/tools/javac/main/Arguments.java | 12 +-
.../javac/main/DelegatingJavaFileManager.java | 2 +-
.../sun/tools/javac/main/JavaCompiler.java | 47 +-
.../com/sun/tools/javac/main/Main.java | 2 +-
.../com/sun/tools/javac/main/Option.java | 54 +-
.../javac/model/AnnotationProxyMaker.java | 2 +-
.../tools/javac/model/FilteredMemberList.java | 3 +-
.../sun/tools/javac/model/JavacElements.java | 8 +-
.../com/sun/tools/javac/model/JavacTypes.java | 2 +-
.../tools/javac/parser/DocCommentParser.java | 24 +-
.../sun/tools/javac/parser/JavaTokenizer.java | 13 +-
.../sun/tools/javac/parser/JavacParser.java | 358 +++++++++----
.../tools/javac/parser/ReferenceParser.java | 4 +-
.../tools/javac/parser/ScannerFactory.java | 2 +-
.../com/sun/tools/javac/parser/Tokens.java | 57 +-
.../sun/tools/javac/parser/UnicodeReader.java | 21 +-
.../javac/platform/JDKPlatformProvider.java | 4 +-
.../tools/javac/processing/JavacFiler.java | 10 +-
.../JavacProcessingEnvironment.java | 9 +-
.../processing/JavacRoundEnvironment.java | 12 +-
.../javac/processing/PrintingProcessor.java | 80 ++-
.../javac/resources/CompilerProperties.java | 165 ++++--
.../tools/javac/resources/compiler.properties | 89 +++-
.../tools/javac/resources/javac.properties | 16 +-
.../com/sun/tools/javac/tree/DocPretty.java | 4 +-
.../com/sun/tools/javac/tree/JCTree.java | 208 +++++++-
.../com/sun/tools/javac/tree/Pretty.java | 53 +-
.../com/sun/tools/javac/tree/TreeCopier.java | 25 +-
.../com/sun/tools/javac/tree/TreeInfo.java | 87 ++-
.../com/sun/tools/javac/tree/TreeMaker.java | 32 +-
.../com/sun/tools/javac/tree/TreeScanner.java | 17 +-
.../sun/tools/javac/tree/TreeTranslator.java | 20 +-
.../util/AbstractDiagnosticFormatter.java | 6 +-
.../javac/util/BasicDiagnosticFormatter.java | 2 +-
.../com/sun/tools/javac/util/Bits.java | 2 +
.../com/sun/tools/javac/util/Constants.java | 6 +-
.../com/sun/tools/javac/util/Context.java | 2 +-
.../sun/tools/javac/util/Dependencies.java | 12 +-
.../tools/javac/util/DiagnosticSource.java | 8 +-
.../sun/tools/javac/util/IntHashTable.java | 60 +--
.../com/sun/tools/javac/util/Iterators.java | 2 +-
.../sun/tools/javac/util/JCDiagnostic.java | 2 +-
.../sun/tools/javac/util/JavacMessages.java | 2 +-
.../tools/javac/util/LayoutCharacters.java | 16 +-
.../com/sun/tools/javac/util/List.java | 2 +-
.../classes/com/sun/tools/javac/util/Log.java | 45 +-
.../javac/util/MandatoryWarningHandler.java | 22 +-
.../com/sun/tools/javac/util/Names.java | 16 +-
.../com/sun/tools/javac/util/Pair.java | 2 +-
.../javac/util/RawDiagnosticFormatter.java | 10 +-
.../javac/util/RichDiagnosticFormatter.java | 2 +-
.../sun/tools/javac/util/SharedNameTable.java | 8 +-
.../tools/javac/util/UnsharedNameTable.java | 8 +-
.../shellsupport/doc/JavadocFormatter.java | 3 +-
src/jdk.compiler/share/man/javac.1 | 7 +-
src/jdk.compiler/share/man/serialver.1 | 2 +-
.../com/sun/tools/classfile/Instruction.java | 4 +
.../com/sun/tools/javap/ClassWriter.java | 4 +-
.../com/sun/tools/javap/CodeWriter.java | 2 +-
.../classes/com/sun/tools/jdeprscan/Main.java | 10 +-
.../com/sun/tools/jdeprscan/scan/Scan.java | 2 +-
.../classes/com/sun/tools/jdeps/Analyzer.java | 8 +
.../com/sun/tools/jdeps/ClassFileReader.java | 4 +-
.../com/sun/tools/jdeps/JdepsWriter.java | 2 +-
.../sun/tools/jdeps/ModuleInfoBuilder.java | 2 +-
.../java/lang/annotation/ElementType.java | 19 +-
.../classes/jdk/internal/PreviewFeature.java | 28 +-
src/jdk.jdeps/share/man/javap.1 | 2 +-
src/jdk.jdeps/share/man/jdeprscan.1 | 2 +-
src/jdk.jdeps/share/man/jdeps.1 | 2 +-
166 files changed, 4290 insertions(+), 1539 deletions(-)
create mode 100644 src/jdk.compiler/share/classes/com/sun/source/tree/CaseLabelTree.java
create mode 100644 src/jdk.compiler/share/classes/com/sun/source/tree/DefaultCaseLabelTree.java
create mode 100644 src/jdk.compiler/share/classes/com/sun/source/tree/GuardedPatternTree.java
create mode 100644 src/jdk.compiler/share/classes/com/sun/source/tree/ParenthesizedPatternTree.java
diff --git a/make/langtools/netbeans/nb-javac/nbproject/project.properties b/make/langtools/netbeans/nb-javac/nbproject/project.properties
index 6c0d23e..3d58b74 100644
--- a/make/langtools/netbeans/nb-javac/nbproject/project.properties
+++ b/make/langtools/netbeans/nb-javac/nbproject/project.properties
@@ -104,4 +104,4 @@ javac.test.classpath=\
${build.dir}/lib/hamcrest-core-1.3.jar
debug.classpath=${run.classpath}
jnlp.enabled=false
-nb-javac-ver=16.0.0.0
+nb-javac-ver=17.0.0.0
diff --git a/src/java.compiler/share/classes/javax/lang/model/SourceVersion.java b/src/java.compiler/share/classes/javax/lang/model/SourceVersion.java
index 5122e79..4c7336a 100644
--- a/src/java.compiler/share/classes/javax/lang/model/SourceVersion.java
+++ b/src/java.compiler/share/classes/javax/lang/model/SourceVersion.java
@@ -221,9 +221,23 @@ public enum SourceVersion {
* The version recognized by the Java Platform, Standard Edition
* 16.
*
+ * Additions in this release include pattern matching for {@code
+ * instanceof} and records.
+ *
* @since 16
*/
- RELEASE_16;
+ RELEASE_16,
+
+ /**
+ * The version recognized by the Java Platform, Standard Edition
+ * 17.
+ *
+ * Additions in this release include sealed classes and
+ * restoration of always-strict floating-point semantics.
+ *
+ * @since 17
+ */
+ RELEASE_17;
// Note that when adding constants for newer releases, the
// behavior of latest() and latestSupported() must be updated too.
@@ -232,7 +246,7 @@ public enum SourceVersion {
* {@return the latest source version that can be modeled}
*/
public static SourceVersion latest() {
- return RELEASE_16;
+ return RELEASE_17;
}
private static final SourceVersion latestSupported = getLatestSupported();
@@ -246,10 +260,14 @@ public static SourceVersion latest() {
*/
private static SourceVersion getLatestSupported() {
+
try {
String specVersion = System.getProperty("java.specification.version");
switch (specVersion) {
+ case "17":
+ return RELEASE_17;
+
case "16":
return RELEASE_16;
@@ -279,6 +297,7 @@ private static SourceVersion getLatestSupported() {
}
return RELEASE_5;
+
}
diff --git a/src/java.compiler/share/classes/javax/lang/model/element/Modifier.java b/src/java.compiler/share/classes/javax/lang/model/element/Modifier.java
index f8aef53..dfbd76d 100644
--- a/src/java.compiler/share/classes/javax/lang/model/element/Modifier.java
+++ b/src/java.compiler/share/classes/javax/lang/model/element/Modifier.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 2020, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2021, 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
@@ -66,33 +66,15 @@ public enum Modifier {
/** The modifier {@code static} */ STATIC,
/**
- * {@preview Associated with sealed classes, a preview feature of the Java language.
- *
- * This enum constant is associated with sealed classes, 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.}
- *
* The modifier {@code sealed}
- * @since 15
+ * @since 17
*/
- @jdk.internal.PreviewFeature(feature=jdk.internal.PreviewFeature.Feature.SEALED_CLASSES,
- essentialAPI=false)
SEALED,
/**
- * {@preview Associated with sealed classes, a preview feature of the Java language.
- *
- * This enum constant is associated with sealed classes, 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.}
- *
* The modifier {@code non-sealed}
- * @since 15
+ * @since 17
*/
- @jdk.internal.PreviewFeature(feature=jdk.internal.PreviewFeature.Feature.SEALED_CLASSES,
- essentialAPI=false)
NON_SEALED {
public String toString() {
return "non-sealed";
diff --git a/src/java.compiler/share/classes/javax/lang/model/element/TypeElement.java b/src/java.compiler/share/classes/javax/lang/model/element/TypeElement.java
index 6ba3377..0a8b389 100644
--- a/src/java.compiler/share/classes/javax/lang/model/element/TypeElement.java
+++ b/src/java.compiler/share/classes/javax/lang/model/element/TypeElement.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 2020, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2021, 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
@@ -201,12 +201,6 @@ default List extends RecordComponentElement> getRecordComponents() {
}
/**
- * {@preview Associated with sealed classes, a preview feature of the Java language.
- *
- * This method is associated with sealed classes, 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 permitted classes of this class or interface
* element in declaration order.
*
@@ -215,10 +209,8 @@ default List extends RecordComponentElement> getRecordComponents() {
*
* @return the permitted classes, or an empty list if there are none
*
- * @since 15
+ * @since 17
*/
- @jdk.internal.PreviewFeature(feature=jdk.internal.PreviewFeature.Feature.SEALED_CLASSES,
- essentialAPI=false)
default List extends TypeMirror> getPermittedSubclasses() {
return Collections.unmodifiableList(new ArrayList());
}
diff --git a/src/java.compiler/share/classes/javax/lang/model/util/AbstractAnnotationValueVisitor14.java b/src/java.compiler/share/classes/javax/lang/model/util/AbstractAnnotationValueVisitor14.java
index db9d370..08a2fb5 100644
--- a/src/java.compiler/share/classes/javax/lang/model/util/AbstractAnnotationValueVisitor14.java
+++ b/src/java.compiler/share/classes/javax/lang/model/util/AbstractAnnotationValueVisitor14.java
@@ -44,7 +44,7 @@
* @see AbstractAnnotationValueVisitor9
* @since 14
*/
-@SupportedSourceVersion(RELEASE_16)
+@SupportedSourceVersion(RELEASE_17)
public abstract class AbstractAnnotationValueVisitor14 extends AbstractAnnotationValueVisitor9 {
/**
diff --git a/src/java.compiler/share/classes/javax/lang/model/util/AbstractElementVisitor14.java b/src/java.compiler/share/classes/javax/lang/model/util/AbstractElementVisitor14.java
index b2af474..dbb9e73 100644
--- a/src/java.compiler/share/classes/javax/lang/model/util/AbstractElementVisitor14.java
+++ b/src/java.compiler/share/classes/javax/lang/model/util/AbstractElementVisitor14.java
@@ -50,7 +50,7 @@
* @since 16
*/
-@SupportedSourceVersion(RELEASE_16)
+@SupportedSourceVersion(RELEASE_17)
public abstract class AbstractElementVisitor14 extends AbstractElementVisitor9 {
/**
diff --git a/src/java.compiler/share/classes/javax/lang/model/util/AbstractTypeVisitor14.java b/src/java.compiler/share/classes/javax/lang/model/util/AbstractTypeVisitor14.java
index 953c415..ac7ac4e 100644
--- a/src/java.compiler/share/classes/javax/lang/model/util/AbstractTypeVisitor14.java
+++ b/src/java.compiler/share/classes/javax/lang/model/util/AbstractTypeVisitor14.java
@@ -47,7 +47,7 @@
* @see AbstractTypeVisitor9
* @since 14
*/
-@SupportedSourceVersion(RELEASE_16)
+@SupportedSourceVersion(RELEASE_17)
public abstract class AbstractTypeVisitor14 extends AbstractTypeVisitor9 {
/**
* Constructor for concrete subclasses to call.
diff --git a/src/java.compiler/share/classes/javax/lang/model/util/ElementKindVisitor14.java b/src/java.compiler/share/classes/javax/lang/model/util/ElementKindVisitor14.java
index 6a620e8..e16d232 100644
--- a/src/java.compiler/share/classes/javax/lang/model/util/ElementKindVisitor14.java
+++ b/src/java.compiler/share/classes/javax/lang/model/util/ElementKindVisitor14.java
@@ -62,7 +62,7 @@
* @since 16
*/
-@SupportedSourceVersion(RELEASE_16)
+@SupportedSourceVersion(RELEASE_17)
public class ElementKindVisitor14 extends ElementKindVisitor9 {
/**
diff --git a/src/java.compiler/share/classes/javax/lang/model/util/ElementScanner14.java b/src/java.compiler/share/classes/javax/lang/model/util/ElementScanner14.java
index 905a7d4..eb483c9 100644
--- a/src/java.compiler/share/classes/javax/lang/model/util/ElementScanner14.java
+++ b/src/java.compiler/share/classes/javax/lang/model/util/ElementScanner14.java
@@ -76,7 +76,7 @@
* @see ElementScanner9
* @since 16
*/
-@SupportedSourceVersion(RELEASE_16)
+@SupportedSourceVersion(RELEASE_17)
public class ElementScanner14 extends ElementScanner9 {
/**
* Constructor for concrete subclasses; uses {@code null} for the
diff --git a/src/java.compiler/share/classes/javax/lang/model/util/Elements.java b/src/java.compiler/share/classes/javax/lang/model/util/Elements.java
index ec513fb..fc94c17 100644
--- a/src/java.compiler/share/classes/javax/lang/model/util/Elements.java
+++ b/src/java.compiler/share/classes/javax/lang/model/util/Elements.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 2020, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2021, 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
@@ -656,6 +656,22 @@ boolean overrides(ExecutableElement overrider, ExecutableElement overridden,
*/
boolean isFunctionalInterface(TypeElement type);
+ /**
+ * {@return {@code true} if the module element is an automatic
+ * module, {@code false} otherwise}
+ *
+ * @implSpec
+ * The default implementation of this method returns {@code
+ * false}.
+ *
+ * @param module the module element being examined
+ * @jls 7.7.1 Dependences
+ * @since 17
+ */
+ default boolean isAutomaticModule(ModuleElement module) {
+ return false;
+ }
+
/**
* Returns the record component for the given accessor. Returns null if the
* given method is not a record component accessor.
diff --git a/src/java.compiler/share/classes/javax/lang/model/util/SimpleAnnotationValueVisitor14.java b/src/java.compiler/share/classes/javax/lang/model/util/SimpleAnnotationValueVisitor14.java
index f48dd4d..347b522 100644
--- a/src/java.compiler/share/classes/javax/lang/model/util/SimpleAnnotationValueVisitor14.java
+++ b/src/java.compiler/share/classes/javax/lang/model/util/SimpleAnnotationValueVisitor14.java
@@ -52,7 +52,7 @@
* @see SimpleAnnotationValueVisitor9
* @since 14
*/
-@SupportedSourceVersion(RELEASE_16)
+@SupportedSourceVersion(RELEASE_17)
public class SimpleAnnotationValueVisitor14 extends SimpleAnnotationValueVisitor9 {
/**
* Constructor for concrete subclasses; uses {@code null} for the
diff --git a/src/java.compiler/share/classes/javax/lang/model/util/SimpleElementVisitor14.java b/src/java.compiler/share/classes/javax/lang/model/util/SimpleElementVisitor14.java
index e1d8a5a..23a7f10 100644
--- a/src/java.compiler/share/classes/javax/lang/model/util/SimpleElementVisitor14.java
+++ b/src/java.compiler/share/classes/javax/lang/model/util/SimpleElementVisitor14.java
@@ -58,7 +58,7 @@
* @since 16
*/
-@SupportedSourceVersion(RELEASE_16)
+@SupportedSourceVersion(RELEASE_17)
public class SimpleElementVisitor14 extends SimpleElementVisitor9 {
/**
diff --git a/src/java.compiler/share/classes/javax/lang/model/util/SimpleTypeVisitor14.java b/src/java.compiler/share/classes/javax/lang/model/util/SimpleTypeVisitor14.java
index 3a1b6f5..25af668 100644
--- a/src/java.compiler/share/classes/javax/lang/model/util/SimpleTypeVisitor14.java
+++ b/src/java.compiler/share/classes/javax/lang/model/util/SimpleTypeVisitor14.java
@@ -56,7 +56,7 @@
* @see SimpleTypeVisitor9
* @since 14
*/
-@SupportedSourceVersion(RELEASE_16)
+@SupportedSourceVersion(RELEASE_17)
public class SimpleTypeVisitor14 extends SimpleTypeVisitor9 {
/**
* Constructor for concrete subclasses; uses {@code null} for the
diff --git a/src/java.compiler/share/classes/javax/lang/model/util/TypeKindVisitor14.java b/src/java.compiler/share/classes/javax/lang/model/util/TypeKindVisitor14.java
index 9309b64..1adc974 100644
--- a/src/java.compiler/share/classes/javax/lang/model/util/TypeKindVisitor14.java
+++ b/src/java.compiler/share/classes/javax/lang/model/util/TypeKindVisitor14.java
@@ -61,7 +61,7 @@
* @see TypeKindVisitor9
* @since 14
*/
-@SupportedSourceVersion(RELEASE_16)
+@SupportedSourceVersion(RELEASE_17)
public class TypeKindVisitor14 extends TypeKindVisitor9 {
/**
* Constructor for concrete subclasses to call; uses {@code null}
diff --git a/src/java.compiler/share/classes/javax/tools/StandardJavaFileManager.java b/src/java.compiler/share/classes/javax/tools/StandardJavaFileManager.java
index 34ed761..b1fee9e 100644
--- a/src/java.compiler/share/classes/javax/tools/StandardJavaFileManager.java
+++ b/src/java.compiler/share/classes/javax/tools/StandardJavaFileManager.java
@@ -190,16 +190,16 @@ Iterable extends JavaFileObject> getJavaFileObjectsFromFiles(
* Returns file objects representing the given paths.
*
* @implSpec
- * The default implementation converts each path to a file and calls
- * {@link #getJavaFileObjectsFromFiles getJavaObjectsFromFiles}.
- * IllegalArgumentException will be thrown if any of the paths
- * cannot be converted to a file.
+ * The default implementation lazily converts each path to a file and calls
+ * {@link #getJavaFileObjectsFromFiles(Iterable) getJavaFileObjectsFromFiles}.
+ * {@code IllegalArgumentException} will be thrown
+ * if any of the paths cannot be converted to a file at the point the conversion happens.
*
* @param paths a list of paths
* @return a list of file objects
* @throws IllegalArgumentException if the list of paths includes
* a directory or if this file manager does not support any of the
- * given paths.
+ * given paths
*
* @since 13
*/
@@ -229,10 +229,10 @@ public File next() {
* Returns file objects representing the given paths.
*
* @implSpec
- * The default implementation converts each path to a file and calls
- * {@link #getJavaFileObjectsFromFiles getJavaObjectsFromFiles}.
- * IllegalArgumentException will be thrown if any of the paths
- * cannot be converted to a file.
+ * The default implementation lazily converts each path to a file and calls
+ * {@link #getJavaFileObjectsFromPaths(Collection) getJavaFileObjectsFromPaths}.
+ * {@code IllegalArgumentException} will be thrown
+ * if any of the paths cannot be converted to a file at the point the conversion happens.
*
* @param paths a list of paths
* @return a list of file objects
@@ -273,7 +273,8 @@ default Iterable extends JavaFileObject> getJavaFileObjectsFromPaths(
* @param files an array of files
* @return a list of file objects
* @throws IllegalArgumentException if the array of files includes
- * a directory
+ * a directory or if this file manager does not support any of the
+ * given paths
* @throws NullPointerException if the given array contains null
* elements
*/
@@ -287,10 +288,15 @@ default Iterable extends JavaFileObject> getJavaFileObjectsFromPaths(
* getJavaFileObjectsFromPaths({@linkplain java.util.Arrays#asList Arrays.asList}(paths))
*
*
+ * @implSpec
+ * The default implementation will only throw {@code NullPointerException}
+ * if {@linkplain #getJavaFileObjectsFromPaths(Collection)} throws it.
+ *
* @param paths an array of paths
* @return a list of file objects
* @throws IllegalArgumentException if the array of files includes
- * a directory
+ * a directory or if this file manager does not support any of the
+ * given paths
* @throws NullPointerException if the given array contains null
* elements
*
@@ -357,10 +363,10 @@ void setLocation(Location location, Iterable extends File> files)
* will be cancelled.
*
* @implSpec
- * The default implementation converts each path to a file and calls
- * {@link #getJavaFileObjectsFromFiles getJavaObjectsFromFiles}.
- * {@linkplain IllegalArgumentException IllegalArgumentException}
- * will be thrown if any of the paths cannot be converted to a file.
+ * The default implementation lazily converts each path to a file and calls
+ * {@link #setLocation setLocation}.
+ * {@code IllegalArgumentException} will be thrown if any of the paths cannot
+ * be converted to a file at the point the conversion happens.
*
* @param location a location
* @param paths a list of paths, if {@code null} use the default
diff --git a/src/java.compiler/share/classes/javax/tools/ToolProvider.java b/src/java.compiler/share/classes/javax/tools/ToolProvider.java
index e28d32e..4471f0a 100644
--- a/src/java.compiler/share/classes/javax/tools/ToolProvider.java
+++ b/src/java.compiler/share/classes/javax/tools/ToolProvider.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 2020, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2021, 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
@@ -24,7 +24,6 @@
*/
package javax.tools;
-
/**
* Provides methods for locating tool providers, for example,
* providers of compilers. This class complements the
diff --git a/src/jdk.compiler/share/classes/com/sun/source/tree/CaseLabelTree.java b/src/jdk.compiler/share/classes/com/sun/source/tree/CaseLabelTree.java
new file mode 100644
index 0000000..4e8b295
--- /dev/null
+++ b/src/jdk.compiler/share/classes/com/sun/source/tree/CaseLabelTree.java
@@ -0,0 +1,36 @@
+/*
+ * Copyright (c) 2021, 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. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * 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.
+ */
+
+package com.sun.source.tree;
+
+import jdk.internal.PreviewFeature;
+
+/**
+ * A marker interface for {@code Tree}s that may be used as {@link CaseTree} labels.
+ *
+ * @since 17
+ */
+@PreviewFeature(feature=PreviewFeature.Feature.SWITCH_PATTERN_MATCHING, reflective=true)
+public interface CaseLabelTree extends Tree {}
diff --git a/src/jdk.compiler/share/classes/com/sun/source/tree/CaseTree.java b/src/jdk.compiler/share/classes/com/sun/source/tree/CaseTree.java
index cdfcef3..a65896a 100644
--- a/src/jdk.compiler/share/classes/com/sun/source/tree/CaseTree.java
+++ b/src/jdk.compiler/share/classes/com/sun/source/tree/CaseTree.java
@@ -27,6 +27,8 @@
import java.util.List;
+import jdk.internal.PreviewFeature;
+
/**
* A tree node for a {@code case} in a {@code switch} statement or expression.
*
@@ -65,6 +67,16 @@ public interface CaseTree extends Tree {
@Deprecated()
List extends ExpressionTree> getExpressions();
+ /**
+ * Returns the labels for this case.
+ * For {@code default} case return a list with a single element, {@link DefaultCaseLabelTree}.
+ *
+ * @return labels for this case
+ * @since 17
+ */
+ @PreviewFeature(feature=PreviewFeature.Feature.SWITCH_PATTERN_MATCHING, reflective=true)
+ List extends CaseLabelTree> getLabels();
+
/**
* For case with kind {@linkplain CaseKind#STATEMENT},
* returns the statements labeled by the case.
diff --git a/src/jdk.compiler/share/classes/com/sun/source/tree/ClassTree.java b/src/jdk.compiler/share/classes/com/sun/source/tree/ClassTree.java
index b1c0a89..6be81f3 100644
--- a/src/jdk.compiler/share/classes/com/sun/source/tree/ClassTree.java
+++ b/src/jdk.compiler/share/classes/com/sun/source/tree/ClassTree.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 2020, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2021, 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
@@ -87,23 +87,14 @@ public interface ClassTree extends StatementTree {
List extends Tree> getImplementsClause();
/**
- * {@preview Associated with sealed classes, a preview feature of the Java language.
- *
- * This method is associated with sealed classes, 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 subclasses permitted by this type declaration.
*
* @implSpec this implementation returns an empty list
*
* @return the subclasses
*
- * @since 15
+ * @since 17
*/
- @jdk.internal.PreviewFeature(feature=jdk.internal.PreviewFeature.Feature.SEALED_CLASSES,
- essentialAPI=false)
default List extends Tree> getPermitsClause() {
return new ArrayList<>();
}
diff --git a/src/jdk.compiler/share/classes/com/sun/source/tree/CompilationUnitTree.java b/src/jdk.compiler/share/classes/com/sun/source/tree/CompilationUnitTree.java
index 7bbd93d..a9aff46 100644
--- a/src/jdk.compiler/share/classes/com/sun/source/tree/CompilationUnitTree.java
+++ b/src/jdk.compiler/share/classes/com/sun/source/tree/CompilationUnitTree.java
@@ -29,16 +29,29 @@
import javax.tools.JavaFileObject;
/**
- * Represents the abstract syntax tree for compilation units (source
- * files) and package declarations (package-info.java).
+ * Represents the abstract syntax tree for ordinary compilation units
+ * and modular compilation units.
*
* @jls 7.3 Compilation Units
* @jls 7.4 Package Declarations
+ * @jls 7.7 Module Declarations
*
* @author Peter von der Ahé
* @since 1.6
*/
public interface CompilationUnitTree extends Tree {
+
+ /**
+ * Returns the module tree associated with this compilation unit,
+ * or {@code null} if there is no module declaration.
+ * @return the module tree
+ * @implSpec This implementation throws {@code UnsupportedOperationException}
+ * @since 17
+ */
+ default ModuleTree getModule() {
+ throw new UnsupportedOperationException();
+ }
+
/**
* Returns the annotations listed on any package declaration
* at the head of this compilation unit, or {@code null} if there
@@ -64,15 +77,18 @@ public interface CompilationUnitTree extends Tree {
PackageTree getPackage();
/**
- * Returns the import declarations appearing in this compilation unit.
+ * Returns the import declarations appearing in this compilation unit,
+ * or an empty list if there are no import declarations.
* @return the import declarations
*/
List extends ImportTree> getImports();
/**
- * Returns the type declarations appearing in this compilation unit.
+ * Returns the type declarations appearing in this compilation unit,
+ * or an empty list if there are no type declarations.
* The list may also include empty statements resulting from
* extraneous semicolons.
+ * A modular compilation unit does not contain any type declarations.
* @return the type declarations
*/
List extends Tree> getTypeDecls();
@@ -84,8 +100,8 @@ public interface CompilationUnitTree extends Tree {
JavaFileObject getSourceFile();
/**
- * Returns the line map for this compilation unit, if available.
- * Returns {@code null} if the line map is not available.
+ * Returns the line map for this compilation unit, if available,
+ * or {@code null} if the line map is not available.
* @return the line map for this compilation unit
*/
LineMap getLineMap();
diff --git a/src/jdk.compiler/share/classes/com/sun/source/tree/DefaultCaseLabelTree.java b/src/jdk.compiler/share/classes/com/sun/source/tree/DefaultCaseLabelTree.java
new file mode 100644
index 0000000..d8b5e18
--- /dev/null
+++ b/src/jdk.compiler/share/classes/com/sun/source/tree/DefaultCaseLabelTree.java
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2021, 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. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * 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.
+ */
+package com.sun.source.tree;
+
+import jdk.internal.PreviewFeature;
+
+/**
+ * A case label that marks {@code default} in {@code case null, default}.
+ *
+ * @since 17
+ */
+@PreviewFeature(feature=PreviewFeature.Feature.SWITCH_PATTERN_MATCHING, reflective=true)
+public interface DefaultCaseLabelTree extends CaseLabelTree {}
diff --git a/src/jdk.compiler/share/classes/com/sun/source/tree/ExpressionTree.java b/src/jdk.compiler/share/classes/com/sun/source/tree/ExpressionTree.java
index bd6b17c..90b7ae4 100644
--- a/src/jdk.compiler/share/classes/com/sun/source/tree/ExpressionTree.java
+++ b/src/jdk.compiler/share/classes/com/sun/source/tree/ExpressionTree.java
@@ -35,4 +35,4 @@
* @author Jonathan Gibbons
* @since 1.6
*/
-public interface ExpressionTree extends Tree {}
+public interface ExpressionTree extends Tree, CaseLabelTree {}
diff --git a/src/jdk.compiler/share/classes/com/sun/source/tree/GuardedPatternTree.java b/src/jdk.compiler/share/classes/com/sun/source/tree/GuardedPatternTree.java
new file mode 100644
index 0000000..81587bd
--- /dev/null
+++ b/src/jdk.compiler/share/classes/com/sun/source/tree/GuardedPatternTree.java
@@ -0,0 +1,50 @@
+/*
+ * Copyright (c) 2017, 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. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * 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.
+ */
+
+package com.sun.source.tree;
+
+import jdk.internal.PreviewFeature;
+
+/**
+ * A guard pattern tree.
+ *
+ * @since 17
+ */
+@PreviewFeature(feature=PreviewFeature.Feature.SWITCH_PATTERN_MATCHING, reflective=true)
+public interface GuardedPatternTree extends PatternTree {
+
+ /**
+ * The guarded pattern expression.
+ * @return the guarded pattern
+ */
+ public PatternTree getPattern();
+
+ /**
+ * The guard expression.
+ * @return the guard expression
+ */
+ public ExpressionTree getExpression();
+
+}
diff --git a/src/jdk.compiler/share/classes/com/sun/source/tree/ParenthesizedPatternTree.java b/src/jdk.compiler/share/classes/com/sun/source/tree/ParenthesizedPatternTree.java
new file mode 100644
index 0000000..4c67925
--- /dev/null
+++ b/src/jdk.compiler/share/classes/com/sun/source/tree/ParenthesizedPatternTree.java
@@ -0,0 +1,49 @@
+/*
+ * Copyright (c) 2005, 2014, 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. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * 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.
+ */
+
+package com.sun.source.tree;
+
+import jdk.internal.PreviewFeature;
+
+/**
+ * A tree node for a parenthesized pattern.
+ *
+ * For example:
+ *
+ * ( pattern )
+ *
+ *
+ * @jls 14.30.1 Kinds of Patterns
+ *
+ * @since 17
+ */
+@PreviewFeature(feature=PreviewFeature.Feature.SWITCH_PATTERN_MATCHING, reflective=true)
+public interface ParenthesizedPatternTree extends PatternTree {
+ /**
+ * Returns the pattern within the parentheses.
+ * @return the pattern
+ */
+ PatternTree getPattern();
+}
diff --git a/src/jdk.compiler/share/classes/com/sun/source/tree/PatternTree.java b/src/jdk.compiler/share/classes/com/sun/source/tree/PatternTree.java
index 283fa20..c8c1b7a 100644
--- a/src/jdk.compiler/share/classes/com/sun/source/tree/PatternTree.java
+++ b/src/jdk.compiler/share/classes/com/sun/source/tree/PatternTree.java
@@ -31,4 +31,4 @@
*
* @since 16
*/
-public interface PatternTree extends Tree {}
+public interface PatternTree extends Tree, CaseLabelTree {}
diff --git a/src/jdk.compiler/share/classes/com/sun/source/tree/Tree.java b/src/jdk.compiler/share/classes/com/sun/source/tree/Tree.java
index 3a6cb09..45be8d3 100644
--- a/src/jdk.compiler/share/classes/com/sun/source/tree/Tree.java
+++ b/src/jdk.compiler/share/classes/com/sun/source/tree/Tree.java
@@ -25,6 +25,8 @@
package com.sun.source.tree;
+import jdk.internal.PreviewFeature;
+
/**
* Common interface for all nodes in an abstract syntax tree.
*
@@ -226,6 +228,30 @@ public enum Kind {
*/
BINDING_PATTERN(BindingPatternTree.class),
+ /**
+ * Used for instances of {@link GuardedPatternTree}.
+ *
+ * @since 17
+ */
+ @PreviewFeature(feature=PreviewFeature.Feature.SWITCH_PATTERN_MATCHING, reflective=true)
+ GUARDED_PATTERN(GuardedPatternTree.class),
+
+ /**
+ * Used for instances of {@link ParenthesizedPatternTree}.
+ *
+ * @since 17
+ */
+ @PreviewFeature(feature=PreviewFeature.Feature.SWITCH_PATTERN_MATCHING, reflective=true)
+ PARENTHESIZED_PATTERN(ParenthesizedPatternTree.class),
+
+ /**
+ * Used for instances of {@link DefaultCaseLabelTree}.
+ *
+ * @since 17
+ */
+ @PreviewFeature(feature=PreviewFeature.Feature.SWITCH_PATTERN_MATCHING, reflective=true)
+ DEFAULT_CASE_LABEL(DefaultCaseLabelTree.class),
+
/**
* Used for instances of {@link PrimitiveTypeTree}.
*/
diff --git a/src/jdk.compiler/share/classes/com/sun/source/tree/TreeVisitor.java b/src/jdk.compiler/share/classes/com/sun/source/tree/TreeVisitor.java
index cbb6f72..46b022a 100644
--- a/src/jdk.compiler/share/classes/com/sun/source/tree/TreeVisitor.java
+++ b/src/jdk.compiler/share/classes/com/sun/source/tree/TreeVisitor.java
@@ -25,6 +25,8 @@
package com.sun.source.tree;
+import jdk.internal.PreviewFeature;
+
/**
* A visitor of trees, in the style of the visitor design pattern.
* Classes implementing this interface are used to operate
@@ -266,6 +268,16 @@ public interface TreeVisitor {
*/
R visitBindingPattern(BindingPatternTree node, P p);
+ /**
+ * Visits a DefaultCaseLabelTree node.
+ * @param node the node being visited
+ * @param p a parameter value
+ * @return a result value
+ * @since 17
+ */
+ @PreviewFeature(feature=PreviewFeature.Feature.SWITCH_PATTERN_MATCHING, reflective=true)
+ R visitDefaultCaseLabel(DefaultCaseLabelTree node, P p);
+
/**
* Visits a MethodTree node.
* @param node the node being visited
@@ -290,6 +302,26 @@ public interface TreeVisitor {
*/
R visitNewArray(NewArrayTree node, P p);
+ /**
+ * Visits a GuardPatternTree node.
+ * @param node the node being visited
+ * @param p a parameter value
+ * @return a result value
+ * @since 17
+ */
+ @PreviewFeature(feature=PreviewFeature.Feature.SWITCH_PATTERN_MATCHING, reflective=true)
+ R visitGuardedPattern(GuardedPatternTree node, P p);
+
+ /**
+ * Visits a ParenthesizedPatternTree node.
+ * @param node the node being visited
+ * @param p a parameter value
+ * @return a result value
+ * @since 17
+ */
+ @PreviewFeature(feature=PreviewFeature.Feature.SWITCH_PATTERN_MATCHING, reflective=true)
+ R visitParenthesizedPattern(ParenthesizedPatternTree node, P p);
+
/**
* Visits a NewClassTree node.
* @param node the node being visited
diff --git a/src/jdk.compiler/share/classes/com/sun/source/util/DocTreeFactory.java b/src/jdk.compiler/share/classes/com/sun/source/util/DocTreeFactory.java
index f5834a5..8499273 100644
--- a/src/jdk.compiler/share/classes/com/sun/source/util/DocTreeFactory.java
+++ b/src/jdk.compiler/share/classes/com/sun/source/util/DocTreeFactory.java
@@ -269,13 +269,17 @@ DocCommentTree newDocCommentTree(List extends DocTree> fullBody,
* Creates a new {@code ReturnTree} object, to represent a {@code @return} tag
* or {@code {@return}} tag.
*
- * @implSpec This implementation throws {@code UnsupportedOperationException} if
- * {@code isInline} is {@code true}, and calls {@link #newReturnTree(List)} otherwise.
- *
+ * @param isInline {@code true} if this instance is as an inline tag,
+ * and {@code false} otherwise
* @param description the description of the return value of a method
+ *
* @return a {@code ReturnTree} object
* @throws UnsupportedOperationException if inline {@code {@return}} tags are
- * not supported
+ * not supported
+ *
+ * @implSpec This implementation throws {@code UnsupportedOperationException} if
+ * {@code isInline} is {@code true}, and calls {@link #newReturnTree(List)} otherwise.
+ *
* @since 16
*/
default ReturnTree newReturnTree(boolean isInline, List extends DocTree> description) {
diff --git a/src/jdk.compiler/share/classes/com/sun/source/util/DocTreeScanner.java b/src/jdk.compiler/share/classes/com/sun/source/util/DocTreeScanner.java
index 0ed59fe..54ce3b1 100644
--- a/src/jdk.compiler/share/classes/com/sun/source/util/DocTreeScanner.java
+++ b/src/jdk.compiler/share/classes/com/sun/source/util/DocTreeScanner.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2011, 2020, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2021, 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
@@ -35,22 +35,6 @@
* Inside your method, call super.visitXYZ to visit descendant
* nodes.
*
- *
The default implementation of the visitXYZ methods will determine
- * a result as follows:
- *
- *
If the node being visited has no children, the result will be {@code null}.
- *
If the node being visited has one child, the result will be the
- * result of calling {@code scan} on that child. The child may be a simple node
- * or itself a list of nodes.
- *
If the node being visited has more than one child, the result will
- * be determined by calling {@code scan} each child in turn, and then combining the
- * result of each scan after the first with the cumulative result
- * so far, as determined by the {@link #reduce} method. Each child may be either
- * a simple node of a list of nodes. The default behavior of the {@code reduce}
- * method is such that the result of the visitXYZ method will be the result of
- * the last child scanned.
- *
- *
*
Here is an example to count the number of erroneous nodes in a tree:
*
The default implementation of the visitXYZ methods will determine
+ * a result as follows:
+ *
+ *
If the node being visited has no children, the result will be {@code null}.
+ *
If the node being visited has one child, the result will be the
+ * result of calling {@code scan} with that child. The child may be a simple node
+ * or itself a list of nodes.
+ *
If the node being visited has more than one child, the result will
+ * be determined by calling {@code scan} with each child in turn, and then combining the
+ * result of each scan after the first with the cumulative result
+ * so far, as determined by the {@link #reduce} method. Each child may be either
+ * a simple node or a list of nodes. The default behavior of the {@code reduce}
+ * method is such that the result of the visitXYZ method will be the result of
+ * the last child scanned.
+ *
+ *
* @since 1.8
*/
public class DocTreeScanner implements DocTreeVisitor {
@@ -128,7 +129,9 @@ public R reduce(R r1, R r2) {
****************************************************************************/
/**
- * {@inheritDoc} This implementation scans the children in left to right order.
+ * {@inheritDoc}
+ *
+ * @implSpec This implementation scans the children in left to right order.
*
* @param node {@inheritDoc}
* @param p {@inheritDoc}
@@ -140,7 +143,9 @@ public R visitAttribute(AttributeTree node, P p) {
}
/**
- * {@inheritDoc} This implementation scans the children in left to right order.
+ * {@inheritDoc}
+ *
+ * @implSpec This implementation scans the children in left to right order.
*
* @param node {@inheritDoc}
* @param p {@inheritDoc}
@@ -152,7 +157,9 @@ public R visitAuthor(AuthorTree node, P p) {
}
/**
- * {@inheritDoc} This implementation returns {@code null}.
+ * {@inheritDoc}
+ *
+ * @implSpec This implementation returns {@code null}.
*
* @param node {@inheritDoc}
* @param p {@inheritDoc}
@@ -164,7 +171,9 @@ public R visitComment(CommentTree node, P p) {
}
/**
- * {@inheritDoc} This implementation scans the children in left to right order.
+ * {@inheritDoc}
+ *
+ * @implSpec This implementation scans the children in left to right order.
*
* @param node {@inheritDoc}
* @param p {@inheritDoc}
@@ -176,7 +185,9 @@ public R visitDeprecated(DeprecatedTree node, P p) {
}
/**
- * {@inheritDoc} This implementation scans the children in left to right order.
+ * {@inheritDoc}
+ *
+ * @implSpec This implementation scans the children in left to right order.
*
* @param node {@inheritDoc}
* @param p {@inheritDoc}
@@ -191,7 +202,9 @@ public R visitDocComment(DocCommentTree node, P p) {
}
/**
- * {@inheritDoc} This implementation returns {@code null}.
+ * {@inheritDoc}
+ *
+ * @implSpec This implementation returns {@code null}.
*
* @param node {@inheritDoc}
* @param p {@inheritDoc}
@@ -203,7 +216,9 @@ public R visitDocRoot(DocRootTree node, P p) {
}
/**
- * {@inheritDoc} This implementation returns {@code null}.
+ * {@inheritDoc}
+ *
+ * @implSpec This implementation returns {@code null}.
*
* @param node {@inheritDoc}
* @param p {@inheritDoc}
@@ -215,7 +230,9 @@ public R visitDocType(DocTypeTree node, P p) {
}
/**
- * {@inheritDoc} This implementation returns {@code null}.
+ * {@inheritDoc}
+ *
+ * @implSpec This implementation returns {@code null}.
*
* @param node {@inheritDoc}
* @param p {@inheritDoc}
@@ -227,7 +244,9 @@ public R visitEndElement(EndElementTree node, P p) {
}
/**
- * {@inheritDoc} This implementation returns {@code null}.
+ * {@inheritDoc}
+ *
+ * @implSpec This implementation returns {@code null}.
*
* @param node {@inheritDoc}
* @param p {@inheritDoc}
@@ -239,7 +258,9 @@ public R visitEntity(EntityTree node, P p) {
}
/**
- * {@inheritDoc} This implementation returns {@code null}.
+ * {@inheritDoc}
+ *
+ * @implSpec This implementation returns {@code null}.
*
* @param node {@inheritDoc}
* @param p {@inheritDoc}
@@ -251,7 +272,9 @@ public R visitErroneous(ErroneousTree node, P p) {
}
/**
- * {@inheritDoc} This implementation scans the children in left to right order.
+ * {@inheritDoc}
+ *
+ * @implSpec This implementation scans the children in left to right order.
*
* @param node {@inheritDoc}
* @param p {@inheritDoc}
@@ -263,7 +286,9 @@ public R visitHidden(HiddenTree node, P p) {
}
/**
- * {@inheritDoc} This implementation returns {@code null}.
+ * {@inheritDoc}
+ *
+ * @implSpec This implementation returns {@code null}.
*
* @param node {@inheritDoc}
* @param p {@inheritDoc}
@@ -275,7 +300,9 @@ public R visitIdentifier(IdentifierTree node, P p) {
}
/**
- * {@inheritDoc} This implementation scans the children in left to right order.
+ * {@inheritDoc}
+ *
+ * @implSpec This implementation scans the children in left to right order.
*
* @param node {@inheritDoc}
* @param p {@inheritDoc}
@@ -289,7 +316,9 @@ public R visitIndex(IndexTree node, P p) {
}
/**
- * {@inheritDoc} This implementation returns {@code null}.
+ * {@inheritDoc}
+ *
+ * @implSpec This implementation returns {@code null}.
*
* @param node {@inheritDoc}
* @param p {@inheritDoc}
@@ -301,7 +330,9 @@ public R visitInheritDoc(InheritDocTree node, P p) {
}
/**
- * {@inheritDoc} This implementation scans the children in left to right order.
+ * {@inheritDoc}
+ *
+ * @implSpec This implementation scans the children in left to right order.
*
* @param node {@inheritDoc}
* @param p {@inheritDoc}
@@ -315,7 +346,9 @@ public R visitLink(LinkTree node, P p) {
}
/**
- * {@inheritDoc} This implementation scans the children in left to right order.
+ * {@inheritDoc}
+ *
+ * @implSpec This implementation scans the children in left to right order.
*
* @param node {@inheritDoc}
* @param p {@inheritDoc}
@@ -327,7 +360,9 @@ public R visitLiteral(LiteralTree node, P p) {
}
/**
- * {@inheritDoc} This implementation scans the children in left to right order.
+ * {@inheritDoc}
+ *
+ * @implSpec This implementation scans the children in left to right order.
*
* @param node {@inheritDoc}
* @param p {@inheritDoc}
@@ -341,7 +376,9 @@ public R visitParam(ParamTree node, P p) {
}
/**
- * {@inheritDoc} This implementation scans the children in left to right order.
+ * {@inheritDoc}
+ *
+ * @implSpec This implementation scans the children in left to right order.
*
* @param node {@inheritDoc}
* @param p {@inheritDoc}
@@ -355,7 +392,9 @@ public R visitProvides(ProvidesTree node, P p) {
}
/**
- * {@inheritDoc} This implementation returns {@code null}.
+ * {@inheritDoc}
+ *
+ * @implSpec This implementation returns {@code null}.
*
* @param node {@inheritDoc}
* @param p {@inheritDoc}
@@ -367,7 +406,9 @@ public R visitReference(ReferenceTree node, P p) {
}
/**
- * {@inheritDoc} This implementation scans the children in left to right order.
+ * {@inheritDoc}
+ *
+ * @implSpec This implementation scans the children in left to right order.
*
* @param node {@inheritDoc}
* @param p {@inheritDoc}
@@ -379,7 +420,9 @@ public R visitReturn(ReturnTree node, P p) {
}
/**
- * {@inheritDoc} This implementation scans the children in left to right order.
+ * {@inheritDoc}
+ *
+ * @implSpec This implementation scans the children in left to right order.
*
* @param node {@inheritDoc}
* @param p {@inheritDoc}
@@ -391,7 +434,9 @@ public R visitSee(SeeTree node, P p) {
}
/**
- * {@inheritDoc} This implementation scans the children in left to right order.
+ * {@inheritDoc}
+ *
+ * @implSpec This implementation scans the children in left to right order.
*
* @param node {@inheritDoc}
* @param p {@inheritDoc}
@@ -403,7 +448,9 @@ public R visitSerial(SerialTree node, P p) {
}
/**
- * {@inheritDoc} This implementation scans the children in left to right order.
+ * {@inheritDoc}
+ *
+ * @implSpec This implementation scans the children in left to right order.
*
* @param node {@inheritDoc}
* @param p {@inheritDoc}
@@ -415,7 +462,9 @@ public R visitSerialData(SerialDataTree node, P p) {
}
/**
- * {@inheritDoc} This implementation scans the children in left to right order.
+ * {@inheritDoc}
+ *
+ * @implSpec This implementation scans the children in left to right order.
*
* @param node {@inheritDoc}
* @param p {@inheritDoc}
@@ -430,7 +479,9 @@ public R visitSerialField(SerialFieldTree node, P p) {
}
/**
- * {@inheritDoc} This implementation scans the children in left to right order.
+ * {@inheritDoc}
+ *
+ * @implSpec This implementation scans the children in left to right order.
*
* @param node {@inheritDoc}
* @param p {@inheritDoc}
@@ -442,7 +493,9 @@ public R visitSince(SinceTree node, P p) {
}
/**
- * {@inheritDoc} This implementation scans the children in left to right order.
+ * {@inheritDoc}
+ *
+ * @implSpec This implementation scans the children in left to right order.
*
* @param node {@inheritDoc}
* @param p {@inheritDoc}
@@ -454,7 +507,9 @@ public R visitStartElement(StartElementTree node, P p) {
}
/**
- * {@inheritDoc} This implementation scans the children in left to right order.
+ * {@inheritDoc}
+ *
+ * @implSpec This implementation scans the children in left to right order.
*
* @param node {@inheritDoc}
* @param p {@inheritDoc}
@@ -467,7 +522,9 @@ public R visitSummary(SummaryTree node, P p) {
}
/**
- * {@inheritDoc} This implementation returns {@code null}.
+ * {@inheritDoc}
+ *
+ * @implSpec This implementation returns {@code null}.
*
* @param node {@inheritDoc}
* @param p {@inheritDoc}
@@ -480,7 +537,9 @@ public R visitSystemProperty(SystemPropertyTree node, P p) {
}
/**
- * {@inheritDoc} This implementation returns {@code null}.
+ * {@inheritDoc}
+ *
+ * @implSpec This implementation returns {@code null}.
*
* @param node {@inheritDoc}
* @param p {@inheritDoc}
@@ -492,7 +551,9 @@ public R visitText(TextTree node, P p) {
}
/**
- * {@inheritDoc} This implementation scans the children in left to right order.
+ * {@inheritDoc}
+ *
+ * @implSpec This implementation scans the children in left to right order.
*
* @param node {@inheritDoc}
* @param p {@inheritDoc}
@@ -506,7 +567,9 @@ public R visitThrows(ThrowsTree node, P p) {
}
/**
- * {@inheritDoc} This implementation scans the children in left to right order.
+ * {@inheritDoc}
+ *
+ * @implSpec This implementation scans the children in left to right order.
*
* @param node {@inheritDoc}
* @param p {@inheritDoc}
@@ -518,7 +581,9 @@ public R visitUnknownBlockTag(UnknownBlockTagTree node, P p) {
}
/**
- * {@inheritDoc} This implementation scans the children in left to right order.
+ * {@inheritDoc}
+ *
+ * @implSpec This implementation scans the children in left to right order.
*
* @param node {@inheritDoc}
* @param p {@inheritDoc}
@@ -530,7 +595,9 @@ public R visitUnknownInlineTag(UnknownInlineTagTree node, P p) {
}
/**
- * {@inheritDoc} This implementation scans the children in left to right order.
+ * {@inheritDoc}
+ *
+ * @implSpec This implementation scans the children in left to right order.
*
* @param node {@inheritDoc}
* @param p {@inheritDoc}
@@ -544,7 +611,9 @@ public R visitUses(UsesTree node, P p) {
}
/**
- * {@inheritDoc} This implementation scans the children in left to right order.
+ * {@inheritDoc}
+ *
+ * @implSpec This implementation scans the children in left to right order.
*
* @param node {@inheritDoc}
* @param p {@inheritDoc}
@@ -556,7 +625,9 @@ public R visitValue(ValueTree node, P p) {
}
/**
- * {@inheritDoc} This implementation scans the children in left to right order.
+ * {@inheritDoc}
+ *
+ * @implSpec This implementation scans the children in left to right order.
*
* @param node {@inheritDoc}
* @param p {@inheritDoc}
@@ -568,7 +639,9 @@ public R visitVersion(VersionTree node, P p) {
}
/**
- * {@inheritDoc} This implementation returns {@code null}.
+ * {@inheritDoc}
+ *
+ * @implSpec This implementation returns {@code null}.
*
* @param node {@inheritDoc}
* @param p {@inheritDoc}
diff --git a/src/jdk.compiler/share/classes/com/sun/source/util/DocTrees.java b/src/jdk.compiler/share/classes/com/sun/source/util/DocTrees.java
index 60fd4b2..2c3c070 100644
--- a/src/jdk.compiler/share/classes/com/sun/source/util/DocTrees.java
+++ b/src/jdk.compiler/share/classes/com/sun/source/util/DocTrees.java
@@ -232,6 +232,7 @@ public abstract void printMessage(Diagnostic.Kind kind, CharSequence msg,
* 8.1.4. Character references
* in the HTML 5.2 specification.
*
+ * @param tree the tree containing the entity
* @return a string containing the characters
*/
public abstract String getCharacters(EntityTree tree);
diff --git a/src/jdk.compiler/share/classes/com/sun/source/util/SimpleDocTreeVisitor.java b/src/jdk.compiler/share/classes/com/sun/source/util/SimpleDocTreeVisitor.java
index 4fa7fd0..2461ac4 100644
--- a/src/jdk.compiler/share/classes/com/sun/source/util/SimpleDocTreeVisitor.java
+++ b/src/jdk.compiler/share/classes/com/sun/source/util/SimpleDocTreeVisitor.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 2020, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2021, 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
@@ -96,7 +96,9 @@ public final R visit(Iterable extends DocTree> nodes, P p) {
}
/**
- * {@inheritDoc} This implementation calls {@code defaultAction}.
+ * {@inheritDoc}
+ *
+ * @implSpec This implementation calls {@code defaultAction}.
*
* @param node {@inheritDoc}
* @param p {@inheritDoc}
@@ -108,7 +110,9 @@ public R visitAttribute(AttributeTree node, P p) {
}
/**
- * {@inheritDoc} This implementation calls {@code defaultAction}.
+ * {@inheritDoc}
+ *
+ * @implSpec This implementation calls {@code defaultAction}.
*
* @param node {@inheritDoc}
* @param p {@inheritDoc}
@@ -120,7 +124,9 @@ public R visitAuthor(AuthorTree node, P p) {
}
/**
- * {@inheritDoc} This implementation calls {@code defaultAction}.
+ * {@inheritDoc}
+ *
+ * @implSpec This implementation calls {@code defaultAction}.
*
* @param node {@inheritDoc}
* @param p {@inheritDoc}
@@ -132,7 +138,9 @@ public R visitComment(CommentTree node, P p) {
}
/**
- * {@inheritDoc} This implementation calls {@code defaultAction}.
+ * {@inheritDoc}
+ *
+ * @implSpec This implementation calls {@code defaultAction}.
*
* @param node {@inheritDoc}
* @param p {@inheritDoc}
@@ -144,7 +152,9 @@ public R visitDeprecated(DeprecatedTree node, P p) {
}
/**
- * {@inheritDoc} This implementation calls {@code defaultAction}.
+ * {@inheritDoc}
+ *
+ * @implSpec This implementation calls {@code defaultAction}.
*
* @param node {@inheritDoc}
* @param p {@inheritDoc}
@@ -156,7 +166,9 @@ public R visitDocComment(DocCommentTree node, P p) {
}
/**
- * {@inheritDoc} This implementation calls {@code defaultAction}.
+ * {@inheritDoc}
+ *
+ * @implSpec This implementation calls {@code defaultAction}.
*
* @param node {@inheritDoc}
* @param p {@inheritDoc}
@@ -181,7 +193,9 @@ public R visitDocRoot(DocRootTree node, P p) {
public R visitDocType(DocTypeTree node, P p) { return defaultAction(node, p); }
/**
- * {@inheritDoc} This implementation calls {@code defaultAction}.
+ * {@inheritDoc}
+ *
+ * @implSpec This implementation calls {@code defaultAction}.
*
* @param node {@inheritDoc}
* @param p {@inheritDoc}
@@ -191,7 +205,9 @@ public R visitDocRoot(DocRootTree node, P p) {
public R visitEndElement(EndElementTree node, P p) { return defaultAction(node, p);}
/**
- * {@inheritDoc} This implementation calls {@code defaultAction}.
+ * {@inheritDoc}
+ *
+ * @implSpec This implementation calls {@code defaultAction}.
*
* @param node {@inheritDoc}
* @param p {@inheritDoc}
@@ -203,7 +219,9 @@ public R visitEntity(EntityTree node, P p) {
}
/**
- * {@inheritDoc} This implementation calls {@code defaultAction}.
+ * {@inheritDoc}
+ *
+ * @implSpec This implementation calls {@code defaultAction}.
*
* @param node {@inheritDoc}
* @param p {@inheritDoc}
@@ -215,7 +233,9 @@ public R visitErroneous(ErroneousTree node, P p) {
}
/**
- * {@inheritDoc} This implementation calls {@code defaultAction}.
+ * {@inheritDoc}
+ *
+ * @implSpec This implementation calls {@code defaultAction}.
*
* @param node {@inheritDoc}
* @param p {@inheritDoc}
@@ -229,7 +249,9 @@ public R visitHidden(HiddenTree node, P p) {
}
/**
- * {@inheritDoc} This implementation calls {@code defaultAction}.
+ * {@inheritDoc}
+ *
+ * @implSpec This implementation calls {@code defaultAction}.
*
* @param node {@inheritDoc}
* @param p {@inheritDoc}
@@ -241,7 +263,9 @@ public R visitIdentifier(IdentifierTree node, P p) {
}
/**
- * {@inheritDoc} This implementation calls {@code defaultAction}.
+ * {@inheritDoc}
+ *
+ * @implSpec This implementation calls {@code defaultAction}.
*
* @param node {@inheritDoc}
* @param p {@inheritDoc}
@@ -255,7 +279,9 @@ public R visitIndex(IndexTree node, P p) {
}
/**
- * {@inheritDoc} This implementation calls {@code defaultAction}.
+ * {@inheritDoc}
+ *
+ * @implSpec This implementation calls {@code defaultAction}.
*
* @param node {@inheritDoc}
* @param p {@inheritDoc}
@@ -267,7 +293,9 @@ public R visitInheritDoc(InheritDocTree node, P p) {
}
/**
- * {@inheritDoc} This implementation calls {@code defaultAction}.
+ * {@inheritDoc}
+ *
+ * @implSpec This implementation calls {@code defaultAction}.
*
* @param node {@inheritDoc}
* @param p {@inheritDoc}
@@ -279,7 +307,9 @@ public R visitLink(LinkTree node, P p) {
}
/**
- * {@inheritDoc} This implementation calls {@code defaultAction}.
+ * {@inheritDoc}
+ *
+ * @implSpec This implementation calls {@code defaultAction}.
*
* @param node {@inheritDoc}
* @param p {@inheritDoc}
@@ -291,7 +321,9 @@ public R visitLiteral(LiteralTree node, P p) {
}
/**
- * {@inheritDoc} This implementation calls {@code defaultAction}.
+ * {@inheritDoc}
+ *
+ * @implSpec This implementation calls {@code defaultAction}.
*
* @param node {@inheritDoc}
* @param p {@inheritDoc}
@@ -303,7 +335,9 @@ public R visitParam(ParamTree node, P p) {
}
/**
- * {@inheritDoc} This implementation calls {@code defaultAction}.
+ * {@inheritDoc}
+ *
+ * @implSpec This implementation calls {@code defaultAction}.
*
* @param node {@inheritDoc}
* @param p {@inheritDoc}
@@ -317,7 +351,9 @@ public R visitProvides(ProvidesTree node, P p) {
}
/**
- * {@inheritDoc} This implementation calls {@code defaultAction}.
+ * {@inheritDoc}
+ *
+ * @implSpec This implementation calls {@code defaultAction}.
*
* @param node {@inheritDoc}
* @param p {@inheritDoc}
@@ -329,7 +365,9 @@ public R visitReference(ReferenceTree node, P p) {
}
/**
- * {@inheritDoc} This implementation calls {@code defaultAction}.
+ * {@inheritDoc}
+ *
+ * @implSpec This implementation calls {@code defaultAction}.
*
* @param node {@inheritDoc}
* @param p {@inheritDoc}
@@ -341,7 +379,9 @@ public R visitReturn(ReturnTree node, P p) {
}
/**
- * {@inheritDoc} This implementation calls {@code defaultAction}.
+ * {@inheritDoc}
+ *
+ * @implSpec This implementation calls {@code defaultAction}.
*
* @param node {@inheritDoc}
* @param p {@inheritDoc}
@@ -353,7 +393,9 @@ public R visitSee(SeeTree node, P p) {
}
/**
- * {@inheritDoc} This implementation calls {@code defaultAction}.
+ * {@inheritDoc}
+ *
+ * @implSpec This implementation calls {@code defaultAction}.
*
* @param node {@inheritDoc}
* @param p {@inheritDoc}
@@ -365,7 +407,9 @@ public R visitSerial(SerialTree node, P p) {
}
/**
- * {@inheritDoc} This implementation calls {@code defaultAction}.
+ * {@inheritDoc}
+ *
+ * @implSpec This implementation calls {@code defaultAction}.
*
* @param node {@inheritDoc}
* @param p {@inheritDoc}
@@ -377,7 +421,9 @@ public R visitSerialData(SerialDataTree node, P p) {
}
/**
- * {@inheritDoc} This implementation calls {@code defaultAction}.
+ * {@inheritDoc}
+ *
+ * @implSpec This implementation calls {@code defaultAction}.
*
* @param node {@inheritDoc}
* @param p {@inheritDoc}
@@ -389,7 +435,9 @@ public R visitSerialField(SerialFieldTree node, P p) {
}
/**
- * {@inheritDoc} This implementation calls {@code defaultAction}.
+ * {@inheritDoc}
+ *
+ * @implSpec This implementation calls {@code defaultAction}.
*
* @param node {@inheritDoc}
* @param p {@inheritDoc}
@@ -401,7 +449,9 @@ public R visitSince(SinceTree node, P p) {
}
/**
- * {@inheritDoc} This implementation calls {@code defaultAction}.
+ * {@inheritDoc}
+ *
+ * @implSpec This implementation calls {@code defaultAction}.
*
* @param node {@inheritDoc}
* @param p {@inheritDoc}
@@ -413,7 +463,9 @@ public R visitStartElement(StartElementTree node, P p) {
}
/**
- * {@inheritDoc} This implementation calls {@code defaultAction}.
+ * {@inheritDoc}
+ *
+ * @implSpec This implementation calls {@code defaultAction}.
*
* @param node {@inheritDoc}
* @param p {@inheritDoc}
@@ -426,7 +478,9 @@ public R visitSummary(SummaryTree node, P p) {
}
/**
- * {@inheritDoc} This implementation calls {@code defaultAction}.
+ * {@inheritDoc}
+ *
+ * @implSpec This implementation calls {@code defaultAction}.
*
* @param node {@inheritDoc}
* @param p {@inheritDoc}
@@ -439,7 +493,9 @@ public R visitSystemProperty(SystemPropertyTree node, P p) {
}
/**
- * {@inheritDoc} This implementation calls {@code defaultAction}.
+ * {@inheritDoc}
+ *
+ * @implSpec This implementation calls {@code defaultAction}.
*
* @param node {@inheritDoc}
* @param p {@inheritDoc}
@@ -451,7 +507,9 @@ public R visitText(TextTree node, P p) {
}
/**
- * {@inheritDoc} This implementation calls {@code defaultAction}.
+ * {@inheritDoc}
+ *
+ * @implSpec This implementation calls {@code defaultAction}.
*
* @param node {@inheritDoc}
* @param p {@inheritDoc}
@@ -463,7 +521,9 @@ public R visitThrows(ThrowsTree node, P p) {
}
/**
- * {@inheritDoc} This implementation calls {@code defaultAction}.
+ * {@inheritDoc}
+ *
+ * @implSpec This implementation calls {@code defaultAction}.
*
* @param node {@inheritDoc}
* @param p {@inheritDoc}
@@ -475,7 +535,9 @@ public R visitUnknownBlockTag(UnknownBlockTagTree node, P p) {
}
/**
- * {@inheritDoc} This implementation calls {@code defaultAction}.
+ * {@inheritDoc}
+ *
+ * @implSpec This implementation calls {@code defaultAction}.
*
* @param node {@inheritDoc}
* @param p {@inheritDoc}
@@ -487,7 +549,9 @@ public R visitUnknownInlineTag(UnknownInlineTagTree node, P p) {
}
/**
- * {@inheritDoc} This implementation calls {@code defaultAction}.
+ * {@inheritDoc}
+ *
+ * @implSpec This implementation calls {@code defaultAction}.
*
* @param node {@inheritDoc}
* @param p {@inheritDoc}
@@ -501,7 +565,9 @@ public R visitUses(UsesTree node, P p) {
}
/**
- * {@inheritDoc} This implementation calls {@code defaultAction}.
+ * {@inheritDoc}
+ *
+ * @implSpec This implementation calls {@code defaultAction}.
*
* @param node {@inheritDoc}
* @param p {@inheritDoc}
@@ -513,7 +579,9 @@ public R visitValue(ValueTree node, P p) {
}
/**
- * {@inheritDoc} This implementation calls {@code defaultAction}.
+ * {@inheritDoc}
+ *
+ * @implSpec This implementation calls {@code defaultAction}.
*
* @param node {@inheritDoc}
* @param p {@inheritDoc}
@@ -525,7 +593,9 @@ public R visitVersion(VersionTree node, P p) {
}
/**
- * {@inheritDoc} This implementation calls {@code defaultAction}.
+ * {@inheritDoc}
+ *
+ * @implSpec This implementation calls {@code defaultAction}.
*
* @param node {@inheritDoc}
* @param p {@inheritDoc}
diff --git a/src/jdk.compiler/share/classes/com/sun/source/util/SimpleTreeVisitor.java b/src/jdk.compiler/share/classes/com/sun/source/util/SimpleTreeVisitor.java
index 03ff696..d2fc692 100644
--- a/src/jdk.compiler/share/classes/com/sun/source/util/SimpleTreeVisitor.java
+++ b/src/jdk.compiler/share/classes/com/sun/source/util/SimpleTreeVisitor.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 2020, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2021, 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
@@ -26,6 +26,7 @@
package com.sun.source.util;
import com.sun.source.tree.*;
+import jdk.internal.PreviewFeature;
/**
* A simple visitor for tree nodes.
@@ -96,7 +97,9 @@ public final R visit(Iterable extends Tree> nodes, P p) {
}
/**
- * {@inheritDoc} This implementation calls {@code defaultAction}.
+ * {@inheritDoc}
+ *
+ * @implSpec This implementation calls {@code defaultAction}.
*
* @param node {@inheritDoc}
* @param p {@inheritDoc}
@@ -108,7 +111,9 @@ public R visitCompilationUnit(CompilationUnitTree node, P p) {
}
/**
- * {@inheritDoc} This implementation calls {@code defaultAction}.
+ * {@inheritDoc}
+ *
+ * @implSpec This implementation calls {@code defaultAction}.
*
* @param node {@inheritDoc}
* @param p {@inheritDoc}
@@ -120,7 +125,9 @@ public R visitPackage(PackageTree node, P p) {
}
/**
- * {@inheritDoc} This implementation calls {@code defaultAction}.
+ * {@inheritDoc}
+ *
+ * @implSpec This implementation calls {@code defaultAction}.
*
* @param node {@inheritDoc}
* @param p {@inheritDoc}
@@ -132,7 +139,9 @@ public R visitImport(ImportTree node, P p) {
}
/**
- * {@inheritDoc} This implementation calls {@code defaultAction}.
+ * {@inheritDoc}
+ *
+ * @implSpec This implementation calls {@code defaultAction}.
*
* @param node {@inheritDoc}
* @param p {@inheritDoc}
@@ -144,7 +153,9 @@ public R visitClass(ClassTree node, P p) {
}
/**
- * {@inheritDoc} This implementation calls {@code defaultAction}.
+ * {@inheritDoc}
+ *
+ * @implSpec This implementation calls {@code defaultAction}.
*
* @param node {@inheritDoc}
* @param p {@inheritDoc}
@@ -156,7 +167,9 @@ public R visitMethod(MethodTree node, P p) {
}
/**
- * {@inheritDoc} This implementation calls {@code defaultAction}.
+ * {@inheritDoc}
+ *
+ * @implSpec This implementation calls {@code defaultAction}.
*
* @param node {@inheritDoc}
* @param p {@inheritDoc}
@@ -168,7 +181,9 @@ public R visitVariable(VariableTree node, P p) {
}
/**
- * {@inheritDoc} This implementation calls {@code defaultAction}.
+ * {@inheritDoc}
+ *
+ * @implSpec This implementation calls {@code defaultAction}.
*
* @param node {@inheritDoc}
* @param p {@inheritDoc}
@@ -180,7 +195,9 @@ public R visitEmptyStatement(EmptyStatementTree node, P p) {
}
/**
- * {@inheritDoc} This implementation calls {@code defaultAction}.
+ * {@inheritDoc}
+ *
+ * @implSpec This implementation calls {@code defaultAction}.
*
* @param node {@inheritDoc}
* @param p {@inheritDoc}
@@ -192,7 +209,9 @@ public R visitBlock(BlockTree node, P p) {
}
/**
- * {@inheritDoc} This implementation calls {@code defaultAction}.
+ * {@inheritDoc}
+ *
+ * @implSpec This implementation calls {@code defaultAction}.
*
* @param node {@inheritDoc}
* @param p {@inheritDoc}
@@ -204,7 +223,9 @@ public R visitDoWhileLoop(DoWhileLoopTree node, P p) {
}
/**
- * {@inheritDoc} This implementation calls {@code defaultAction}.
+ * {@inheritDoc}
+ *
+ * @implSpec This implementation calls {@code defaultAction}.
*
* @param node {@inheritDoc}
* @param p {@inheritDoc}
@@ -216,7 +237,9 @@ public R visitWhileLoop(WhileLoopTree node, P p) {
}
/**
- * {@inheritDoc} This implementation calls {@code defaultAction}.
+ * {@inheritDoc}
+ *
+ * @implSpec This implementation calls {@code defaultAction}.
*
* @param node {@inheritDoc}
* @param p {@inheritDoc}
@@ -228,7 +251,9 @@ public R visitForLoop(ForLoopTree node, P p) {
}
/**
- * {@inheritDoc} This implementation calls {@code defaultAction}.
+ * {@inheritDoc}
+ *
+ * @implSpec This implementation calls {@code defaultAction}.
*
* @param node {@inheritDoc}
* @param p {@inheritDoc}
@@ -240,7 +265,9 @@ public R visitEnhancedForLoop(EnhancedForLoopTree node, P p) {
}
/**
- * {@inheritDoc} This implementation calls {@code defaultAction}.
+ * {@inheritDoc}
+ *
+ * @implSpec This implementation calls {@code defaultAction}.
*
* @param node {@inheritDoc}
* @param p {@inheritDoc}
@@ -252,7 +279,9 @@ public R visitLabeledStatement(LabeledStatementTree node, P p) {
}
/**
- * {@inheritDoc} This implementation calls {@code defaultAction}.
+ * {@inheritDoc}
+ *
+ * @implSpec This implementation calls {@code defaultAction}.
*
* @param node {@inheritDoc}
* @param p {@inheritDoc}
@@ -264,7 +293,9 @@ public R visitSwitch(SwitchTree node, P p) {
}
/**
- * {@inheritDoc} This implementation calls {@code defaultAction}.
+ * {@inheritDoc}
+ *
+ * @implSpec This implementation calls {@code defaultAction}.
*
* @param node {@inheritDoc}
* @param p {@inheritDoc}
@@ -276,7 +307,9 @@ public R visitSwitchExpression(SwitchExpressionTree node, P p) {
}
/**
- * {@inheritDoc} This implementation calls {@code defaultAction}.
+ * {@inheritDoc}
+ *
+ * @implSpec This implementation calls {@code defaultAction}.
*
* @param node {@inheritDoc}
* @param p {@inheritDoc}
@@ -288,7 +321,9 @@ public R visitCase(CaseTree node, P p) {
}
/**
- * {@inheritDoc} This implementation calls {@code defaultAction}.
+ * {@inheritDoc}
+ *
+ * @implSpec This implementation calls {@code defaultAction}.
*
* @param node {@inheritDoc}
* @param p {@inheritDoc}
@@ -300,7 +335,9 @@ public R visitSynchronized(SynchronizedTree node, P p) {
}
/**
- * {@inheritDoc} This implementation calls {@code defaultAction}.
+ * {@inheritDoc}
+ *
+ * @implSpec This implementation calls {@code defaultAction}.
*
* @param node {@inheritDoc}
* @param p {@inheritDoc}
@@ -312,7 +349,9 @@ public R visitTry(TryTree node, P p) {
}
/**
- * {@inheritDoc} This implementation calls {@code defaultAction}.
+ * {@inheritDoc}
+ *
+ * @implSpec This implementation calls {@code defaultAction}.
*
* @param node {@inheritDoc}
* @param p {@inheritDoc}
@@ -324,7 +363,9 @@ public R visitCatch(CatchTree node, P p) {
}
/**
- * {@inheritDoc} This implementation calls {@code defaultAction}.
+ * {@inheritDoc}
+ *
+ * @implSpec This implementation calls {@code defaultAction}.
*
* @param node {@inheritDoc}
* @param p {@inheritDoc}
@@ -336,7 +377,9 @@ public R visitConditionalExpression(ConditionalExpressionTree node, P p) {
}
/**
- * {@inheritDoc} This implementation calls {@code defaultAction}.
+ * {@inheritDoc}
+ *
+ * @implSpec This implementation calls {@code defaultAction}.
*
* @param node {@inheritDoc}
* @param p {@inheritDoc}
@@ -348,7 +391,9 @@ public R visitIf(IfTree node, P p) {
}
/**
- * {@inheritDoc} This implementation calls {@code defaultAction}.
+ * {@inheritDoc}
+ *
+ * @implSpec This implementation calls {@code defaultAction}.
*
* @param node {@inheritDoc}
* @param p {@inheritDoc}
@@ -360,7 +405,9 @@ public R visitExpressionStatement(ExpressionStatementTree node, P p) {
}
/**
- * {@inheritDoc} This implementation calls {@code defaultAction}.
+ * {@inheritDoc}
+ *
+ * @implSpec This implementation calls {@code defaultAction}.
*
* @param node {@inheritDoc}
* @param p {@inheritDoc}
@@ -372,7 +419,9 @@ public R visitBreak(BreakTree node, P p) {
}
/**
- * {@inheritDoc} This implementation calls {@code defaultAction}.
+ * {@inheritDoc}
+ *
+ * @implSpec This implementation calls {@code defaultAction}.
*
* @param node {@inheritDoc}
* @param p {@inheritDoc}
@@ -384,7 +433,9 @@ public R visitContinue(ContinueTree node, P p) {
}
/**
- * {@inheritDoc} This implementation calls {@code defaultAction}.
+ * {@inheritDoc}
+ *
+ * @implSpec This implementation calls {@code defaultAction}.
*
* @param node {@inheritDoc}
* @param p {@inheritDoc}
@@ -396,7 +447,9 @@ public R visitReturn(ReturnTree node, P p) {
}
/**
- * {@inheritDoc} This implementation calls {@code defaultAction}.
+ * {@inheritDoc}
+ *
+ * @implSpec This implementation calls {@code defaultAction}.
*
* @param node {@inheritDoc}
* @param p {@inheritDoc}
@@ -408,7 +461,9 @@ public R visitThrow(ThrowTree node, P p) {
}
/**
- * {@inheritDoc} This implementation calls {@code defaultAction}.
+ * {@inheritDoc}
+ *
+ * @implSpec This implementation calls {@code defaultAction}.
*
* @param node {@inheritDoc}
* @param p {@inheritDoc}
@@ -420,7 +475,9 @@ public R visitAssert(AssertTree node, P p) {
}
/**
- * {@inheritDoc} This implementation calls {@code defaultAction}.
+ * {@inheritDoc}
+ *
+ * @implSpec This implementation calls {@code defaultAction}.
*
* @param node {@inheritDoc}
* @param p {@inheritDoc}
@@ -432,7 +489,9 @@ public R visitMethodInvocation(MethodInvocationTree node, P p) {
}
/**
- * {@inheritDoc} This implementation calls {@code defaultAction}.
+ * {@inheritDoc}
+ *
+ * @implSpec This implementation calls {@code defaultAction}.
*
* @param node {@inheritDoc}
* @param p {@inheritDoc}
@@ -444,7 +503,9 @@ public R visitNewClass(NewClassTree node, P p) {
}
/**
- * {@inheritDoc} This implementation calls {@code defaultAction}.
+ * {@inheritDoc}
+ *
+ * @implSpec This implementation calls {@code defaultAction}.
*
* @param node {@inheritDoc}
* @param p {@inheritDoc}
@@ -456,7 +517,9 @@ public R visitNewArray(NewArrayTree node, P p) {
}
/**
- * {@inheritDoc} This implementation calls {@code defaultAction}.
+ * {@inheritDoc}
+ *
+ * @implSpec This implementation calls {@code defaultAction}.
*
* @param node {@inheritDoc}
* @param p {@inheritDoc}
@@ -468,7 +531,9 @@ public R visitLambdaExpression(LambdaExpressionTree node, P p) {
}
/**
- * {@inheritDoc} This implementation calls {@code defaultAction}.
+ * {@inheritDoc}
+ *
+ * @implSpec This implementation calls {@code defaultAction}.
*
* @param node {@inheritDoc}
* @param p {@inheritDoc}
@@ -480,7 +545,9 @@ public R visitParenthesized(ParenthesizedTree node, P p) {
}
/**
- * {@inheritDoc} This implementation calls {@code defaultAction}.
+ * {@inheritDoc}
+ *
+ * @implSpec This implementation calls {@code defaultAction}.
*
* @param node {@inheritDoc}
* @param p {@inheritDoc}
@@ -492,7 +559,9 @@ public R visitAssignment(AssignmentTree node, P p) {
}
/**
- * {@inheritDoc} This implementation calls {@code defaultAction}.
+ * {@inheritDoc}
+ *
+ * @implSpec This implementation calls {@code defaultAction}.
*
* @param node {@inheritDoc}
* @param p {@inheritDoc}
@@ -504,7 +573,9 @@ public R visitCompoundAssignment(CompoundAssignmentTree node, P p) {
}
/**
- * {@inheritDoc} This implementation calls {@code defaultAction}.
+ * {@inheritDoc}
+ *
+ * @implSpec This implementation calls {@code defaultAction}.
*
* @param node {@inheritDoc}
* @param p {@inheritDoc}
@@ -516,7 +587,9 @@ public R visitUnary(UnaryTree node, P p) {
}
/**
- * {@inheritDoc} This implementation calls {@code defaultAction}.
+ * {@inheritDoc}
+ *
+ * @implSpec This implementation calls {@code defaultAction}.
*
* @param node {@inheritDoc}
* @param p {@inheritDoc}
@@ -528,7 +601,9 @@ public R visitBinary(BinaryTree node, P p) {
}
/**
- * {@inheritDoc} This implementation calls {@code defaultAction}.
+ * {@inheritDoc}
+ *
+ * @implSpec This implementation calls {@code defaultAction}.
*
* @param node {@inheritDoc}
* @param p {@inheritDoc}
@@ -540,7 +615,9 @@ public R visitTypeCast(TypeCastTree node, P p) {
}
/**
- * {@inheritDoc} This implementation calls {@code defaultAction}.
+ * {@inheritDoc}
+ *
+ * @implSpec This implementation calls {@code defaultAction}.
*
* @param node {@inheritDoc}
* @param p {@inheritDoc}
@@ -552,7 +629,9 @@ public R visitInstanceOf(InstanceOfTree node, P p) {
}
/**
- * {@inheritDoc} This implementation calls {@code defaultAction}.
+ * {@inheritDoc}
+ *
+ * @implSpec This implementation calls {@code defaultAction}.
*
* @param node {@inheritDoc}
* @param p {@inheritDoc}
@@ -565,7 +644,25 @@ public R visitBindingPattern(BindingPatternTree node, P p) {
}
/**
- * {@inheritDoc} This implementation calls {@code defaultAction}.
+ * {@inheritDoc}
+ *
+ * @implSpec This implementation calls {@code defaultAction}.
+ *
+ * @param node {@inheritDoc}
+ * @param p {@inheritDoc}
+ * @return the result of {@code defaultAction}
+ * @since 17
+ */
+ @Override
+ @PreviewFeature(feature=PreviewFeature.Feature.SWITCH_PATTERN_MATCHING, reflective=true)
+ public R visitDefaultCaseLabel(DefaultCaseLabelTree node, P p) {
+ return defaultAction(node, p);
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @implSpec This implementation calls {@code defaultAction}.
*
* @param node {@inheritDoc}
* @param p {@inheritDoc}
@@ -577,7 +674,9 @@ public R visitArrayAccess(ArrayAccessTree node, P p) {
}
/**
- * {@inheritDoc} This implementation calls {@code defaultAction}.
+ * {@inheritDoc}
+ *
+ * @implSpec This implementation calls {@code defaultAction}.
*
* @param node {@inheritDoc}
* @param p {@inheritDoc}
@@ -589,7 +688,41 @@ public R visitMemberSelect(MemberSelectTree node, P p) {
}
/**
- * {@inheritDoc} This implementation calls {@code defaultAction}.
+ * {@inheritDoc}
+ *
+ * @implSpec This implementation calls {@code defaultAction}.
+ *
+ * @param node {@inheritDoc}
+ * @param p {@inheritDoc}
+ * @return the result of {@code defaultAction}
+ * @since 17
+ */
+ @Override
+ @PreviewFeature(feature=PreviewFeature.Feature.SWITCH_PATTERN_MATCHING, reflective=true)
+ public R visitParenthesizedPattern(ParenthesizedPatternTree node, P p) {
+ return defaultAction(node, p);
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @implSpec This implementation calls {@code defaultAction}.
+ *
+ * @param node {@inheritDoc}
+ * @param p {@inheritDoc}
+ * @return the result of {@code defaultAction}
+ * @since 17
+ */
+ @Override
+ @PreviewFeature(feature=PreviewFeature.Feature.SWITCH_PATTERN_MATCHING, reflective=true)
+ public R visitGuardedPattern(GuardedPatternTree node, P p) {
+ return defaultAction(node, p);
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @implSpec This implementation calls {@code defaultAction}.
*
* @param node {@inheritDoc}
* @param p {@inheritDoc}
@@ -601,7 +734,9 @@ public R visitMemberReference(MemberReferenceTree node, P p) {
}
/**
- * {@inheritDoc} This implementation calls {@code defaultAction}.
+ * {@inheritDoc}
+ *
+ * @implSpec This implementation calls {@code defaultAction}.
*
* @param node {@inheritDoc}
* @param p {@inheritDoc}
@@ -613,7 +748,9 @@ public R visitIdentifier(IdentifierTree node, P p) {
}
/**
- * {@inheritDoc} This implementation calls {@code defaultAction}.
+ * {@inheritDoc}
+ *
+ * @implSpec This implementation calls {@code defaultAction}.
*
* @param node {@inheritDoc}
* @param p {@inheritDoc}
@@ -625,7 +762,9 @@ public R visitLiteral(LiteralTree node, P p) {
}
/**
- * {@inheritDoc} This implementation calls {@code defaultAction}.
+ * {@inheritDoc}
+ *
+ * @implSpec This implementation calls {@code defaultAction}.
*
* @param node {@inheritDoc}
* @param p {@inheritDoc}
@@ -637,7 +776,9 @@ public R visitPrimitiveType(PrimitiveTypeTree node, P p) {
}
/**
- * {@inheritDoc} This implementation calls {@code defaultAction}.
+ * {@inheritDoc}
+ *
+ * @implSpec This implementation calls {@code defaultAction}.
*
* @param node {@inheritDoc}
* @param p {@inheritDoc}
@@ -649,7 +790,9 @@ public R visitArrayType(ArrayTypeTree node, P p) {
}
/**
- * {@inheritDoc} This implementation calls {@code defaultAction}.
+ * {@inheritDoc}
+ *
+ * @implSpec This implementation calls {@code defaultAction}.
*
* @param node {@inheritDoc}
* @param p {@inheritDoc}
@@ -661,7 +804,9 @@ public R visitParameterizedType(ParameterizedTypeTree node, P p) {
}
/**
- * {@inheritDoc} This implementation calls {@code defaultAction}.
+ * {@inheritDoc}
+ *
+ * @implSpec This implementation calls {@code defaultAction}.
*
* @param node {@inheritDoc}
* @param p {@inheritDoc}
@@ -673,7 +818,9 @@ public R visitUnionType(UnionTypeTree node, P p) {
}
/**
- * {@inheritDoc} This implementation calls {@code defaultAction}.
+ * {@inheritDoc}
+ *
+ * @implSpec This implementation calls {@code defaultAction}.
*
* @param node {@inheritDoc}
* @param p {@inheritDoc}
@@ -685,7 +832,9 @@ public R visitIntersectionType(IntersectionTypeTree node, P p) {
}
/**
- * {@inheritDoc} This implementation calls {@code defaultAction}.
+ * {@inheritDoc}
+ *
+ * @implSpec This implementation calls {@code defaultAction}.
*
* @param node {@inheritDoc}
* @param p {@inheritDoc}
@@ -697,7 +846,9 @@ public R visitTypeParameter(TypeParameterTree node, P p) {
}
/**
- * {@inheritDoc} This implementation calls {@code defaultAction}.
+ * {@inheritDoc}
+ *
+ * @implSpec This implementation calls {@code defaultAction}.
*
* @param node {@inheritDoc}
* @param p {@inheritDoc}
@@ -709,7 +860,9 @@ public R visitWildcard(WildcardTree node, P p) {
}
/**
- * {@inheritDoc} This implementation calls {@code defaultAction}.
+ * {@inheritDoc}
+ *
+ * @implSpec This implementation calls {@code defaultAction}.
*
* @param node {@inheritDoc}
* @param p {@inheritDoc}
@@ -721,7 +874,9 @@ public R visitModifiers(ModifiersTree node, P p) {
}
/**
- * {@inheritDoc} This implementation calls {@code defaultAction}.
+ * {@inheritDoc}
+ *
+ * @implSpec This implementation calls {@code defaultAction}.
*
* @param node {@inheritDoc}
* @param p {@inheritDoc}
@@ -733,7 +888,9 @@ public R visitAnnotation(AnnotationTree node, P p) {
}
/**
- * {@inheritDoc} This implementation calls {@code defaultAction}.
+ * {@inheritDoc}
+ *
+ * @implSpec This implementation calls {@code defaultAction}.
*
* @param node {@inheritDoc}
* @param p {@inheritDoc}
@@ -744,41 +901,108 @@ public R visitAnnotatedType(AnnotatedTypeTree node, P p) {
return defaultAction(node, p);
}
+ /**
+ * {@inheritDoc}
+ *
+ * @implSpec This implementation calls {@code defaultAction}.
+ *
+ * @param node {@inheritDoc}
+ * @param p {@inheritDoc}
+ * @return the result of {@code defaultAction}
+ */
+ @Override
public R visitModule(ModuleTree node, P p) {
return defaultAction(node, p);
}
+ /**
+ * {@inheritDoc}
+ *
+ * @implSpec This implementation calls {@code defaultAction}.
+ *
+ * @param node {@inheritDoc}
+ * @param p {@inheritDoc}
+ * @return the result of {@code defaultAction}
+ */
@Override
public R visitExports(ExportsTree node, P p) {
return defaultAction(node, p);
}
+ /**
+ * {@inheritDoc}
+ *
+ * @implSpec This implementation calls {@code defaultAction}.
+ *
+ * @param node {@inheritDoc}
+ * @param p {@inheritDoc}
+ * @return the result of {@code defaultAction}
+ */
@Override
public R visitOpens(OpensTree node, P p) {
return defaultAction(node, p);
}
+ /**
+ * {@inheritDoc}
+ *
+ * @implSpec This implementation calls {@code defaultAction}.
+ *
+ * @param node {@inheritDoc}
+ * @param p {@inheritDoc}
+ * @return the result of {@code defaultAction}
+ */
@Override
public R visitProvides(ProvidesTree node, P p) {
return defaultAction(node, p);
}
+ /**
+ * {@inheritDoc}
+ *
+ * @implSpec This implementation calls {@code defaultAction}.
+ *
+ * @param node {@inheritDoc}
+ * @param p {@inheritDoc}
+ * @return the result of {@code defaultAction}
+ */
@Override
public R visitRequires(RequiresTree node, P p) {
return defaultAction(node, p);
}
+ /**
+ * {@inheritDoc}
+ *
+ * @implSpec This implementation calls {@code defaultAction}.
+ *
+ * @param node {@inheritDoc}
+ * @param p {@inheritDoc}
+ * @return the result of {@code defaultAction}
+ */
@Override
public R visitUses(UsesTree node, P p) {
return defaultAction(node, p);
}
+ /**
+ * {@inheritDoc}
+ *
+ * @implSpec This implementation calls {@code defaultAction}.
+ *
+ * @param node {@inheritDoc}
+ * @param p {@inheritDoc}
+ * @return the result of {@code defaultAction}
+ */
+ @Override
public R visitErroneous(ErroneousTree node, P p) {
return defaultAction(node, p);
}
/**
- * {@inheritDoc} This implementation calls {@code defaultAction}.
+ * {@inheritDoc}
+ *
+ * @implSpec This implementation calls {@code defaultAction}.
*
* @param node {@inheritDoc}
* @param p {@inheritDoc}
@@ -790,7 +1014,9 @@ public R visitOther(Tree node, P p) {
}
/**
- * {@inheritDoc} This implementation calls {@code defaultAction}.
+ * {@inheritDoc}
+ *
+ * @implSpec This implementation calls {@code defaultAction}.
*
* @param node {@inheritDoc}
* @param p {@inheritDoc}
diff --git a/src/jdk.compiler/share/classes/com/sun/source/util/TreePath.java b/src/jdk.compiler/share/classes/com/sun/source/util/TreePath.java
index 6b7f0b2..be98551 100644
--- a/src/jdk.compiler/share/classes/com/sun/source/util/TreePath.java
+++ b/src/jdk.compiler/share/classes/com/sun/source/util/TreePath.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2006, 2020, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2021, 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
@@ -33,7 +33,7 @@
/**
* A path of tree nodes, typically used to represent the sequence of ancestor
- * nodes of a tree node up to the top level CompilationUnitTree node.
+ * nodes of a tree node up to the top-level {@code CompilationUnitTree} node.
*
* @author Jonathan Gibbons
* @since 1.6
diff --git a/src/jdk.compiler/share/classes/com/sun/source/util/TreeScanner.java b/src/jdk.compiler/share/classes/com/sun/source/util/TreeScanner.java
index a606c6d..f60272d 100644
--- a/src/jdk.compiler/share/classes/com/sun/source/util/TreeScanner.java
+++ b/src/jdk.compiler/share/classes/com/sun/source/util/TreeScanner.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 2020, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2021, 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
@@ -26,6 +26,7 @@
package com.sun.source.util;
import com.sun.source.tree.*;
+import jdk.internal.PreviewFeature;
/**
* A TreeVisitor that visits all the child tree nodes.
@@ -34,22 +35,6 @@
* Inside your method, call super.visitXYZ to visit descendant
* nodes.
*
- *
The default implementation of the visitXYZ methods will determine
- * a result as follows:
- *
- *
If the node being visited has no children, the result will be {@code null}.
- *
If the node being visited has one child, the result will be the
- * result of calling {@code scan} on that child. The child may be a simple node
- * or itself a list of nodes.
- *
If the node being visited has more than one child, the result will
- * be determined by calling {@code scan} each child in turn, and then combining the
- * result of each scan after the first with the cumulative result
- * so far, as determined by the {@link #reduce} method. Each child may be either
- * a simple node of a list of nodes. The default behavior of the {@code reduce}
- * method is such that the result of the visitXYZ method will be the result of
- * the last child scanned.
- *
- *
*
Here is an example to count the number of identifier nodes in a tree:
*
The default implementation of the visitXYZ methods will determine
+ * a result as follows:
+ *
+ *
If the node being visited has no children, the result will be {@code null}.
+ *
If the node being visited has one child, the result will be the
+ * result of calling {@code scan} with that child. The child may be a simple node
+ * or itself a list of nodes.
+ *
If the node being visited has more than one child, the result will
+ * be determined by calling {@code scan} with each child in turn, and then combining the
+ * result of each scan after the first with the cumulative result
+ * so far, as determined by the {@link #reduce} method. Each child may be either
+ * a simple node or a list of nodes. The default behavior of the {@code reduce}
+ * method is such that the result of the visitXYZ method will be the result of
+ * the last child scanned.
+ *
+ *
* @param the return type of this visitor's methods. Use {@link
* Void} for visitors that do not need to return results.
* @param
the type of the additional parameter to this visitor's
@@ -135,7 +137,9 @@ public R reduce(R r1, R r2) {
****************************************************************************/
/**
- * {@inheritDoc} This implementation scans the children in left to right order.
+ * {@inheritDoc}
+ *
+ * @implSpec This implementation scans the children in left to right order.
*
* @param node {@inheritDoc}
* @param p {@inheritDoc}
@@ -146,11 +150,14 @@ public R visitCompilationUnit(CompilationUnitTree node, P p) {
R r = scan(node.getPackage(), p);
r = scanAndReduce(node.getImports(), p, r);
r = scanAndReduce(node.getTypeDecls(), p, r);
+ r = scanAndReduce(node.getModule(), p, r);
return r;
}
/**
- * {@inheritDoc} This implementation scans the children in left to right order.
+ * {@inheritDoc}
+ *
+ * @implSpec This implementation scans the children in left to right order.
*
* @param node {@inheritDoc}
* @param p {@inheritDoc}
@@ -164,7 +171,9 @@ public R visitPackage(PackageTree node, P p) {
}
/**
- * {@inheritDoc} This implementation scans the children in left to right order.
+ * {@inheritDoc}
+ *
+ * @implSpec This implementation scans the children in left to right order.
*
* @param node {@inheritDoc}
* @param p {@inheritDoc}
@@ -176,13 +185,14 @@ public R visitImport(ImportTree node, P p) {
}
/**
- * {@inheritDoc} This implementation scans the children in left to right order.
+ * {@inheritDoc}
+ *
+ * @implSpec This implementation scans the children in left to right order.
*
* @param node {@inheritDoc}
* @param p {@inheritDoc}
* @return the result of scanning
*/
- @SuppressWarnings("preview")
@Override
public R visitClass(ClassTree node, P p) {
R r = scan(node.getModifiers(), p);
@@ -195,7 +205,9 @@ public R visitClass(ClassTree node, P p) {
}
/**
- * {@inheritDoc} This implementation scans the children in left to right order.
+ * {@inheritDoc}
+ *
+ * @implSpec This implementation scans the children in left to right order.
*
* @param node {@inheritDoc}
* @param p {@inheritDoc}
@@ -215,7 +227,9 @@ public R visitMethod(MethodTree node, P p) {
}
/**
- * {@inheritDoc} This implementation scans the children in left to right order.
+ * {@inheritDoc}
+ *
+ * @implSpec This implementation scans the children in left to right order.
*
* @param node {@inheritDoc}
* @param p {@inheritDoc}
@@ -231,7 +245,9 @@ public R visitVariable(VariableTree node, P p) {
}
/**
- * {@inheritDoc} This implementation returns {@code null}.
+ * {@inheritDoc}
+ *
+ * @implSpec This implementation returns {@code null}.
*
* @param node {@inheritDoc}
* @param p {@inheritDoc}
@@ -243,7 +259,9 @@ public R visitEmptyStatement(EmptyStatementTree node, P p) {
}
/**
- * {@inheritDoc} This implementation scans the children in left to right order.
+ * {@inheritDoc}
+ *
+ * @implSpec This implementation scans the children in left to right order.
*
* @param node {@inheritDoc}
* @param p {@inheritDoc}
@@ -255,7 +273,9 @@ public R visitBlock(BlockTree node, P p) {
}
/**
- * {@inheritDoc} This implementation scans the children in left to right order.
+ * {@inheritDoc}
+ *
+ * @implSpec This implementation scans the children in left to right order.
*
* @param node {@inheritDoc}
* @param p {@inheritDoc}
@@ -269,7 +289,9 @@ public R visitDoWhileLoop(DoWhileLoopTree node, P p) {
}
/**
- * {@inheritDoc} This implementation scans the children in left to right order.
+ * {@inheritDoc}
+ *
+ * @implSpec This implementation scans the children in left to right order.
*
* @param node {@inheritDoc}
* @param p {@inheritDoc}
@@ -283,7 +305,9 @@ public R visitWhileLoop(WhileLoopTree node, P p) {
}
/**
- * {@inheritDoc} This implementation scans the children in left to right order.
+ * {@inheritDoc}
+ *
+ * @implSpec This implementation scans the children in left to right order.
*
* @param node {@inheritDoc}
* @param p {@inheritDoc}
@@ -299,7 +323,9 @@ public R visitForLoop(ForLoopTree node, P p) {
}
/**
- * {@inheritDoc} This implementation scans the children in left to right order.
+ * {@inheritDoc}
+ *
+ * @implSpec This implementation scans the children in left to right order.
*
* @param node {@inheritDoc}
* @param p {@inheritDoc}
@@ -314,7 +340,9 @@ public R visitEnhancedForLoop(EnhancedForLoopTree node, P p) {
}
/**
- * {@inheritDoc} This implementation scans the children in left to right order.
+ * {@inheritDoc}
+ *
+ * @implSpec This implementation scans the children in left to right order.
*
* @param node {@inheritDoc}
* @param p {@inheritDoc}
@@ -326,7 +354,9 @@ public R visitLabeledStatement(LabeledStatementTree node, P p) {
}
/**
- * {@inheritDoc} This implementation scans the children in left to right order.
+ * {@inheritDoc}
+ *
+ * @implSpec This implementation scans the children in left to right order.
*
* @param node {@inheritDoc}
* @param p {@inheritDoc}
@@ -340,7 +370,9 @@ public R visitSwitch(SwitchTree node, P p) {
}
/**
- * {@inheritDoc} This implementation scans the children in left to right order.
+ * {@inheritDoc}
+ *
+ * @implSpec This implementation scans the children in left to right order.
*
* @param node {@inheritDoc}
* @param p {@inheritDoc}
@@ -354,7 +386,9 @@ public R visitSwitchExpression(SwitchExpressionTree node, P p) {
}
/**
- * {@inheritDoc} This implementation scans the children in left to right order.
+ * {@inheritDoc}
+ *
+ * @implSpec This implementation scans the children in left to right order.
*
* @param node {@inheritDoc}
* @param p {@inheritDoc}
@@ -371,7 +405,9 @@ public R visitCase(CaseTree node, P p) {
}
/**
- * {@inheritDoc} This implementation scans the children in left to right order.
+ * {@inheritDoc}
+ *
+ * @implSpec This implementation scans the children in left to right order.
*
* @param node {@inheritDoc}
* @param p {@inheritDoc}
@@ -385,7 +421,9 @@ public R visitSynchronized(SynchronizedTree node, P p) {
}
/**
- * {@inheritDoc} This implementation scans the children in left to right order.
+ * {@inheritDoc}
+ *
+ * @implSpec This implementation scans the children in left to right order.
*
* @param node {@inheritDoc}
* @param p {@inheritDoc}
@@ -401,7 +439,9 @@ public R visitTry(TryTree node, P p) {
}
/**
- * {@inheritDoc} This implementation scans the children in left to right order.
+ * {@inheritDoc}
+ *
+ * @implSpec This implementation scans the children in left to right order.
*
* @param node {@inheritDoc}
* @param p {@inheritDoc}
@@ -415,7 +455,9 @@ public R visitCatch(CatchTree node, P p) {
}
/**
- * {@inheritDoc} This implementation scans the children in left to right order.
+ * {@inheritDoc}
+ *
+ * @implSpec This implementation scans the children in left to right order.
*
* @param node {@inheritDoc}
* @param p {@inheritDoc}
@@ -430,7 +472,9 @@ public R visitConditionalExpression(ConditionalExpressionTree node, P p) {
}
/**
- * {@inheritDoc} This implementation scans the children in left to right order.
+ * {@inheritDoc}
+ *
+ * @implSpec This implementation scans the children in left to right order.
*
* @param node {@inheritDoc}
* @param p {@inheritDoc}
@@ -445,7 +489,9 @@ public R visitIf(IfTree node, P p) {
}
/**
- * {@inheritDoc} This implementation scans the children in left to right order.
+ * {@inheritDoc}
+ *
+ * @implSpec This implementation scans the children in left to right order.
*
* @param node {@inheritDoc}
* @param p {@inheritDoc}
@@ -457,7 +503,9 @@ public R visitExpressionStatement(ExpressionStatementTree node, P p) {
}
/**
- * {@inheritDoc} This implementation returns {@code null}.
+ * {@inheritDoc}
+ *
+ * @implSpec This implementation returns {@code null}.
*
* @param node {@inheritDoc}
* @param p {@inheritDoc}
@@ -469,7 +517,9 @@ public R visitBreak(BreakTree node, P p) {
}
/**
- * {@inheritDoc} This implementation returns {@code null}.
+ * {@inheritDoc}
+ *
+ * @implSpec This implementation returns {@code null}.
*
* @param node {@inheritDoc}
* @param p {@inheritDoc}
@@ -481,7 +531,9 @@ public R visitContinue(ContinueTree node, P p) {
}
/**
- * {@inheritDoc} This implementation scans the children in left to right order.
+ * {@inheritDoc}
+ *
+ * @implSpec This implementation scans the children in left to right order.
*
* @param node {@inheritDoc}
* @param p {@inheritDoc}
@@ -493,7 +545,9 @@ public R visitReturn(ReturnTree node, P p) {
}
/**
- * {@inheritDoc} This implementation scans the children in left to right order.
+ * {@inheritDoc}
+ *
+ * @implSpec This implementation scans the children in left to right order.
*
* @param node {@inheritDoc}
* @param p {@inheritDoc}
@@ -505,7 +559,9 @@ public R visitThrow(ThrowTree node, P p) {
}
/**
- * {@inheritDoc} This implementation scans the children in left to right order.
+ * {@inheritDoc}
+ *
+ * @implSpec This implementation scans the children in left to right order.
*
* @param node {@inheritDoc}
* @param p {@inheritDoc}
@@ -519,7 +575,9 @@ public R visitAssert(AssertTree node, P p) {
}
/**
- * {@inheritDoc} This implementation scans the children in left to right order.
+ * {@inheritDoc}
+ *
+ * @implSpec This implementation scans the children in left to right order.
*
* @param node {@inheritDoc}
* @param p {@inheritDoc}
@@ -534,7 +592,9 @@ public R visitMethodInvocation(MethodInvocationTree node, P p) {
}
/**
- * {@inheritDoc} This implementation scans the children in left to right order.
+ * {@inheritDoc}
+ *
+ * @implSpec This implementation scans the children in left to right order.
*
* @param node {@inheritDoc}
* @param p {@inheritDoc}
@@ -551,7 +611,9 @@ public R visitNewClass(NewClassTree node, P p) {
}
/**
- * {@inheritDoc} This implementation scans the children in left to right order.
+ * {@inheritDoc}
+ *
+ * @implSpec This implementation scans the children in left to right order.
*
* @param node {@inheritDoc}
* @param p {@inheritDoc}
@@ -570,7 +632,9 @@ public R visitNewArray(NewArrayTree node, P p) {
}
/**
- * {@inheritDoc} This implementation scans the children in left to right order.
+ * {@inheritDoc}
+ *
+ * @implSpec This implementation scans the children in left to right order.
*
* @param node {@inheritDoc}
* @param p {@inheritDoc}
@@ -584,7 +648,9 @@ public R visitLambdaExpression(LambdaExpressionTree node, P p) {
}
/**
- * {@inheritDoc} This implementation scans the children in left to right order.
+ * {@inheritDoc}
+ *
+ * @implSpec This implementation scans the children in left to right order.
*
* @param node {@inheritDoc}
* @param p {@inheritDoc}
@@ -596,7 +662,9 @@ public R visitParenthesized(ParenthesizedTree node, P p) {
}
/**
- * {@inheritDoc} This implementation scans the children in left to right order.
+ * {@inheritDoc}
+ *
+ * @implSpec This implementation scans the children in left to right order.
*
* @param node {@inheritDoc}
* @param p {@inheritDoc}
@@ -610,7 +678,9 @@ public R visitAssignment(AssignmentTree node, P p) {
}
/**
- * {@inheritDoc} This implementation scans the children in left to right order.
+ * {@inheritDoc}
+ *
+ * @implSpec This implementation scans the children in left to right order.
*
* @param node {@inheritDoc}
* @param p {@inheritDoc}
@@ -624,7 +694,9 @@ public R visitCompoundAssignment(CompoundAssignmentTree node, P p) {
}
/**
- * {@inheritDoc} This implementation scans the children in left to right order.
+ * {@inheritDoc}
+ *
+ * @implSpec This implementation scans the children in left to right order.
*
* @param node {@inheritDoc}
* @param p {@inheritDoc}
@@ -636,7 +708,9 @@ public R visitUnary(UnaryTree node, P p) {
}
/**
- * {@inheritDoc} This implementation scans the children in left to right order.
+ * {@inheritDoc}
+ *
+ * @implSpec This implementation scans the children in left to right order.
*
* @param node {@inheritDoc}
* @param p {@inheritDoc}
@@ -650,7 +724,9 @@ public R visitBinary(BinaryTree node, P p) {
}
/**
- * {@inheritDoc} This implementation scans the children in left to right order.
+ * {@inheritDoc}
+ *
+ * @implSpec This implementation scans the children in left to right order.
*
* @param node {@inheritDoc}
* @param p {@inheritDoc}
@@ -664,7 +740,9 @@ public R visitTypeCast(TypeCastTree node, P p) {
}
/**
- * {@inheritDoc} This implementation scans the children in left to right order.
+ * {@inheritDoc}
+ *
+ * @implSpec This implementation scans the children in left to right order.
*
* @param node {@inheritDoc}
* @param p {@inheritDoc}
@@ -682,7 +760,9 @@ public R visitInstanceOf(InstanceOfTree node, P p) {
}
/**
- * {@inheritDoc} This implementation scans the children in left to right order.
+ * {@inheritDoc}
+ *
+ * @implSpec This implementation scans the children in left to right order.
*
* @param node {@inheritDoc}
* @param p {@inheritDoc}
@@ -695,7 +775,25 @@ public R visitBindingPattern(BindingPatternTree node, P p) {
}
/**
- * {@inheritDoc} This implementation scans the children in left to right order.
+ * {@inheritDoc}
+ *
+ * @implSpec This implementation returns {@code null}.
+ *
+ * @param node {@inheritDoc}
+ * @param p {@inheritDoc}
+ * @return the result of scanning
+ * @since 17
+ */
+ @Override
+ @PreviewFeature(feature=PreviewFeature.Feature.SWITCH_PATTERN_MATCHING, reflective=true)
+ public R visitDefaultCaseLabel(DefaultCaseLabelTree node, P p) {
+ return null;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @implSpec This implementation scans the children in left to right order.
*
* @param node {@inheritDoc}
* @param p {@inheritDoc}
@@ -709,7 +807,9 @@ public R visitArrayAccess(ArrayAccessTree node, P p) {
}
/**
- * {@inheritDoc} This implementation scans the children in left to right order.
+ * {@inheritDoc}
+ *
+ * @implSpec This implementation scans the children in left to right order.
*
* @param node {@inheritDoc}
* @param p {@inheritDoc}
@@ -721,7 +821,42 @@ public R visitMemberSelect(MemberSelectTree node, P p) {
}
/**
- * {@inheritDoc} This implementation scans the children in left to right order.
+ * {@inheritDoc}
+ *
+ * @implSpec This implementation scans the children in left to right order.
+ *
+ * @param node {@inheritDoc}
+ * @param p {@inheritDoc}
+ * @return the result of scanning
+ * @since 17
+ */
+ @Override
+ @PreviewFeature(feature=PreviewFeature.Feature.SWITCH_PATTERN_MATCHING, reflective=true)
+ public R visitParenthesizedPattern(ParenthesizedPatternTree node, P p) {
+ return scan(node.getPattern(), p);
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @implSpec This implementation scans the children in left to right order.
+ *
+ * @param node {@inheritDoc}
+ * @param p {@inheritDoc}
+ * @return the result of scanning
+ * @since 17
+ */
+ @Override
+ @PreviewFeature(feature=PreviewFeature.Feature.SWITCH_PATTERN_MATCHING, reflective=true)
+ public R visitGuardedPattern(GuardedPatternTree node, P p) {
+ R r = scan(node.getPattern(), p);
+ return scanAndReduce(node.getExpression(), p, r);
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @implSpec This implementation scans the children in left to right order.
*
* @param node {@inheritDoc}
* @param p {@inheritDoc}
@@ -735,7 +870,9 @@ public R visitMemberReference(MemberReferenceTree node, P p) {
}
/**
- * {@inheritDoc} This implementation returns {@code null}.
+ * {@inheritDoc}
+ *
+ * @implSpec This implementation returns {@code null}.
*
* @param node {@inheritDoc}
* @param p {@inheritDoc}
@@ -747,7 +884,9 @@ public R visitIdentifier(IdentifierTree node, P p) {
}
/**
- * {@inheritDoc} This implementation returns {@code null}.
+ * {@inheritDoc}
+ *
+ * @implSpec This implementation returns {@code null}.
*
* @param node {@inheritDoc}
* @param p {@inheritDoc}
@@ -759,7 +898,9 @@ public R visitLiteral(LiteralTree node, P p) {
}
/**
- * {@inheritDoc} This implementation returns {@code null}.
+ * {@inheritDoc}
+ *
+ * @implSpec This implementation returns {@code null}.
*
* @param node {@inheritDoc}
* @param p {@inheritDoc}
@@ -771,7 +912,9 @@ public R visitPrimitiveType(PrimitiveTypeTree node, P p) {
}
/**
- * {@inheritDoc} This implementation scans the children in left to right order.
+ * {@inheritDoc}
+ *
+ * @implSpec This implementation scans the children in left to right order.
*
* @param node {@inheritDoc}
* @param p {@inheritDoc}
@@ -783,7 +926,9 @@ public R visitArrayType(ArrayTypeTree node, P p) {
}
/**
- * {@inheritDoc} This implementation scans the children in left to right order.
+ * {@inheritDoc}
+ *
+ * @implSpec This implementation scans the children in left to right order.
*
* @param node {@inheritDoc}
* @param p {@inheritDoc}
@@ -797,7 +942,9 @@ public R visitParameterizedType(ParameterizedTypeTree node, P p) {
}
/**
- * {@inheritDoc} This implementation scans the children in left to right order.
+ * {@inheritDoc}
+ *
+ * @implSpec This implementation scans the children in left to right order.
*
* @param node {@inheritDoc}
* @param p {@inheritDoc}
@@ -809,7 +956,9 @@ public R visitUnionType(UnionTypeTree node, P p) {
}
/**
- * {@inheritDoc} This implementation scans the children in left to right order.
+ * {@inheritDoc}
+ *
+ * @implSpec This implementation scans the children in left to right order.
*
* @param node {@inheritDoc}
* @param p {@inheritDoc}
@@ -821,7 +970,9 @@ public R visitIntersectionType(IntersectionTypeTree node, P p) {
}
/**
- * {@inheritDoc} This implementation scans the children in left to right order.
+ * {@inheritDoc}
+ *
+ * @implSpec This implementation scans the children in left to right order.
*
* @param node {@inheritDoc}
* @param p {@inheritDoc}
@@ -835,7 +986,9 @@ public R visitTypeParameter(TypeParameterTree node, P p) {
}
/**
- * {@inheritDoc} This implementation scans the children in left to right order.
+ * {@inheritDoc}
+ *
+ * @implSpec This implementation scans the children in left to right order.
*
* @param node {@inheritDoc}
* @param p {@inheritDoc}
@@ -847,7 +1000,9 @@ public R visitWildcard(WildcardTree node, P p) {
}
/**
- * {@inheritDoc} This implementation scans the children in left to right order.
+ * {@inheritDoc}
+ *
+ * @implSpec This implementation scans the children in left to right order.
*
* @param node {@inheritDoc}
* @param p {@inheritDoc}
@@ -859,7 +1014,9 @@ public R visitModifiers(ModifiersTree node, P p) {
}
/**
- * {@inheritDoc} This implementation scans the children in left to right order.
+ * {@inheritDoc}
+ *
+ * @implSpec This implementation scans the children in left to right order.
*
* @param node {@inheritDoc}
* @param p {@inheritDoc}
@@ -873,7 +1030,9 @@ public R visitAnnotation(AnnotationTree node, P p) {
}
/**
- * {@inheritDoc} This implementation scans the children in left to right order.
+ * {@inheritDoc}
+ *
+ * @implSpec This implementation scans the children in left to right order.
*
* @param node {@inheritDoc}
* @param p {@inheritDoc}
@@ -886,6 +1045,15 @@ public R visitAnnotatedType(AnnotatedTypeTree node, P p) {
return r;
}
+ /**
+ * {@inheritDoc}
+ *
+ * @implSpec This implementation scans the children in left to right order.
+ *
+ * @param node {@inheritDoc}
+ * @param p {@inheritDoc}
+ * @return the result of scanning
+ */
@Override
public R visitModule(ModuleTree node, P p) {
R r = scan(node.getAnnotations(), p);
@@ -894,6 +1062,15 @@ public R visitModule(ModuleTree node, P p) {
return r;
}
+ /**
+ * {@inheritDoc}
+ *
+ * @implSpec This implementation scans the children in left to right order.
+ *
+ * @param node {@inheritDoc}
+ * @param p {@inheritDoc}
+ * @return the result of scanning
+ */
@Override
public R visitExports(ExportsTree node, P p) {
R r = scan(node.getPackageName(), p);
@@ -901,6 +1078,15 @@ public R visitExports(ExportsTree node, P p) {
return r;
}
+ /**
+ * {@inheritDoc}
+ *
+ * @implSpec This implementation scans the children in left to right order.
+ *
+ * @param node {@inheritDoc}
+ * @param p {@inheritDoc}
+ * @return the result of scanning
+ */
@Override
public R visitOpens(OpensTree node, P p) {
R r = scan(node.getPackageName(), p);
@@ -908,6 +1094,15 @@ public R visitOpens(OpensTree node, P p) {
return r;
}
+ /**
+ * {@inheritDoc}
+ *
+ * @implSpec This implementation scans the children in left to right order.
+ *
+ * @param node {@inheritDoc}
+ * @param p {@inheritDoc}
+ * @return the result of scanning
+ */
@Override
public R visitProvides(ProvidesTree node, P p) {
R r = scan(node.getServiceName(), p);
@@ -915,18 +1110,38 @@ public R visitProvides(ProvidesTree node, P p) {
return r;
}
+ /**
+ * {@inheritDoc}
+ *
+ * @implSpec This implementation scans the children in left to right order.
+ *
+ * @param node {@inheritDoc}
+ * @param p {@inheritDoc}
+ * @return the result of scanning
+ */
@Override
public R visitRequires(RequiresTree node, P p) {
return scan(node.getModuleName(), p);
}
+ /**
+ * {@inheritDoc}
+ *
+ * @implSpec This implementation scans the children in left to right order.
+ *
+ * @param node {@inheritDoc}
+ * @param p {@inheritDoc}
+ * @return the result of scanning
+ */
@Override
public R visitUses(UsesTree node, P p) {
return scan(node.getServiceName(), p);
}
/**
- * {@inheritDoc} This implementation returns {@code null}.
+ * {@inheritDoc}
+ *
+ * @implSpec This implementation returns {@code null}.
*
* @param node {@inheritDoc}
* @param p {@inheritDoc}
@@ -938,7 +1153,9 @@ public R visitOther(Tree node, P p) {
}
/**
- * {@inheritDoc} This implementation returns {@code null}.
+ * {@inheritDoc}
+ *
+ * @implSpec This implementation returns {@code null}.
*
* @param node {@inheritDoc}
* @param p {@inheritDoc}
@@ -950,7 +1167,9 @@ public R visitErroneous(ErroneousTree node, P p) {
}
/**
- * {@inheritDoc} This implementation scans the children in left to right order.
+ * {@inheritDoc}
+ *
+ * @implSpec This implementation scans the children in left to right order.
*
* @param node {@inheritDoc}
* @param p {@inheritDoc}
diff --git a/src/jdk.compiler/share/classes/com/sun/tools/doclint/DocLint.java b/src/jdk.compiler/share/classes/com/sun/tools/doclint/DocLint.java
index 255e154..ec16e3e 100644
--- a/src/jdk.compiler/share/classes/com/sun/tools/doclint/DocLint.java
+++ b/src/jdk.compiler/share/classes/com/sun/tools/doclint/DocLint.java
@@ -53,7 +53,6 @@ public abstract class DocLint implements Plugin {
public static final String XMSGS_OPTION = "-Xmsgs";
public static final String XMSGS_CUSTOM_PREFIX = "-Xmsgs:";
- public static final String XHTML_VERSION_PREFIX = "-XhtmlVersion:";
public static final String XCHECK_PACKAGE = "-XcheckPackage:";
public abstract boolean isValidOption(String opt);
@@ -97,7 +96,6 @@ public boolean isValidOption(String s) {
// passively accept all "plausible" options
return s.equals(XMSGS_OPTION)
|| s.startsWith(XMSGS_CUSTOM_PREFIX)
- || s.startsWith(XHTML_VERSION_PREFIX)
|| s.startsWith(XCHECK_PACKAGE);
}
}
diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/api/ClientCodeWrapper.java b/src/jdk.compiler/share/classes/com/sun/tools/javac/api/ClientCodeWrapper.java
index 890462a..f383c30 100644
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/api/ClientCodeWrapper.java
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/api/ClientCodeWrapper.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2011, 2019, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2021, 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
@@ -151,7 +151,7 @@ public Iterable wrapJavaFileObjects(Iterable extends JavaFileO
}
JavaFileObject unwrap(JavaFileObject fo) {
- if (fo instanceof WrappedJavaFileObject)
+ if (fo instanceof WrappedJavaFileObject)
return ((JavaFileObject) ((WrappedJavaFileObject) fo).clientFileObject);
else
return fo;
@@ -170,7 +170,7 @@ TaskListener wrap(TaskListener tl) {
}
TaskListener unwrap(TaskListener l) {
- if (l instanceof WrappedTaskListener)
+ if (l instanceof WrappedTaskListener)
return ((WrappedTaskListener) l).clientTaskListener;
else
return l;
diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/api/JavacScope.java b/src/jdk.compiler/share/classes/com/sun/tools/javac/api/JavacScope.java
index 01900bf..c242c13 100644
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/api/JavacScope.java
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/api/JavacScope.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2006, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2021, 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
@@ -25,7 +25,7 @@
package com.sun.tools.javac.api;
-
+import java.util.function.Predicate;
import javax.lang.model.element.Element;
import javax.lang.model.element.ExecutableElement;
import javax.lang.model.element.TypeElement;
@@ -38,7 +38,6 @@
import com.sun.tools.javac.util.DefinedBy;
import com.sun.tools.javac.util.DefinedBy.Api;
import com.sun.tools.javac.util.Assert;
-import com.sun.tools.javac.util.Filter;
/**
* Provides an implementation of Scope.
@@ -52,7 +51,7 @@
*/
public class JavacScope implements com.sun.source.tree.Scope {
- private static final Filter VALIDATOR = sym -> {
+ private static final Predicate VALIDATOR = sym -> {
sym.apiComplete();
return sym.kind != Kind.ERR;
};
diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/api/JavacTaskImpl.java b/src/jdk.compiler/share/classes/com/sun/tools/javac/api/JavacTaskImpl.java
index 90ff3e1..9dd912b 100644
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/api/JavacTaskImpl.java
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/api/JavacTaskImpl.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2021, 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
@@ -244,7 +244,7 @@ String toString(Iterable items, String sep) {
void cleanup() {
if (compiler != null)
compiler.close();
- if (fileManager instanceof BaseFileManager && ((BaseFileManager) fileManager).autoClose) {
+ if (fileManager instanceof BaseFileManager && ((BaseFileManager) fileManager).autoClose) {
try {
fileManager.close();
} catch (IOException ignore) {
diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/api/JavacTaskPool.java b/src/jdk.compiler/share/classes/com/sun/tools/javac/api/JavacTaskPool.java
index f7ba8cf..0c25278 100644
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/api/JavacTaskPool.java
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/api/JavacTaskPool.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2015, 2020, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2021, 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
@@ -44,6 +44,7 @@
import javax.tools.DiagnosticListener;
import javax.tools.JavaFileManager;
import javax.tools.JavaFileObject;
+import javax.tools.StandardLocation;
import com.sun.source.tree.ClassTree;
import com.sun.source.tree.CompilationUnitTree;
@@ -251,6 +252,9 @@ static class ReusableContext extends Context implements TaskListener {
}
void clear() {
+ //when patching modules (esp. java.base), it may be impossible to
+ //clear the symbols read from the patch path:
+ polluted |= get(JavaFileManager.class).hasLocation(StandardLocation.PATCH_MODULE_PATH);
drop(Arguments.argsKey);
drop(DiagnosticListener.class);
drop(Log.outKey);
@@ -292,9 +296,9 @@ void clear() {
@Override @DefinedBy(Api.COMPILER_TREE)
public Void scan(Tree tree, Symtab syms) {
if (tree instanceof LetExpr) {
- LetExpr le = (LetExpr) tree;
- scan(le.defs, syms);
- scan(le.expr, syms);
+ LetExpr letExpr = (LetExpr) tree;
+ scan(letExpr.defs, syms);
+ scan(letExpr.expr, syms);
return null;
} else {
return super.scan(tree, syms);
@@ -356,7 +360,7 @@ void drop(Class c) {
*/
static class ReusableJavaCompiler extends JavaCompiler {
- final static Factory factory = ReusableJavaCompiler::new;
+ static final Factory factory = ReusableJavaCompiler::new;
ReusableJavaCompiler(Context context) {
super(context);
@@ -383,7 +387,7 @@ protected void checkReusable() {
*/
static class ReusableLog extends Log {
- final static Factory factory = ReusableLog::new;
+ static final Factory factory = ReusableLog::new;
Context context;
diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/api/JavacTool.java b/src/jdk.compiler/share/classes/com/sun/tools/javac/api/JavacTool.java
index 1c474b0..c8c5d5e 100644
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/api/JavacTool.java
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/api/JavacTool.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2021, 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
@@ -166,9 +166,15 @@ public JavacTask getTask(Writer out,
if (diagnosticListener != null)
context.put(DiagnosticListener.class, ccw.wrap(diagnosticListener));
- if (out == null)
+ // If out is null and the value is set in the context, we need to do nothing.
+ if (out == null && context.get(Log.errKey) == null)
+ // Situation: out is null and the value is not set in the context.
context.put(Log.errKey, new PrintWriter(System.err, true));
- else
+ else if (out instanceof PrintWriter)
+ // Situation: out is not null and out is a PrintWriter.
+ context.put(Log.errKey, (PrintWriter)out);
+ else if (out != null)
+ // Situation: out is not null and out is not a PrintWriter.
context.put(Log.errKey, new PrintWriter(out, true));
if (fileManager == null) {
diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/api/JavacTrees.java b/src/jdk.compiler/share/classes/com/sun/tools/javac/api/JavacTrees.java
index 18000a6..eb3308a 100644
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/api/JavacTrees.java
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/api/JavacTrees.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 2020, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2021, 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
@@ -247,9 +247,11 @@ private void init(Context context) {
syms = Symtab.instance(context);
fileManager = context.get(JavaFileManager.class);
JavacTask t = context.get(JavacTask.class);
+
if (t instanceof JavacTaskImpl)
javacTaskImpl = (JavacTaskImpl) t;
compiler = com.sun.tools.javac.main.JavaCompiler.instance(context);
+
}
@Override @DefinedBy(Api.COMPILER_TREE)
@@ -480,7 +482,7 @@ public TypeMirror getType(DocTreePath path) {
new Log.DeferredDiagnosticHandler(log);
try {
Env env = getAttrContext(path.getTreePath());
- Type t = attr.attribType(((DCReference) tree).qualifierExpression, env);
+ Type t = attr.attribType(((DCReference)tree).qualifierExpression, env);
if (t != null && !t.isErroneous()) {
return t;
}
@@ -579,7 +581,7 @@ private Symbol attributeDocReference(TreePath path, DCReference ref) {
Type e = t;
// If this is an array type convert to element type
while (e instanceof ArrayType)
- e = ((ArrayType) e).elemtype;
+ e = ((ArrayType)e).elemtype;
tsym = e.tsym;
memberName = (Name) ref.memberName;
}
@@ -653,12 +655,10 @@ private Symbol attributeParamIdentifier(TreePath path, DCParam paramTag) {
return null;
}
- /** @see com.sun.tools.javadoc.ClassDocImpl#findField */
private VarSymbol findField(ClassSymbol tsym, Name fieldName) {
return searchField(tsym, fieldName, new HashSet<>());
}
- /** @see com.sun.tools.javadoc.ClassDocImpl#searchField */
private VarSymbol searchField(ClassSymbol tsym, Name fieldName, Set searched) {
if (searched.contains(tsym)) {
return null;
@@ -705,7 +705,6 @@ private VarSymbol searchField(ClassSymbol tsym, Name fieldName, Set
return null;
}
- /** @see com.sun.tools.javadoc.ClassDocImpl#findConstructor */
MethodSymbol findConstructor(ClassSymbol tsym, List paramTypes) {
for (Symbol sym : tsym.members().getSymbolsByName(names.init)) {
if (sym.kind == MTH) {
@@ -717,12 +716,10 @@ MethodSymbol findConstructor(ClassSymbol tsym, List paramTypes) {
return null;
}
- /** @see com.sun.tools.javadoc.ClassDocImpl#findMethod */
private MethodSymbol findMethod(ClassSymbol tsym, Name methodName, List paramTypes) {
return searchMethod(tsym, methodName, paramTypes, new HashSet<>());
}
- /** @see com.sun.tools.javadoc.ClassDocImpl#searchMethod */
private MethodSymbol searchMethod(ClassSymbol tsym, Name methodName,
List paramTypes, Set searched) {
//### Note that this search is not necessarily what the compiler would do!
@@ -804,7 +801,6 @@ private MethodSymbol searchMethod(ClassSymbol tsym, Name methodName,
return null;
}
- /** @see com.sun.tools.javadoc.ClassDocImpl */
private boolean hasParameterTypes(MethodSymbol method, List paramTypes) {
if (paramTypes == null)
return true;
@@ -837,7 +833,7 @@ public JavacScope getScope(TreePath path) {
public String getDocComment(TreePath path) {
CompilationUnitTree t = path.getCompilationUnit();
Tree leaf = path.getLeaf();
- if (t instanceof JCTree.JCCompilationUnit && leaf instanceof JCTree) {
+ if (t instanceof JCTree.JCCompilationUnit && leaf instanceof JCTree) {
JCCompilationUnit cu = (JCCompilationUnit) t;
if (cu.docComments != null) {
return cu.docComments.getCommentText((JCTree) leaf);
@@ -891,6 +887,7 @@ public boolean isAccessible(Scope scope, TypeElement type) {
@Override @DefinedBy(Api.COMPILER_TREE)
public boolean isAccessible(Scope scope, Element member, DeclaredType type) {
+
if (scope instanceof JavacScope
&& member instanceof Symbol
&& type instanceof com.sun.tools.javac.code.Type) {
@@ -901,6 +898,7 @@ public boolean isAccessible(Scope scope, Element member, DeclaredType type) {
return resolve.isAccessible(env, (com.sun.tools.javac.code.Type)type, (Symbol)member, true);
} else
return false;
+
}
private Env getAttrContext(TreePath path) {
@@ -1161,7 +1159,7 @@ public void visitVarDef(JCVariableDecl tree) {
static JavaFileObject asJavaFileObject(FileObject fileObject) {
JavaFileObject jfo = null;
- if (fileObject instanceof JavaFileObject) {
+ if (fileObject instanceof JavaFileObject) {
jfo = (JavaFileObject) fileObject;
checkHtmlKind(fileObject, Kind.HTML);
return jfo;
@@ -1306,7 +1304,7 @@ protected Copier createCopier(TreeMaker maker) {
*/
@Override @DefinedBy(Api.COMPILER_TREE)
public TypeMirror getOriginalType(javax.lang.model.type.ErrorType errorType) {
- if (errorType instanceof com.sun.tools.javac.code.Type.ErrorType) {
+ if (errorType instanceof com.sun.tools.javac.code.Type.ErrorType) {
return ((com.sun.tools.javac.code.Type.ErrorType)errorType).getOriginalType();
}
if (errorType instanceof com.sun.tools.javac.code.Type.ClassType &&
diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/code/AnnoConstruct.java b/src/jdk.compiler/share/classes/com/sun/tools/javac/code/AnnoConstruct.java
index a7488ea..e9e802f 100644
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/code/AnnoConstruct.java
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/code/AnnoConstruct.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2021, 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
@@ -168,7 +168,7 @@ private Attribute.Compound[] unpackContained(Attribute.Compound container) {
ListBuffer compounds = new ListBuffer<>();
if (contained0 != null) {
for (Attribute a : contained0)
- if (a instanceof Attribute.Compound)
+ if (a instanceof Attribute.Compound)
compounds = compounds.append((Attribute.Compound)a);
}
return compounds.toArray(new Attribute.Compound[compounds.size()]);
diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Attribute.java b/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Attribute.java
index 04cf147..b93105a 100644
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Attribute.java
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Attribute.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003, 2019, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2021, 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
@@ -88,7 +88,7 @@ public Object getValue() {
@DefinedBy(Api.LANGUAGE_MODEL)
public R accept(AnnotationValueVisitor v, P p) {
if (value instanceof String)
- return v.visitString((String) value, p);
+ return v.visitString((String)value, p);
if (value instanceof Integer) {
int i = (Integer) value;
switch (type.getTag()) {
diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/code/ClassFinder.java b/src/jdk.compiler/share/classes/com/sun/tools/javac/code/ClassFinder.java
index 3a5ac8c..c74bfe8 100644
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/code/ClassFinder.java
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/code/ClassFinder.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1999, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2021, 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
diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Directive.java b/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Directive.java
index e6cad52..34fb6d2 100644
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Directive.java
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Directive.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2009, 2019, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009, 2021, 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
@@ -359,7 +359,7 @@ public R accept(DirectiveVisitor v, P p) {
// TODO: delete?
@Override
public boolean equals(Object obj) {
- if (!(obj instanceof UsesDirective)) {
+ if (!(obj instanceof UsesDirective)) {
return false;
}
UsesDirective other = (UsesDirective)obj;
diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Flags.java b/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Flags.java
index b614e24..f31ce23 100644
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Flags.java
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Flags.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1999, 2020, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2021, 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
@@ -176,7 +176,12 @@ public static EnumSet asFlagSet(long flags) {
/** Flag for synthesized default constructors of anonymous classes.
*/
- public static final int ANONCONSTR = 1<<29;
+ public static final int ANONCONSTR = 1<<29; //non-class members
+
+ /**
+ * Flag to indicate the super classes of this ClassSymbol has been attributed.
+ */
+ public static final int SUPER_OWNER_ATTRIBUTED = 1<<29; //ClassSymbols
/** Flag for class symbols to indicate it has been checked and found
* acyclic.
@@ -306,7 +311,12 @@ public static EnumSet asFlagSet(long flags) {
/**
* Flag to indicate the given ModuleSymbol is a system module.
*/
- public static final long SYSTEM_MODULE = 1L<<53;
+ public static final long SYSTEM_MODULE = 1L<<53; //ModuleSymbols only
+
+ /**
+ * Flag to indicate the given ClassSymbol is a value based.
+ */
+ public static final long VALUE_BASED = 1L<<53; //ClassSymbols only
/**
* Flag to indicate the given symbol has a @Deprecated annotation.
@@ -337,7 +347,7 @@ public static EnumSet asFlagSet(long flags) {
/**
* Flag to indicate the API element in question is for a preview API.
*/
- public static final long PREVIEW_ESSENTIAL_API = 1L<<58; //any Symbol kind
+ public static final long PREVIEW_REFLECTIVE = 1L<<58; //any Symbol kind
/**
* Flag to indicate the given variable is a match binding variable.
@@ -383,6 +393,7 @@ public static EnumSet asFlagSet(long flags) {
*/
public static final long NON_SEALED = 1L<<63; // ClassSymbols
+
/** Modifier masks.
*/
public static final int
@@ -412,7 +423,6 @@ public static EnumSet asFlagSet(long flags) {
LocalVarFlags = FINAL | PARAMETER,
ReceiverParamFlags = PARAMETER;
- @SuppressWarnings("preview")
public static Set asModifierSet(long flags) {
Set modifiers = modifierSets.get(flags);
if (modifiers == null) {
@@ -512,7 +522,7 @@ public enum Flag {
ANONCONSTR_BASED(Flags.ANONCONSTR_BASED),
NAME_FILLED(Flags.NAME_FILLED),
PREVIEW_API(Flags.PREVIEW_API),
- PREVIEW_ESSENTIAL_API(Flags.PREVIEW_ESSENTIAL_API),
+ PREVIEW_REFLECTIVE(Flags.PREVIEW_REFLECTIVE),
MATCH_BINDING(Flags.MATCH_BINDING),
MATCH_BINDING_TO_OUTER(Flags.MATCH_BINDING_TO_OUTER),
RECORD(Flags.RECORD),
diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Lint.java b/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Lint.java
index feb9565..3c43be6 100644
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Lint.java
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Lint.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 2020, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2021, 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
@@ -118,6 +118,9 @@ protected Lint(Context context) {
if (source.compareTo(Source.JDK9) >= 0) {
values.add(LintCategory.DEP_ANN);
}
+ if (Source.Feature.REDUNDANT_STRICTFP.allowedInSource(source)) {
+ values.add(LintCategory.STRICTFP);
+ }
values.add(LintCategory.REQUIRES_TRANSITIVE_AUTOMATIC);
values.add(LintCategory.OPENS);
values.add(LintCategory.MODULE);
@@ -292,6 +295,11 @@ public enum LintCategory {
*/
STATIC("static"),
+ /**
+ * Warn about unnecessary uses of the strictfp modifier
+ */
+ STRICTFP("strictfp"),
+
/**
* Warn about synchronization attempts on instances of @ValueBased classes.
*/
diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Preview.java b/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Preview.java
index 24a83c6..c4653c5 100644
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Preview.java
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Preview.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2018, 2020, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2018, 2021, 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
@@ -42,9 +42,15 @@
import javax.tools.JavaFileObject;
import java.util.HashMap;
+import java.util.HashSet;
import java.util.Map;
+import java.util.Set;
+import static com.sun.tools.javac.code.Flags.RECORD;
+import static com.sun.tools.javac.code.Flags.SEALED;
+import static com.sun.tools.javac.code.Flags.NON_SEALED;
import static com.sun.tools.javac.main.Option.PREVIEW;
+import com.sun.tools.javac.util.JCDiagnostic;
/**
* Helper class to handle preview language features. This class maps certain language features
@@ -70,9 +76,11 @@ public class Preview {
/** a mapping from classfile numbers to Java SE versions */
private final Map majorVersionToSource;
+ private final Set sourcesWithPreviewFeatures = new HashSet<>();
private final Lint lint;
private final Log log;
+ private final Source source;
private static final Context.Key previewKey = new Context.Key<>();
@@ -90,8 +98,9 @@ public static Preview instance(Context context) {
enabled = options.isSet(PREVIEW);
log = Log.instance(context);
lint = Lint.instance(context);
+ source = Source.instance(context);
this.previewHandler =
- new MandatoryWarningHandler(log, lint.isEnabled(LintCategory.PREVIEW), true, "preview", LintCategory.PREVIEW);
+ new MandatoryWarningHandler(log, source, lint.isEnabled(LintCategory.PREVIEW), true, "preview", LintCategory.PREVIEW);
forcePreview = options.isSet("forcePreview");
majorVersionToSource = initMajorVersionToSourceMap();
}
@@ -128,6 +137,7 @@ public void warnPreview(DiagnosticPosition pos, Feature feature) {
Assert.check(isEnabled());
Assert.check(isPreview(feature));
if (!lint.isSuppressed(LintCategory.PREVIEW)) {
+ sourcesWithPreviewFeatures.add(log.currentSourceFile());
previewHandler.report(pos, feature.isPlural() ?
Warnings.PreviewFeatureUsePlural(feature.nameFragment()) :
Warnings.PreviewFeatureUse(feature.nameFragment()));
@@ -141,16 +151,25 @@ public void warnPreview(DiagnosticPosition pos, Feature feature) {
*/
public void warnPreview(JavaFileObject classfile, int majorVersion) {
Assert.check(isEnabled());
- if (!lint.isSuppressed(LintCategory.PREVIEW)) {
- previewHandler.report(null,
+ if (lint.isEnabled(LintCategory.PREVIEW)) {
+ sourcesWithPreviewFeatures.add(log.currentSourceFile());
+ log.mandatoryWarning(LintCategory.PREVIEW, null,
Warnings.PreviewFeatureUseClassfile(classfile, majorVersionToSource.get(majorVersion).name));
}
}
+ public void markUsesPreview(DiagnosticPosition pos) {
+ sourcesWithPreviewFeatures.add(log.currentSourceFile());
+ }
+
public void reportPreviewWarning(DiagnosticPosition pos, Warning warnKey) {
previewHandler.report(pos, warnKey);
}
+ public boolean usesPreview(JavaFileObject file) {
+ return sourcesWithPreviewFeatures.contains(file);
+ }
+
/**
* Are preview features enabled?
* @return true, if preview features are enabled.
@@ -165,7 +184,9 @@ public boolean isEnabled() {
* @return true, if given feature is a preview feature.
*/
public boolean isPreview(Feature feature) {
- if (feature == Feature.SEALED_CLASSES)
+ if (feature == Feature.CASE_NULL)
+ return true;
+ else if(feature == Feature.PATTERN_SWITCH)
return true;
//Note: this is a backdoor which allows to optionally treat all features as 'preview' (for testing).
//When real preview features will be added, this method can be implemented to return 'true'
@@ -197,6 +218,17 @@ public Error disabledError(JavaFileObject classfile, int majorVersion) {
return Errors.PreviewFeatureDisabledClassfile(classfile, majorVersionToSource.get(majorVersion).name);
}
+ /**
+ * Check whether the given symbol has been declared using
+ * a preview language feature.
+ *
+ * @param sym Symbol to check
+ * @return true iff sym has been declared using a preview language feature
+ */
+ public boolean declaredUsingPreviewFeature(Symbol sym) {
+ return false;
+ }
+
/**
* Report any deferred diagnostics.
*/
@@ -208,4 +240,19 @@ public void clear() {
previewHandler.clear();
}
+ public void checkSourceLevel(DiagnosticPosition pos, Feature feature) {
+ if (isPreview(feature) && !isEnabled()) {
+ //preview feature without --preview flag, error
+ log.error(JCDiagnostic.DiagnosticFlag.SOURCE_LEVEL, pos, disabledError(feature));
+ } else {
+ if (!feature.allowedInSource(source)) {
+ log.error(JCDiagnostic.DiagnosticFlag.SOURCE_LEVEL, pos,
+ feature.error(source.name));
+ }
+ if (isEnabled() && isPreview(feature)) {
+ warnPreview(pos, feature);
+ }
+ }
+ }
+
}
diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Scope.java b/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Scope.java
index 4e8a39b..f19fd65 100644
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Scope.java
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Scope.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1999, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2021, 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
@@ -29,6 +29,7 @@
import java.lang.ref.WeakReference;
import java.util.*;
import java.util.function.BiConsumer;
+import java.util.function.Predicate;
import com.sun.tools.javac.code.Symbol.CompletionFailure;
import com.sun.tools.javac.code.Symbol.TypeSymbol;
@@ -70,7 +71,7 @@ public final Iterable getSymbols() {
/**Returns Symbols that match the given filter. Symbols from outward Scopes are included.
*/
- public final Iterable getSymbols(Filter sf) {
+ public final Iterable getSymbols(Predicate sf) {
return getSymbols(sf, RECURSIVE);
}
@@ -84,7 +85,7 @@ public final Iterable getSymbols(LookupKind lookupKind) {
/**Returns Symbols that match the given filter. Symbols from outward Scopes are included
* iff lookupKind == RECURSIVE.
*/
- public abstract Iterable getSymbols(Filter sf, LookupKind lookupKind);
+ public abstract Iterable getSymbols(Predicate sf, LookupKind lookupKind);
/**Returns Symbols with the given name. Symbols from outward Scopes are included.
*/
@@ -95,7 +96,7 @@ public final Iterable getSymbolsByName(Name name) {
/**Returns Symbols with the given name that match the given filter.
* Symbols from outward Scopes are included.
*/
- public final Iterable getSymbolsByName(final Name name, final Filter sf) {
+ public final Iterable getSymbolsByName(final Name name, final Predicate sf) {
return getSymbolsByName(name, sf, RECURSIVE);
}
@@ -109,7 +110,7 @@ public final Iterable getSymbolsByName(Name name, LookupKind lookupKind)
/**Returns Symbols with the given name that match the given filter.
* Symbols from outward Scopes are included iff lookupKind == RECURSIVE.
*/
- public abstract Iterable getSymbolsByName(final Name name, final Filter sf,
+ public abstract Iterable getSymbolsByName(final Name name, final Predicate sf,
final LookupKind lookupKind);
/** Return the first Symbol from this or outward scopes with the given name.
@@ -122,7 +123,7 @@ public final Symbol findFirst(Name name) {
/** Return the first Symbol from this or outward scopes with the given name that matches the
* given filter. Returns null if none.
*/
- public Symbol findFirst(Name name, Filter sf) {
+ public Symbol findFirst(Name name, Predicate sf) {
Iterator it = getSymbolsByName(name, sf).iterator();
return it.hasNext() ? it.next() : null;
}
@@ -130,7 +131,7 @@ public Symbol findFirst(Name name, Filter sf) {
/** Returns true iff there are is at least one Symbol in this scope matching the given filter.
* Does not inspect outward scopes.
*/
- public boolean anyMatch(Filter filter) {
+ public boolean anyMatch(Predicate filter) {
return getSymbols(filter, NON_RECURSIVE).iterator().hasNext();
}
@@ -160,7 +161,7 @@ public boolean isEmpty() {
*/
public abstract boolean isStaticallyImported(Symbol byName);
- private static final Filter noFilter = null;
+ private static final Predicate noFilter = null;
/** A list of scopes to be notified if items are to be removed from this scope.
*/
@@ -514,16 +515,16 @@ protected Entry lookup(Name name) {
return lookup(name, noFilter);
}
- protected Entry lookup(Name name, Filter sf) {
+ protected Entry lookup(Name name, Predicate sf) {
Entry e = table[getIndex(name)];
if (e == null || e == sentinel)
return sentinel;
- while (e.scope != null && (e.sym.name != name || (sf != null && !sf.accepts(e.sym))))
+ while (e.scope != null && (e.sym.name != name || (sf != null && !sf.test(e.sym))))
e = e.shadowed;
return e;
}
- public Symbol findFirst(Name name, Filter sf) {
+ public Symbol findFirst(Name name, Predicate sf) {
return lookup(name, sf).sym;
}
@@ -563,11 +564,11 @@ int getIndex (Name name) {
}
}
- public boolean anyMatch(Filter sf) {
+ public boolean anyMatch(Predicate sf) {
return getSymbols(sf, NON_RECURSIVE).iterator().hasNext();
}
- public Iterable getSymbols(final Filter sf,
+ public Iterable getSymbols(final Predicate sf,
final LookupKind lookupKind) {
return () -> new Iterator() {
private ScopeImpl currScope = ScopeImpl.this;
@@ -616,7 +617,7 @@ private void update() {
}
void skipToNextMatchingEntry() {
- while (currEntry != null && sf != null && !sf.accepts(currEntry.sym)) {
+ while (currEntry != null && sf != null && !sf.test(currEntry.sym)) {
currEntry = currEntry.nextSibling;
}
}
@@ -624,7 +625,7 @@ void skipToNextMatchingEntry() {
}
public Iterable getSymbolsByName(final Name name,
- final Filter sf,
+ final Predicate sf,
final LookupKind lookupKind) {
return () -> new Iterator() {
Entry currentEntry = lookup(name, sf);
@@ -729,8 +730,8 @@ public Entry next() {
return shadowed;
}
- public Entry next(Filter sf) {
- if (shadowed.sym == null || sf == null || sf.accepts(shadowed.sym)) return shadowed;
+ public Entry next(Predicate sf) {
+ if (shadowed.sym == null || sf == null || sf.test(shadowed.sym)) return shadowed;
else return shadowed.next(sf);
}
@@ -752,7 +753,7 @@ public void finalizeScope() {
}
protected Scope finalizeSingleScope(Scope impScope) {
- if (impScope instanceof FilterImportScope && impScope.owner.kind == Kind.TYP &&
+ if (impScope instanceof FilterImportScope && impScope.owner.kind == Kind.TYP &&
((FilterImportScope) impScope).isStaticallyImported()) {
WriteableScope finalized = WriteableScope.create(impScope.owner);
@@ -815,7 +816,7 @@ private Scope appendScope(Scope newScope, Name name) {
}
@Override
- public Iterable getSymbolsByName(Name name, Filter sf, LookupKind lookupKind) {
+ public Iterable getSymbolsByName(Name name, Predicate sf, LookupKind lookupKind) {
Scope[] scopes = name2Scopes.get(name);
if (scopes == null)
return Collections.emptyList();
@@ -848,16 +849,16 @@ public SingleEntryScope(Symbol owner, Symbol sym, Scope origin) {
}
@Override
- public Iterable getSymbols(Filter sf, LookupKind lookupKind) {
- return sf == null || sf.accepts(sym) ? content : Collections.emptyList();
+ public Iterable getSymbols(Predicate sf, LookupKind lookupKind) {
+ return sf == null || sf.test(sym) ? content : Collections.emptyList();
}
@Override
public Iterable getSymbolsByName(Name name,
- Filter sf,
+ Predicate sf,
LookupKind lookupKind) {
return sym.name == name &&
- (sf == null || sf.accepts(sym)) ? content : Collections.emptyList();
+ (sf == null || sf.test(sym)) ? content : Collections.emptyList();
}
@Override
@@ -928,7 +929,7 @@ public FilterImportScope(Types types,
}
@Override
- public Iterable getSymbols(final Filter sf, final LookupKind lookupKind) {
+ public Iterable getSymbols(final Predicate sf, final LookupKind lookupKind) {
if (filterName != null)
return getSymbolsByName(filterName, sf, lookupKind);
try {
@@ -951,7 +952,7 @@ Iterable doLookup(TypeSymbol tsym) {
@Override
public Iterable getSymbolsByName(final Name name,
- final Filter sf,
+ final Predicate sf,
final LookupKind lookupKind) {
if (filterName != null && filterName != name)
return Collections.emptyList();
@@ -1077,7 +1078,7 @@ public String toString() {
}
@Override
- public Iterable getSymbols(final Filter sf,
+ public Iterable getSymbols(final Predicate sf,
final LookupKind lookupKind) {
return () -> Iterators.createCompoundIterator(subScopes,
scope -> scope.getSymbols(sf,
@@ -1087,7 +1088,7 @@ public Iterable getSymbols(final Filter sf,
@Override
public Iterable getSymbolsByName(final Name name,
- final Filter sf,
+ final Predicate sf,
final LookupKind lookupKind) {
return () -> Iterators.createCompoundIterator(subScopes,
scope -> scope.getSymbolsByName(name,
diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Source.java b/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Source.java
index c70ce8d..0f9eef3 100644
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Source.java
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Source.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2002, 2020, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2021, 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
@@ -108,7 +108,12 @@ public enum Source {
/**
* 16, tbd
*/
- JDK16("16");
+ JDK16("16"),
+
+ /**
+ * 17, tbd
+ */
+ JDK17("17");
private static final Context.Key