Skip to content

Commit

Permalink
8312093: Incorrect javadoc comment text
Browse files Browse the repository at this point in the history
Reviewed-by: jlaskey
  • Loading branch information
lahodaj committed Jul 17, 2023
1 parent 37ca902 commit 1c9691b
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1546,7 +1546,10 @@ protected void scanDocComment() {
return;
}

skip('*');
if (skip('*') != 0 && is('/')) {
return ;
}

skipWhitespace();

if (isEOLN()) {
Expand Down
30 changes: 29 additions & 1 deletion test/langtools/tools/javac/parser/JavacParserTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

/*
* @test
* @bug 7073631 7159445 7156633 8028235 8065753 8205418 8205913 8228451 8237041 8253584 8246774 8256411 8256149 8259050 8266436 8267221 8271928 8275097 8293897 8295401 8304671 8310326
* @bug 7073631 7159445 7156633 8028235 8065753 8205418 8205913 8228451 8237041 8253584 8246774 8256411 8256149 8259050 8266436 8267221 8271928 8275097 8293897 8295401 8304671 8310326 8312093
* @summary tests error and diagnostics positions
* @author Jan Lahoda
* @modules jdk.compiler/com.sun.tools.javac.api
Expand Down Expand Up @@ -2420,6 +2420,34 @@ public Void visitClass(ClassTree node, Void p) {
}.scan(cut, null);
}

@Test //JDK-8312093
void testJavadoc() throws IOException {
String code = """
public class Test {
/***/
void main() {
}
}
""";
DiagnosticCollector<JavaFileObject> coll =
new DiagnosticCollector<>();
JavacTaskImpl ct = (JavacTaskImpl) tool.getTask(null, fm, coll, null,
null, Arrays.asList(new MyFileObject(code)));
Trees trees = Trees.instance(ct);
CompilationUnitTree cut = ct.parse().iterator().next();
new TreePathScanner<Void, Void>() {
@Override
public Void visitMethod(MethodTree node, Void p) {
if (!node.getName().contentEquals("main")) {
return null;
}
String comment = trees.getDocComment(getCurrentPath());
assertEquals("Expecting empty comment", "", comment);
return null;
}
}.scan(cut, null);
}

void run(String[] args) throws Exception {
int passed = 0, failed = 0;
final Pattern p = (args != null && args.length > 0)
Expand Down

0 comments on commit 1c9691b

Please sign in to comment.