8247788: DocCommentParser should not reject standalone '>'

Reviewed-by: prappo
This commit is contained in:
Jonathan Gibbons 2020-06-18 14:07:49 -07:00
parent a750ac5feb
commit de3923edf9
9 changed files with 15 additions and 77 deletions
src/jdk.compiler/share/classes/com/sun/tools/javac
test/langtools
jdk/javadoc/doclet
tools
doclint/tidy
javac

@ -221,17 +221,6 @@ public class DocCommentParser {
}
break;
case '>':
newline = false;
addPendingText(trees, bp - 1);
trees.add(m.at(bp).newErroneousTree(newString(bp, bp + 1), diagSource, "dc.bad.gt"));
nextChar();
if (textStart == -1) {
textStart = bp;
lastNonWhite = -1;
}
break;
case '{':
inlineTag(trees);
break;

@ -3140,9 +3140,6 @@ compiler.misc.where.description.intersection.1=\
compiler.err.dc.bad.entity=\
bad HTML entity
compiler.err.dc.bad.gt=\
bad use of ''>''
compiler.err.dc.bad.inline.tag=\
incorrect use of inline tag

@ -39,6 +39,8 @@ public class TestJavaFX extends JavadocTester {
public static void main(String... args) throws Exception {
TestJavaFX tester = new TestJavaFX();
tester.setAutomaticCheckAccessibility(false);
tester.setAutomaticCheckLinks(false);
tester.runTests();
}
@ -353,6 +355,6 @@ public class TestJavaFX extends JavadocTester {
checkExit(Exit.OK);
// make sure the doclet indeed emits the warning
checkOutput(Output.OUT, true, "C.java:0: warning - invalid usage of tag >");
checkOutput(Output.OUT, true, "C.java:0: warning - invalid usage of tag <");
}
}

@ -28,7 +28,7 @@ public class C {
/**
* Defines the number of cycles in this animation. The {@code cycleCount}
* may be {@code INDEFINITE} for animations that repeat indefinitely.
* Now we add a > to deliberately cause an Html error.
* Now we add <> to deliberately cause an Html error.
* @defaultValue 11
* @since JavaFX 8.0
*/

@ -46,7 +46,7 @@ public class TestPackageHtml extends JavadocTester {
"-sourcepath", testSrc,
"pkg1");
checkExit(Exit.ERROR);
checkOutput(Output.OUT, true, "package.html:5: error: bad use of '>'");
checkOutput(Output.OUT, true, "package.html:4: error: malformed HTML");
}
// Doclet must handle empty body in package.html, must

@ -1,8 +1,7 @@
<HTML>
<BODY>
<!-- generate a syntax error to verify that the file is parsed -->
<pre>
&lt;opaque value="TRUE"/>
<123 value="TRUE"/>
</pre>
</BODY>
</HTML>

@ -1,10 +1,8 @@
InvalidTag.java:14: error: unknown tag: String
* List<String> list = new ArrayList<>();
^
InvalidTag.java:14: error: malformed HTML
* List<String> list = new ArrayList<>();
^
InvalidTag.java:14: error: bad use of '>'
* List<String> list = new ArrayList<>();
^
3 errors
2 errors

@ -1,32 +0,0 @@
/*
* Copyright (c) 2012, 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.
*
* 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.
*/
// key: compiler.err.dc.bad.gt
// key: compiler.note.note
// key: compiler.note.proc.messager
// run: backdoor
// options: -processor DocCommentProcessor -proc:only
/** > */
class BadGreaterThan { }

@ -23,7 +23,7 @@
/*
* @test
* @bug 7021614 8078320
* @bug 7021614 8078320 8247788
* @summary extend com.sun.source API to support parsing javadoc comments
* @modules jdk.compiler/com.sun.tools.javac.api
* jdk.compiler/com.sun.tools.javac.file
@ -93,13 +93,8 @@ DocComment[DOC_COMMENT, pos:1
void bad_gt() { }
/*
DocComment[DOC_COMMENT, pos:1
firstSentence: 3
Text[TEXT, pos:1, abc_]
Erroneous[ERRONEOUS, pos:5
code: compiler.err.dc.bad.gt
body: >
]
Text[TEXT, pos:6, _def]
firstSentence: 1
Text[TEXT, pos:1, abc_>_def]
body: empty
block tags: empty
]
@ -111,18 +106,13 @@ DocComment[DOC_COMMENT, pos:1
void bad_chars_start();
/*
DocComment[DOC_COMMENT, pos:1
firstSentence: 5
firstSentence: 3
Text[TEXT, pos:1, abc_]
Erroneous[ERRONEOUS, pos:5
code: compiler.err.dc.malformed.html
body: <
]
Text[TEXT, pos:6, p_123]
Erroneous[ERRONEOUS, pos:11
code: compiler.err.dc.bad.gt
body: >
]
Text[TEXT, pos:12, _def]
Text[TEXT, pos:6, p_123>_def]
body: empty
block tags: empty
]
@ -134,18 +124,13 @@ DocComment[DOC_COMMENT, pos:1
void bad_chars_end();
/*
DocComment[DOC_COMMENT, pos:1
firstSentence: 5
firstSentence: 3
Text[TEXT, pos:1, abc_]
Erroneous[ERRONEOUS, pos:5
code: compiler.err.dc.malformed.html
body: <
]
Text[TEXT, pos:6, /p_123]
Erroneous[ERRONEOUS, pos:12
code: compiler.err.dc.bad.gt
body: >
]
Text[TEXT, pos:13, _def]
Text[TEXT, pos:6, /p_123>_def]
body: empty
block tags: empty
]