On Fri, 29 Apr 2022 00:29:50 GMT, Jonathan Gibbons <j...@openjdk.org> wrote:
> Please review some localized cleanup for the doclint Checker class, primarily > focused on upgrading to the use of "enhanced `switch`" > > The output of one test was changed because of some improvements in one switch > statement to eliminate the use of fall-through semantics. It's nice to see many `break` go. src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclint/Checker.java line 737: > 735: private Element getEnclosingPackageOrClass(Element e) { > 736: while (e != null) { > 737: if (e.getKind().isDeclaredType() || e.getKind() == > ElementKind.PACKAGE) { This change does not seem to be equivalent: `isDeclaredType()` accepts more kinds than the `switch` did. Does it matter here? src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclint/Checker.java line 866: > 864: if (paramElement == null) { > 865: switch (env.currElement.getKind()) { > 866: case CLASS, ENUM, INTERFACE, ANNOTATION_TYPE -> { Neither an enum nor annotation can be generic. src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclint/Checker.java line 1127: > 1125: return false; > 1126: > 1127: return switch (e.getKind()) { While uniformity of constructs is good, to me, the previous variant read better. Does this have to be a switch expression? src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclint/Checker.java line 1171: > 1169: > 1170: private boolean isDefaultConstructor() { > 1171: return switch (env.currElement.getKind()) { Similar to the above. ------------- PR: https://git.openjdk.java.net/jdk/pull/8460