The primary problem was that key `compiler.err.dc.ref.bad.parens` had the wrong 
message "')' missing in reference". That error message is not used when the 
right parenthesis is missing, but when it occurs before the end of the 
signature. The missing parenthesis case is caught earlier by the parens 
balancing code in `DocCommentParser#reference` and uses message 
`compiler.err.dc.unterminated.signature` ("unterminated signature").

I changed the message for `compiler.err.dc.ref.bad.parens` to "unexpected 
parenthesis". 

A secondary problem was that `DocCommentParser#reference` also threw 
"unterminated signature" when there were too many closing angle brackets or 
parentheses. These cases are now passed through in`DocCommentParser#reference` 
so that `ReferenceParser#parse` can throw a more appropriate error ("unexpected 
parenthesis" or "unexpected input"). 

Here's a list of what references now cause what error messages:

 - `#foo(int`     `unterminated signature`
 - `#foo((int))`   `unexpected parenthesis`
 - `#foo(int))`   `unexpected parenthesis`
 - `#foo(int)x`   `unexpected parenthesis`
 - `F<T`        `unterminated signature`
 - `F<T>>`    `unexpected input`

I added two new tests for the cases with too many closing brackets/parens that 
used to fail with "unterminated signature".

-------------

Commit messages:
 - JDK-8264181: javadoc tool Incorrect error message about malformed link

Changes: https://git.openjdk.java.net/jdk/pull/4068/files
 Webrev: https://webrevs.openjdk.java.net/?repo=jdk&pr=4068&range=00
  Issue: https://bugs.openjdk.java.net/browse/JDK-8264181
  Stats: 38 lines in 4 files changed: 33 ins; 0 del; 5 mod
  Patch: https://git.openjdk.java.net/jdk/pull/4068.diff
  Fetch: git fetch https://git.openjdk.java.net/jdk pull/4068/head:pull/4068

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

Reply via email to