Skip to content

Conversation

@jddarcy
Copy link
Member

@jddarcy jddarcy commented Sep 13, 2024

Candidates for this refactoring were found programmatically; the program to find candidates is in a comment on the bug.


Progress

  • Change must be properly reviewed (1 review required, with at least 1 Reviewer)
  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue

Issue

  • JDK-8340082: Use inline return tag in java.base (Enhancement - P4)

Reviewers

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/20981/head:pull/20981
$ git checkout pull/20981

Update a local copy of the PR:
$ git checkout pull/20981
$ git pull https://git.openjdk.org/jdk.git pull/20981/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 20981

View PR using the GUI difftool:
$ git pr show -t 20981

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/20981.diff

Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Sep 13, 2024

👋 Welcome back darcy! A progress list of the required criteria for merging this PR into master will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

@openjdk
Copy link

openjdk bot commented Sep 13, 2024

@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:

8340082: Use inline return tag in java.base

Reviewed-by: iris, prappo, lancea, djelinski, naoto, liach

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 13 new commits pushed to the master branch:

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 master branch, type /integrate in a new comment.

@openjdk openjdk bot changed the title JDK-8340082: Use inline return tag in java.base 8340082: Use inline return tag in java.base Sep 13, 2024
@openjdk openjdk bot added the rfr Pull request is ready for review label Sep 13, 2024
@openjdk
Copy link

openjdk bot commented Sep 13, 2024

@jddarcy The following labels will be automatically applied to this pull request:

  • core-libs
  • i18n
  • nio
  • security

When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing lists. If you would like to change these labels, use the /label pull request command.

@openjdk openjdk bot added security security-dev@openjdk.org nio nio-dev@openjdk.org core-libs core-libs-dev@openjdk.org i18n i18n-dev@openjdk.org labels Sep 13, 2024
@mlbridge
Copy link

mlbridge bot commented Sep 13, 2024

Webrevs

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Sep 13, 2024
Copy link

@ExE-Boss ExE-Boss left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The old version of the doc comments had a . at the end of the first sentence:

