-
Notifications
You must be signed in to change notification settings - Fork 6.2k
8355371: NegativeArraySizeException in print methods in IO or System.console() in JShell #24897
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
|
Hi @tats-u, welcome to this OpenJDK project and thanks for contributing! We do not recognize you as Contributor and need to ensure you have signed the Oracle Contributor Agreement (OCA). If you have not signed the OCA, please follow the instructions. Please fill in your GitHub username in the "Username" field of the application. Once you have signed the OCA, please let us know by writing If you already are an OpenJDK Author, Committer or Reviewer, please click here to open a new issue so that we can record that fact. Please use "Add GitHub user tats-u" as summary for the issue. If you are contributing this work on behalf of your employer and your employer has signed the OCA, please let us know by writing |
|
@tats-u 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 91 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. As you do not have Committer status in this project an existing Committer must agree to sponsor your change. Possible candidates are the reviewers of this PR (@liach, @lahodaj) but any other Committer may sponsor as well. ➡️ To flag this PR as ready for integration with the above commit message, type |
| buffer[bp++] = b; | ||
| // Can be negative because directly casted from byte. | ||
| // java.io.OutputStream.write(int b) stipulates "The 24 high-order bits of b are ignored." | ||
| buffer[bp++] = b & 0xff; |
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 think the cause is that OutputStream.write(byte[], int, int) provides negative bytes. I recommend you to update the "can be negative" comment above to be like:
// Can be negative because widening from byte in write(byte[], int, int).
Also note, there is another usage of b below in case READ_CHARS -> but I think it is also a bug; it should be readInt(1).
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 think the cause is that OutputStream.write(byte[], int, int) provides negative bytes.
I seem to recall that perhaps so. Your suggestion is better.
it should be readInt(1).
Do you mean int len = readInt(b);? I will update it but unfortunately I have no idea which is correct. Do you have any idea to test that the fix is correct?
I could not tell the difference in jshell by playing with some input.
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.
Yep, that readInt is probably fine because the buffer is large enough, plus the result is unused, so there was no observable consequence.
Also in principle, we will not approve patches unless oca is cleared; meanwhile please update the 2024 last updated year in the license header of 2 files to 2025. (I thought this rule was mentioned in the guide, but apparently it wasnt!)
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.
Which notation is the best?
- 2023-2025 (uses the ASCII hypen)
- 2023–2025 (uses U+2013 EN dash)
- 2023, 2024, 2025
Looks like "Copyright (c) A, B" means the the closed interval [A, B] (i.e. A–B).
Is "2023, 2025" correct?
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.
Yep, Copyright (c) 2023, 2025, Oracle is correct.
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.
Thank you. Does the current change look good to you?
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. But I will get a more professional jshell reviewer to double check once the oca is resolved.
|
Newcomer notes:
|
|
/signed |
|
Thank you! Please allow for up to two weeks to process your OCA, although it is usually done within one to two business days. Also, please note that pull requests that are pending an OCA check will not usually be evaluated, so your patience is appreciated! |
|
/issue JDK-8354910 |
|
@tats-u |
Co-authored-by: Chen Liang <liach@openjdk.org>
Co-authored-by: Chen Liang <liach@openjdk.org>
Webrevs
|
liach
left a comment
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.
Thank you for the wait and the fix!
Since @lahodaj works more closely with JShell, please wait for a review from Lahoda before typing integrate command.
lahodaj
left a comment
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, thanks!
My only slight worry is with the UTF-8 character - please see the inline comment.
|
@liach Could you review the latest commit again? Sorry for bothering you. |
liach
left a comment
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.
The char update looks good.
|
Let's wait for Jan - I think it is holiday for Jan so you might need to wait for a few days. |
lahodaj
left a comment
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, thanks!
|
@lahodaj Thank you for your approval. /integrate |
|
FWIW, I have ran tests just to be sure, turned out OK. It is a bit late for me right before the weekend, so I am a bit reluctant to sponsor right now. Unless @liach sponsors before that, I'll sponsor on Monday morning. |
|
I got it. Have a nice weekend. |
|
/sponsor |
|
Going to push as commit c8ce61c.
Your commit was automatically rebased without conflicts. |
This PR will fix not only JDK-8355371 but also JDK-8354910. I chose the more serious one.
Note: according to JEP-512 (JDK-8344699), java.io.IO is going to stop using System.console().
I confirmed it by checking out and building #24438. (in that PR, the bug does not occur in
IO.print(ln))Before (Temurin 24):
After (master & without #24438):
I don't know how to prepare the template other PRs use or whether outsiders like me may create a PR.
Progress
Issues
Reviewers
Reviewing
Using
gitCheckout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/24897/head:pull/24897$ git checkout pull/24897Update a local copy of the PR:
$ git checkout pull/24897$ git pull https://git.openjdk.org/jdk.git pull/24897/headUsing Skara CLI tools
Checkout this PR locally:
$ git pr checkout 24897View PR using the GUI difftool:
$ git pr show -t 24897Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/24897.diff
Using Webrev
Link to Webrev Comment