RFR: 8247957: remove doclint support for HTML 4 [v5]

Yoshiki Sato ysatowse at openjdk.java.net
Wed Dec 23 07:54:02 UTC 2020

On Wed, 23 Dec 2020 05:38:36 GMT, Yoshiki Sato <ysatowse at openjdk.org> wrote:

>> src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclint/Checker.java line 736:
>>> 734: 
>>> 735:     // https://html.spec.whatwg.org/#the-id-attribute
>>> 736:     private static final Pattern validId = Pattern.compile("[^\s]+");
>> The regular expression is invalid and needs to be fixed. It should be `Pattern.compile("[^\\s]+")`
>> Note the extra `` character. This is because you need to escape the `` character in the string constant, so that the `` is seen in the pattern as part of `\s`.
> Correct.  Thanks a lot for finding this error.  
> Now that I have doubts why this line could have been compiled without error.  This line should cause a compiler error.
> Let me review all anchor tests again because the logic should be checked there.

For some reason, `"[^\s]+"` might have been dealt with as a text block, thus `\s` was regarded as a whitespace...
I believe a text block is defined with triple double quotes, but javac seems to accept `"[^\s]+"` as a text block.

That aside, all anchor tests look fine.  This is because there is no specific test to use whitespace characters such as `\n`, `\t`, `\r` and `\f` in an anchor name.  Also I confirmed the discrepancy of the results for `"[^\s]+"` and `"[^\\s]+"`.  It shows that the former is not exactly what we want to do.

$ jshell -J-Duser.language=en -J--show-version
java 15 2020-09-15
Java(TM) SE Runtime Environment (build 15+36-1562)
Java HotSpot(TM) 64-Bit Server VM (build 15+36-1562, mixed mode, sharing)
|  Welcome to JShell -- Version 15
|  For an introduction type: /help intro

jshell> Pattern validId1 = Pattern.compile("[^\s]+")
validId1 ==> [^ ]+

jshell> Pattern validId2 = Pattern.compile("[^\\s]+")
validId2 ==> [^\s]+

jshell> validId1.matcher("aaa").matches()
$3 ==> true

jshell> validId1.matcher("aaa ").matches()
$4 ==> false

jshell> validId1.matcher("aaa\n").matches()
$5 ==> true

jshell> validId2.matcher("aaa").matches()
$6 ==> true

jshell> validId2.matcher("aaa ").matches()
$7 ==> false

jshell> validId2.matcher("aaa\n").matches()
$8 ==> false


PR: https://git.openjdk.java.net/jdk/pull/893

More information about the compiler-dev mailing list