Skip to content

Conversation

@vy
Copy link
Contributor

@vy vy commented May 30, 2025

Passes the Charset read from the stdin.encoding system property while creating InputStreamReader or Scanner instances for System.in.

stdin.encoding is a recently added property for Java 25 in JDK-8350703. Employing it throughout the entire code base is addressed by the parent ticket JDK-8356893. JDK-8357993 this PR is addressing is a sub-task of JDK-8356893 and is concerned with only areas related to Hotspot.


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-8357993: Use "stdin.encoding" for reading System.in with InputStreamReader/Scanner [hotspot] (Sub-task - P4)

Reviewers

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 25542

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

Using diff file

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

Using Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented May 30, 2025

👋 Welcome back vyazici! 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 May 30, 2025

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

8357993: Use "stdin.encoding" for reading System.in with InputStreamReader/Scanner [hotspot]

Reviewed-by: cjplummer, sspitsyn

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 196 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 added the rfr Pull request is ready for review label May 30, 2025
@openjdk
Copy link

openjdk bot commented May 30, 2025

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

  • hotspot-jfr
  • serviceability

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 serviceability serviceability-dev@openjdk.org hotspot-jfr hotspot-jfr-dev@openjdk.org labels May 30, 2025
@mlbridge
Copy link

mlbridge bot commented May 30, 2025

Webrevs

Copy link
Contributor

@plummercj plummercj left a comment

Choose a reason for hiding this comment

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

Changes look good. Can you clarify your testing?

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Jun 2, 2025
@vy
Copy link
Contributor Author

vy commented Jun 3, 2025

Can you clarify your testing?

@plummercj, green tier1,2 results on 45bdc4f are attached to the ticket. Would they suffice?

@AlanBateman
Copy link
Contributor

/reviewers 2

@openjdk
Copy link

openjdk bot commented Jun 3, 2025

@AlanBateman
The total number of required reviews for this PR (including the jcheck configuration and the last /reviewers command) is now set to 2 (with at least 1 Reviewer, 1 Author).

@openjdk openjdk bot removed the ready Pull request is ready to be integrated label Jun 3, 2025
@AlanBateman
Copy link
Contributor

/reviewers 1

@openjdk
Copy link

openjdk bot commented Jun 3, 2025

@AlanBateman
The total number of required reviews for this PR (including the jcheck configuration and the last /reviewers command) is now set to 1 (with at least 1 Reviewer).

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Jun 3, 2025
@plummercj
Copy link
Contributor

Can you clarify your testing?

@plummercj, green tier1,2 results on 45bdc4f are attached to the ticket. Would they suffice?

That's not going to be sufficient. The nsk tests are not being run until tier5.

@vy
Copy link
Contributor Author

vy commented Jun 5, 2025

That's not going to be sufficient. The nsk tests are not being run until tier5.

@plummercj, I've attached the tier3,4,5 run report to the ticket, would you mind reviewing them, please?

@plummercj
Copy link
Contributor

That's not going to be sufficient. The nsk tests are not being run until tier5.

@plummercj, I've attached the tier3,4,5 run report to the ticket, would you mind reviewing them, please?

Looks good.

Copy link
Contributor

@sspitsyn sspitsyn left a comment

Choose a reason for hiding this comment

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

Looks okay to me.

@vy
Copy link
Contributor Author

vy commented Jun 6, 2025

@AlanBateman @plummercj @sspitsyn Thanks so much for taking time to review the changes, much appreciated. 🙇

/integrate

@openjdk
Copy link

openjdk bot commented Jun 6, 2025

Going to push as commit bb2611a.
Since your change was applied there have been 203 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 Jun 6, 2025
@openjdk openjdk bot closed this Jun 6, 2025
@openjdk openjdk bot removed ready Pull request is ready to be integrated rfr Pull request is ready for review labels Jun 6, 2025
@openjdk
Copy link

openjdk bot commented Jun 6, 2025

@vy Pushed as commit bb2611a.

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

@AlanBateman
Copy link
Contributor

@AlanBateman @plummercj @sspitsyn Thanks so much for taking time to review the changes, much appreciated.

Okay, but I'm still puzzled as to why the tests were changed as they don't ready from the console.

@vy
Copy link
Contributor Author

vy commented Jun 6, 2025

Okay, but I'm still puzzled as to why the tests were changed as they don't ready from the console.

