-
Notifications
You must be signed in to change notification settings - Fork 5.8k
JDK-8307184: Incorrect/inconsistent specification and implementation for Elements.getDocComment #15062
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…for Elements.getDocComment
👋 Welcome back darcy! A progress list of the required criteria for merging this PR into |
/csr needed |
Webrevs
|
@jddarcy has indicated that a compatibility and specification (CSR) request is needed for this pull request. @jddarcy please create a CSR request for issue JDK-8307184 with the correct fix version. This pull request cannot be integrated until the CSR request is approved. |
Once we've settled on the spec changes, I'll populate the CSR accordingly. |
@@ -283,15 +283,32 @@ default Set<? extends ModuleElement> getAllModuleElements() { | |||
* <p> A documentation comment of an element is a comment that | |||
* begins with "{@code /**}", ends with a separate | |||
* "<code>*/</code>", and immediately precedes the element, | |||
* ignoring white space. Therefore, a documentation comment | |||
* ignoring white space and annotations and end-of-line-comments ({@code "//"} comments). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(minor/grammar)
instead of A and B and C
consider using A, B, and C
* of the doc comment starting after the initial "{@code /**}", | ||
* if the lines start with <em>zero</em> or more white space characters followed by | ||
* <em>one</em> or more "{@code *}" characters, | ||
* those leading white space characters are discarded as are any |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FWIW, I checked javac
and it allows form-feed in the leading whitespace characters
As an adjective "white space" is normally a single word, at least in JDK.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm. java.lang.Character contains both "whitespace" and "white space" in its textual comments.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, the difference is typically whitespace
(adjective) and white space
noun. But no matter.
void stringDiffer(String actual, String expected) { | ||
if (actual.length() != expected.length()) { | ||
System.out.println("Strings have different lengths"); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not critical, but for bonus points, you could identify the first line that is different.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you know of an existing utility usable in the JDK that does this?
(I didn't want to write a utility like that for the purpose of this bug.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ToolBox.checkEqual
General feedback: while the text is good at describing when non-newline characters are removed, it is less good at describing the treatment of newlines ... are they line-terminators or line-separators; how do such characters in the result of |
* Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do | ||
* eiusmod tempor incididunt ut labore et dolore magna aliqua. | ||
*/ | ||
@ExpectedComment( // Cannot used a text block here since leading spaces are removed |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could use a text block, by carefully adjusting the indentation of the trailing """
src/java.compiler/share/classes/javax/lang/model/util/Elements.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks good to me
Hmm. Does the precise handling of line terminators matter enough to specify? |
Mailing list message from Alex Buckley on compiler-dev: On 8/4/2023 1:33 PM, Joe Darcy wrote:
The JLS is careful to speak only of "white space" as a noun, never as an Alex |
PS FWIW, the javac implementation does normalize line terminators, test case added. |
Medium yes. For anyone parsing the contents of a doc comment, it helps to know whether the terminators are "as in the source file" or "always |
System.out.println("Expected"); | ||
System.out.println(expectedCommentStr); | ||
stringDiffer(actualComment, expectedCommentStr); | ||
(new ToolBox()).checkEqual(expectedCommentStr.lines().toList(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
:-)
I guess for anyone doing character-based parsing, handling line-ending sequences is no biggie. For folk doing line-based parsing |
@jddarcy This change now passes all automated pre-integration checks. ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details. After integration, the commit message for the final commit will be:
You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed. At the time when this comment was updated there had been 43 new commits pushed to the
As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details. ➡️ To integrate this PR with the above commit message to the |
/integrate |
Going to push as commit c307391.
Your commit was automatically rebased without conflicts. |
Start by just reformatting the existing specs to highlight subsequent spec changes.
Progress
Issues
Reviewers
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/15062/head:pull/15062
$ git checkout pull/15062
Update a local copy of the PR:
$ git checkout pull/15062
$ git pull https://git.openjdk.org/jdk.git pull/15062/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 15062
View PR using the GUI difftool:
$ git pr show -t 15062
Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/15062.diff
Webrev
Link to Webrev Comment