/**
* Returns the pattern used to create this filter.
* @return the pattern used to create this filter
* {@return the pattern used to create this filter}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* {@return the pattern used to create this filter}
* {@return the pattern used to create this filter}.

/**
* Returns the number of bytes read from the input stream.
* @return the number of bytes read from the input stream
* {@return the number of bytes read from the input stream}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* {@return the number of bytes read from the input stream}
* {@return the number of bytes read from the input stream}.

/**
* Returns the retention policy.
* @return the retention policy
* {@return the retention policy}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* {@return the retention policy}
* {@return the retention policy}.

/**
* Returns the length of the input.
* @return the length of the input
* {@return the length of the input}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* {@return the length of the input}
* {@return the length of the input}.

/**
* Returns the message.
* @return the message
* {@return the message}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* {@return the message}
* {@return the message}.

Comment on lines +295 to +296
* {@return true if the end of the compressed data stream has been
* reached}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* {@return true if the end of the compressed data stream has been
* reached}
* {@return true if the end of the compressed data stream has been
* reached}.

/**
* Returns the ADLER-32 value of the uncompressed data.
* @return the ADLER-32 value of the uncompressed data
* {@return the ADLER-32 value of the uncompressed data}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* {@return the ADLER-32 value of the uncompressed data}
* {@return the ADLER-32 value of the uncompressed data}.

/**
* Returns the name of the entry.
* @return the name of the entry
* {@return the name of the entry}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* {@return the name of the entry}
* {@return the name of the entry}.

/**
* Returns the path name of the ZIP file.
* @return the path name of the ZIP file
* {@return the path name of the ZIP file}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* {@return the path name of the ZIP file}
* {@return the path name of the ZIP file}.

/**
* Returns an enumeration of the ZIP file entries.
* @return an enumeration of the ZIP file entries
* {@return an enumeration of the ZIP file entries}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* {@return an enumeration of the ZIP file entries}
* {@return an enumeration of the ZIP file entries}.

@pavelrappo
Copy link
Member

The old version of the doc comments had a . at the end of the first sentence:

The new version has it too, but in the final, generated form: https://docs.oracle.com/en/java/javase/22/docs/specs/javadoc/doc-comment-spec.html#return

{@return blah} expands to Returns blah.

Copy link
Member

@pavelrappo pavelrappo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, Joe. This looks good, especially considering that the change was produced with the help of a quick-and-dirty, regex-based script. This change is certainly enough to spread awareness of this relatively new javadoc feature.

I remember I had a more involved script that used javax.lang.model and string similarity metrics. That script captured a lot more candidates for {@return}. But on the other hand, once you start considering non-exact matches, it requires human judgement and increases review effort.


Separately, this PR has helped me put a finger on what I don't like about {@return}. What I don't like is the generated HTML. {@return} saves mental effort when reading raw javadoc in source, but it provides no similar service to the reader of the final, HTML form. Maybe it's just me, but it looks needlessly bloated and silly:

browser screenshot of javax.lang.model.element.AnnotationValue#getValue

Maybe if a method's main description consisted only of {@return}, we could skip the first sentence in the "Method Details" section and just output Returns:? Any further discussion should happen on the javadoc-dev mailing list.

Copy link
Contributor

@LanceAndersen LanceAndersen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I went through the changes and they look fine.

@liach
Copy link
Member

liach commented Sep 13, 2024

This patch only captures one-line returns without extra sentences. Is it possible for us to handle slightly more complex documentations like ParameterizedType::getActualTypeArguments?

* Returns an array of {@code Type} objects representing the actual type
* arguments to this type.
*
* <p>Note that in some cases, the returned array be empty. This can occur
* if this type represents a non-parameterized type nested within
* a parameterized type.
*
* @return an array of {@code Type} objects representing the actual type
* arguments to this type

@pavelrappo
Copy link
Member

This patch only captures one-line returns without extra sentences. Is it possible for us to handle slightly more complex documentations like ParameterizedType::getActualTypeArguments?

Sure, it is possible. However, there's a tradeoff between comprehensiveness and the effort required. Joe's script provides a lot for a little.

If there's interest in it, we could file follow-up bugs to fix more cases with more powerful tools.

Copy link
Member

@naotoj naotoj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

java.nio.charset and java.time.format changes look good

@jddarcy
Copy link
Member Author

jddarcy commented Sep 13, 2024

This patch only captures one-line returns without extra sentences. Is it possible for us to handle slightly more complex documentations like ParameterizedType::getActualTypeArguments?

Sure, it is possible. However, there's a tradeoff between comprehensiveness and the effort required. Joe's script provides a lot for a little.

If there's interest in it, we could file follow-up bugs to fix more cases with more powerful tools.

Yes, the quick and dirty program is only a "minimum viable product" level of functionality. It is not complete and doesn't catch all cases. Future improvements welcome!

Copy link
Member

@liach liach left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. It might be feasible to run a more complex tool that analyzes the tokenized javadoc AST from javac as later work.

Annotation changes look good.

@jddarcy
Copy link
Member Author

jddarcy commented Sep 13, 2024

/integrate

@openjdk
Copy link

openjdk bot commented Sep 13, 2024

Going to push as commit 89c172a.
Since your change was applied there have been 13 commits pushed to the master branch:

Your commit was automatically rebased without conflicts.

@openjdk openjdk bot added the integrated Pull request has been integrated label Sep 13, 2024
@openjdk openjdk bot closed this Sep 13, 2024
@openjdk openjdk bot removed ready Pull request is ready to be integrated rfr Pull request is ready for review labels Sep 13, 2024
@openjdk
Copy link

openjdk bot commented Sep 13, 2024

@jddarcy Pushed as commit 89c172a.

💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored.

@jddarcy jddarcy deleted the JDK-8340082 branch October 17, 2024 16:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core-libs core-libs-dev@openjdk.org i18n i18n-dev@openjdk.org integrated Pull request has been integrated nio nio-dev@openjdk.org security security-dev@openjdk.org

Development

Successfully merging this pull request may close these issues.

8 participants