@AlanBateman, I only skipped the practice of passing stdin.encoding to InputStreamReader/Scanner ctors whenever it is obvious that the System.in referred there is not the console. Do you imply I was mistaken while assessing BindServer and attach010Agent00? If so, which ones, and [to learn what I missed] why? I can create a follow-up ticket+PR to amend them.

@vy vy deleted the stdinEnc-hotspot branch June 6, 2025 08:06
@AlanBateman
Copy link
Contributor

@AlanBateman, I only skipped the practice of passing stdin.encoding to InputStreamReader/Scanner ctors whenever it is obvious that the System.in referred there is not the console. Do you imply I was mistaken while assessing BindServer and attach010Agent00? If so, which ones, and [to learn what I missed] why? I can create a follow-up ticket+PR to amend them.

Tests are automated and very rare to have tests read from an interactive console. A small number of test uses "expect" for testing interactive input. There might be tests that have stdin redirected from a file or something else.

For multi VM tests (very common in the test suite) then you typically see the parent process using Process/ProcessBuilder and starting a child VM with its standard streams connected to the parent, meaning reading from System.in will read from a pipe connected to the parent. Some tests do inherit but I doubt we have any tests that inherit and also read from an interactive console.

So my point is that we probably don't need to jump on all tests that use System.in. The tests that do read from System.in probably need closer examination to see if they are reading from a pipe or something else.

@vy
Copy link
Contributor Author

vy commented Jun 6, 2025

For multi VM tests (very common in the test suite) then you typically see the parent process using Process/ProcessBuilder and starting a child VM with its standard streams connected to the parent, meaning reading from System.in will read from a pipe connected to the parent. Some tests do inherit but I doubt we have any tests that inherit and also read from an interactive console.

So my point is that we probably don't need to jump on all tests that use System.in.

I think 😅 I see your point, and I agree with it. I've dropped several of my earlier changes from the abandoned parent #25368 – this applies to all subsequent tickets: #25544 (core), #25541 (tools), and this one. When the subject code is called in a Process, or the stream is obtained from a URL or a ClassLoader, ..., when it is "obvious" that the stream doesn't refer to the console, I've skipped the stdin.encoding refactoring. That said, "obvious" is very subjective and I might have misjudged certain usages.

The tests that do read from System.in probably need closer examination to see if they are reading from a pipe or something else.

In all stdin.encoding PRs – #25544 (core), #25541 (tools), and this one – I've examined usages before introducing the changes. I did my best, but I cannot claim it was exhaustive. That said, if it requires a significant effort to deduce that the console is not involved in a System.in usage, I'd prefer to include the stdin.encoding best-practice. There is a considerable likelihood that a later change could inadvertently violate that subtle assumption.

@AlanBateman, if you think a particular change needs closer examination or needs to be reverted, please say so. I'd be more than happy to carry out that task.

@plummercj
Copy link
Contributor

BindServer.java is not used. It can be removed.

The changes in attach010Agent00.java are unnecessary because System.in has been set to read from a file:

35 private static final String inStreamFileName = "AttachOnDemand.attach010.in";
60 FileInputStream newInputStream = new FileInputStream(inStreamFileName);
61 System.setIn(newInputStream);

@vy
Copy link
Contributor Author

vy commented Jun 8, 2025

@plummercj, shall I create a ticket+PR to

  1. remove BindServer.java, and
  2. revert changes to attach010Agent00.java?

@plummercj
Copy link
Contributor

@plummercj, shall I create a ticket+PR to

1. remove `BindServer.java`, and

2. revert changes to `attach010Agent00.java`?

Yes. It might be better to make them 2 PRs.

@vy
Copy link
Contributor Author

vy commented Jun 10, 2025

I've created

  • 8359167: Remove unused test/hotspot/jtreg/vmTestbase/nsk/share/jpda/BindServer.java
  • 8359168: Revert stdin.encoding usage in test/hotspot/jtreg/vmTestbase/nsk/jvmti/AttachOnDemand/attach010/attach010Agent00.java

Used hotspot and test as Component/s and Subcomponent, respectively – hope that is okay. Feel free to update the tickets as you see fit. I will try to pick them up sometime this week.

@plummercj, @AlanBateman, thank you for your assistance and patience. 🙇

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

hotspot-jfr hotspot-jfr-dev@openjdk.org integrated Pull request has been integrated serviceability serviceability-dev@openjdk.org

Development

Successfully merging this pull request may close these issues.

4 participants