Skip to content

Commit 9b93d81

Browse files
author
Daniel D. Daugherty
committed
8271161: [BACKOUT] JDK-8249634 doclint should report implicit constructor as missing javadoc comments
Reviewed-by: iignatyev
1 parent 1362e09 commit 9b93d81

File tree

76 files changed

+114
-231
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

76 files changed

+114
-231
lines changed

src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclint/Checker.java

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -182,18 +182,10 @@ public Void scan(DocCommentTree tree, TreePath p) {
182182
reportMissing("dc.missing.comment");
183183
return null;
184184
}
185-
186-
187-
188185
} else {
189186
if (tree == null) {
190-
if (isDefaultConstructor()) {
191-
if (isNormalClass(p.getParentPath())) {
192-
reportMissing("dc.default.constructor");
193-
}
194-
} else if (!isOverridingMethod) {
187+
if (!isSynthetic() && !isOverridingMethod)
195188
reportMissing("dc.missing.comment");
196-
}
197189
return null;
198190
}
199191
}
@@ -1150,7 +1142,7 @@ private boolean isCheckedException(TypeMirror t) {
11501142
|| env.types.isAssignable(t, env.java_lang_RuntimeException));
11511143
}
11521144

1153-
private boolean isDefaultConstructor() {
1145+
private boolean isSynthetic() {
11541146
switch (env.currElement.getKind()) {
11551147
case CONSTRUCTOR:
11561148
// A synthetic default constructor has the same pos as the
@@ -1161,14 +1153,6 @@ private boolean isDefaultConstructor() {
11611153
return false;
11621154
}
11631155

1164-
private boolean isNormalClass(TreePath p) {
1165-
return switch (p.getLeaf().getKind()) {
1166-
case ENUM, RECORD -> false;
1167-
case CLASS -> true;
1168-
default -> throw new IllegalArgumentException(p.getLeaf().getKind().name());
1169-
};
1170-
}
1171-
11721156
void markEnclosingTag(Flag flag) {
11731157
TagStackItem top = tagStack.peek();
11741158
if (top != null)

src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclint/resources/doclint.properties

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#
2-
# Copyright (c) 2012, 2021, Oracle and/or its affiliates. All rights reserved.
2+
# Copyright (c) 2012, 2020, Oracle and/or its affiliates. All rights reserved.
33
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
#
55
# This code is free software; you can redistribute it and/or modify it
@@ -37,7 +37,6 @@ dc.attr.table.border.not.number = invalid value for attribute "border": {0}
3737
dc.attr.unknown = unknown attribute: {0}
3838
dc.bad.option = bad option: {0}
3939
dc.bad.value.for.option = bad value for option: {0} {1}
40-
dc.default.constructor = use of default constructor, which does not provide a comment
4140
dc.empty = no description for @{0}
4241
dc.entity.invalid = invalid entity &{0};
4342
dc.exception.not.thrown = exception not thrown: {0}

test/langtools/jdk/javadoc/doclet/testDiagsLineCaret/TestDiagsLineCaret.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ public class MyClass { }
6262
"-XDaccessInternalAPI",
6363
"-tagletpath", testClasses,
6464
"-taglet", "MyTaglet",
65-
"-Xdoclint:none",
6665
"MyClass.java");
6766
checkExit(Exit.ERROR);
6867

test/langtools/jdk/javadoc/doclet/testJavaFX/TestJavaFX.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -420,7 +420,7 @@ public class BooleanProperty { }
420420
"--javafx",
421421
"--disable-javafx-strict-checks",
422422
"--no-platform-links",
423-
"-Xdoclint:all,-missing",
423+
"-Xdoclint:all",
424424
"--source-path", "src5",
425425
"pkg");
426426
checkExit(Exit.OK);

test/langtools/jdk/javadoc/doclet/testMissingComment/TestMissingComment.java

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,11 @@ public static void main(String... args) throws Exception {
4949
public void testClass(Path base) throws Exception {
5050
test(base.resolve("class"), """
5151
// no doc comment
52-
public class C {
53-
/** . */ C() { }
54-
}
52+
public class C { }
5553
""",
5654
"""
5755
testClass/class/src/C.java:2: warning: no comment
58-
public class C {
56+
public class C { }
5957
^
6058
""");
6159
}
@@ -67,7 +65,6 @@ public void testExecutable(Path base) throws Exception {
6765
public class C {
6866
// no doc comment
6967
public void m() { }
70-
/** . */ C() { }
7168
}
7269
""",
7370
"""
@@ -84,7 +81,6 @@ public void testField(Path base) throws Exception {
8481
public class C {
8582
// no doc comment
8683
public int f;
87-
/** . */ C() { }
8884
}
8985
""",
9086
"""
@@ -100,15 +96,12 @@ public void testNested(Path base) throws Exception {
10096
/** Class comment. */
10197
public class C {
10298
// no doc comment
103-
public class Nested {
104-
/** . */ Nested() { }
105-
}
106-
/** . */ C() { }
99+
public class Nested { }
107100
}
108101
""",
109102
"""
110103
testNested/nest/src/C.java:4: warning: no comment
111-
public class Nested {
104+
public class Nested { }
112105
^
113106
""");
114107
}

test/langtools/jdk/javadoc/tool/doclint/DocLintTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public static void main(String... args) throws Exception {
6363

6464
final String code =
6565
/* 01 */ "/** Class comment. */\n" +
66-
/* 02 */ "public class Test { /** */ Test() { }\n" +
66+
/* 02 */ "public class Test {\n" +
6767
/* 03 */ " /** Method comment. */\n" +
6868
/* 04 */ " public void method() { }\n" +
6969
/* 05 */ "\n" +
@@ -85,14 +85,14 @@ public static void main(String... args) throws Exception {
8585

8686
final String p1Code =
8787
/* 01 */ "package p1;\n" +
88-
/* 02 */ "public class P1Test { /** */ P1Test() { }\n" +
88+
/* 02 */ "public class P1Test {\n" +
8989
/* 03 */ " /** Syntax < error. */\n" +
9090
/* 04 */ " public void method() { }\n" +
9191
/* 05 */ "}\n";
9292

9393
final String p2Code =
9494
/* 01 */ "package p2;\n" +
95-
/* 02 */ "public class P2Test { /** */ P2Test() { }\n" +
95+
/* 02 */ "public class P2Test {\n" +
9696
/* 03 */ " /** Syntax < error. */\n" +
9797
/* 04 */ " public void method() { }\n" +
9898
/* 05 */ "}\n";

test/langtools/tools/doclint/AccessTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
*/
2020

2121
/** */
22-
public class AccessTest { /** */ AccessTest() { }
22+
public class AccessTest {
2323
/**
2424
* public a < b
2525
*/
@@ -42,7 +42,7 @@ private void private_syntax_error() { }
4242
}
4343

4444
/** */
45-
class AccessTest2 { /** */ AccessTest2() { }
45+
class AccessTest2 {
4646
/**
4747
* public a < b
4848
*/

test/langtools/tools/doclint/AccessibilityTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
* @summary Add new doclint package
55
* @modules jdk.javadoc/jdk.javadoc.internal.doclint
66
* @build DocLintTester
7-
* @run main DocLintTester -Xmsgs:all,-missing,-accessibility AccessibilityTest.java
8-
* @run main DocLintTester -Xmsgs:all,-missing -ref AccessibilityTest.out AccessibilityTest.java
7+
* @run main DocLintTester -Xmsgs:-accessibility AccessibilityTest.java
8+
* @run main DocLintTester -ref AccessibilityTest.out AccessibilityTest.java
99
*/
1010

1111
/** */

test/langtools/tools/doclint/AnchorTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* @summary Add new doclint package
55
* @modules jdk.javadoc/jdk.javadoc.internal.doclint
66
* @build DocLintTester
7-
* @run main DocLintTester -Xmsgs:all,-missing -ref AnchorTest.out AnchorTest.java
7+
* @run main DocLintTester -ref AnchorTest.out AnchorTest.java
88
*/
99

1010
/** */

test/langtools/tools/doclint/AnchorTest2.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
* @summary doclint doesn't reset HTML anchors correctly
55
* @modules jdk.javadoc/jdk.javadoc.internal.doclint
66
* @build DocLintTester
7-
* @run main DocLintTester -Xmsgs:all,-missing -ref AnchorTest2.out AnchorTest2.java AnchorTest2a.java
8-
* @run main DocLintTester -Xmsgs:all,-missing -ref AnchorTest2.out AnchorTest2a.java AnchorTest2.java
7+
* @run main DocLintTester -ref AnchorTest2.out AnchorTest2.java AnchorTest2a.java
8+
* @run main DocLintTester -ref AnchorTest2.out AnchorTest2a.java AnchorTest2.java
99
*/
1010

1111
/** */

0 commit comments

Comments
 (0)