Skip to content
This repository was archived by the owner on Sep 19, 2023. It is now read-only.
/ jdk21 Public archive

Commit a08c6b9

Browse files
committedJul 18, 2023
8312093: Incorrect javadoc comment text
Reviewed-by: jlaskey, iris Backport-of: 1c9691b1f762812aa090b88507d60a2e2e5f4933
1 parent 4fcb0b2 commit a08c6b9

File tree

2 files changed

+33
-2
lines changed

2 files changed

+33
-2
lines changed
 

‎src/jdk.compiler/share/classes/com/sun/tools/javac/parser/JavaTokenizer.java

+4-1
Original file line numberDiff line numberDiff line change
@@ -1546,7 +1546,10 @@ protected void scanDocComment() {
15461546
return;
15471547
}
15481548

1549-
skip('*');
1549+
if (skip('*') != 0 && is('/')) {
1550+
return ;
1551+
}
1552+
15501553
skipWhitespace();
15511554

15521555
if (isEOLN()) {

‎test/langtools/tools/javac/parser/JavacParserTest.java

+29-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323

2424
/*
2525
* @test
26-
* @bug 7073631 7159445 7156633 8028235 8065753 8205418 8205913 8228451 8237041 8253584 8246774 8256411 8256149 8259050 8266436 8267221 8271928 8275097 8293897 8295401 8304671
26+
* @bug 7073631 7159445 7156633 8028235 8065753 8205418 8205913 8228451 8237041 8253584 8246774 8256411 8256149 8259050 8266436 8267221 8271928 8275097 8293897 8295401 8304671 8312093
2727
* @summary tests error and diagnostics positions
2828
* @author Jan Lahoda
2929
* @modules jdk.compiler/com.sun.tools.javac.api
@@ -2395,6 +2395,34 @@ public Void visitCase(CaseTree node, Void p) {
23952395
codes);
23962396
}
23972397

2398+
@Test //JDK-8312093
2399+
void testJavadoc() throws IOException {
2400+
String code = """
2401+
public class Test {
2402+
/***/
2403+
void main() {
2404+
}
2405+
}
2406+
""";
2407+
DiagnosticCollector<JavaFileObject> coll =
2408+
new DiagnosticCollector<>();
2409+
JavacTaskImpl ct = (JavacTaskImpl) tool.getTask(null, fm, coll, null,
2410+
null, Arrays.asList(new MyFileObject(code)));
2411+
Trees trees = Trees.instance(ct);
2412+
CompilationUnitTree cut = ct.parse().iterator().next();
2413+
new TreePathScanner<Void, Void>() {
2414+
@Override
2415+
public Void visitMethod(MethodTree node, Void p) {
2416+
if (!node.getName().contentEquals("main")) {
2417+
return null;
2418+
}
2419+
String comment = trees.getDocComment(getCurrentPath());
2420+
assertEquals("Expecting empty comment", "", comment);
2421+
return null;
2422+
}
2423+
}.scan(cut, null);
2424+
}
2425+
23982426
void run(String[] args) throws Exception {
23992427
int passed = 0, failed = 0;
24002428
final Pattern p = (args != null && args.length > 0)

1 commit comments

Comments
 (1)

openjdk-notifier[bot] commented on Jul 18, 2023

@openjdk-notifier[bot]
This repository has been archived.