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
8265356: need code example for getting canonical constructor of a Record #3556
Conversation
👋 Welcome back tvaleev! A progress list of the required criteria for merging this PR into |
Webrevs
|
Thanks for writing this example. I think that the example lines can be longer. I'd suggest putting the main part of the method declaration on the same line as I think including the small cleanups (1) and (2) in this PR is fine. Changing One other thing I'd like to see is a link to this example code from places where people are likely to look for it. The class doc for |
@stuart-marks thank you for review. How about this note in Record class? I wrote it in a more general manner, without mentioning canonical constructors explicitly. Is it enough? |
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.
Overall looks fine modulo adding @apiNote
. Since the changes are all either editorial/markup or informational, I don't think this needs a CSR. Well, the removal of an unused type variable strictly constitutes a signature change, but those methods aren't public APIs so I still think it's ok without a CSR.
@@ -2361,6 +2361,18 @@ public Method getMethod(String name, Class<?>... parameterTypes) | |||
* Conversely, if {@link #isRecord()} returns {@code true}, then this method | |||
* returns a non-null value. | |||
* |
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 forgot to mention, this example should be within an @apiNote
.
@amaembo 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 265 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 |
Thank you! I also changed 'This method' to 'The following method', as it looks like this wording is more commonly used in OpenJDK specs. |
/integrate |
@amaembo Since your change was applied there have been 265 commits pushed to the
Your commit was automatically rebased without conflicts. Pushed as commit 3e667cc. 💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored. |
I decided to show a complete static method in the example, so it could be copied to user utility class as is. Not sure if it's reasonable to add
assert cls.isRecord();
there. Also I don't know whether there's a limitation on max characters in the sample code. Probable a line break instatic <T extends Record>\nConstructor<T> getCanonicalConstructor(Class<T> cls)
is unnecessary.Aside from this PR, I've found a couple of things to clean up in
java.lang.Class
:getSimpleName()
JavaDoc (introduced by @jddarcy in 8254979: Class.getSimpleName() returns non-empty for lambda and method #3038). It should be#isArray()
instead ofisArray()
.<T>
.java.lang.Record
initialized too early or increasing the footprint of such a basic class in the metaspace, so I don't insist on this.Please tell me if it's ok to fix 1 and 2 along with this PR.
Progress
Issue
Reviewers
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.java.net/jdk pull/3556/head:pull/3556
$ git checkout pull/3556
Update a local copy of the PR:
$ git checkout pull/3556
$ git pull https://git.openjdk.java.net/jdk pull/3556/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 3556
View PR using the GUI difftool:
$ git pr show -t 3556
Using diff file
Download this PR as a diff file:
https://git.openjdk.java.net/jdk/pull/3556.diff