Skip to content

Conversation

@ktakakuri
Copy link
Member

@ktakakuri ktakakuri commented Feb 10, 2025

To resolve runtime/os/windows/TestAvailableProcessors.java failure, I made "systeminfo.exe" executed with "chcp 437". This ensures that the English message "OS Version: " is output on localized windows platforms.
I added the path C:\Windows\System32 to make chcp command recognized on the GHA Windows test machine. Without this addition, GHA will fail.
After this fix, I verified that the test passed.

#22142
I refer to this fix.
tools/jpackage/windows/Win8301247Test.java does not run in GHA, so the problems with recognition of chcp command did not occur before.

Thanks.


Progress

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

Issue

  • JDK-8349288: runtime/os/windows/TestAvailableProcessors.java fails on localized Windows platform (Bug - P4)

Reviewers

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 23536

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

Using diff file

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

Using Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Feb 10, 2025

👋 Welcome back ktakakuri! 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 Feb 10, 2025

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

8349288: runtime/os/windows/TestAvailableProcessors.java fails on localized Windows platform

Reviewed-by: dholmes, alanb

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 2002 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.

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 (@dholmes-ora, @AlanBateman) but any other Committer may sponsor as well.

➡️ To flag this PR as ready for integration with the above commit message, type /integrate in a new comment. (Afterwards, your sponsor types /sponsor in a new comment to perform the integration).

@openjdk openjdk bot added the rfr Pull request is ready for review label Feb 10, 2025
@openjdk
Copy link

openjdk bot commented Feb 10, 2025

@ktakakuri The following label will be automatically applied to this pull request:

  • hotspot-runtime

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

@openjdk openjdk bot added the hotspot-runtime hotspot-runtime-dev@openjdk.org label Feb 10, 2025
@mlbridge
Copy link

mlbridge bot commented Feb 10, 2025

Copy link
Member

@dholmes-ora dholmes-ora left a comment

Choose a reason for hiding this comment

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

@ktakakuri I need to evaluate whether this is a general purpose fix that should work everywhere.

Comment on lines 67 to 68
command.addAll(List.of("cmd.exe", "/c", "set", "PATH=%PATH%;C:\\Windows\\System32;C:\\Windows\\System32\\wbem", "&&"));
command.addAll(List.of("chcp", "437", ">nul", "2>&1", "&&"));
Copy link
Member

Choose a reason for hiding this comment

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

I see the use of chcp in the test ./tools/jpackage/helpers/jdk/jpackage/test/Executor.java so that is okay. However it doesn't set the path and it does not seem necessary to do so, and potentially assumes what the paths are anyway. So I think you can simplify this a little.

Copy link
Member Author

Choose a reason for hiding this comment

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

As well as tools/jpackage/windows/Win8301247Test.java, the tools tests is not included in jdk/tier1, so it will not run in GHA?

Copy link
Member

Choose a reason for hiding this comment

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

Sorry I'm not sure what you are asking.

Copy link
Member Author

Choose a reason for hiding this comment

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

I think tools/jpackage/helpers/jdk/jpackage/test/Executor.java is not run in GHA.

Copy link
Member

Choose a reason for hiding this comment

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

Correct. That is a tier2 test and IIUC GHA only runs tier1.

But I'm not sure why you're asking. I was pointing out that the jpackage test uses chcp in a simpler way than you have used, so I was suggesting you simplify your code and see if it still works.

Copy link
Member Author

@ktakakuri ktakakuri Mar 21, 2025

Choose a reason for hiding this comment

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

Running TestAvailableProcessors.java in GHA without adding the PATH failed. Additional processing is required to pass GHA.
Since the jpackage tests are not run in GHA, there is no need to add PATH.

Copy link
Member

Choose a reason for hiding this comment

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

Hmmm .... okay. This is ony a test so if things go wrong we can re-adjust the test.

Comment on lines 67 to 68
command.addAll(List.of("cmd.exe", "/c", "set", "PATH=%PATH%;C:\\Windows\\System32;C:\\Windows\\System32\\wbem", "&&"));
command.addAll(List.of("chcp", "437", ">nul", "2>&1", "&&"));
Copy link
Member

Choose a reason for hiding this comment

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

Hmmm .... okay. This is ony a test so if things go wrong we can re-adjust the test.

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Mar 21, 2025
@ktakakuri
Copy link
Member Author

/integrate

@openjdk openjdk bot added the sponsor Pull request is ready to be sponsored label Mar 24, 2025
@openjdk
Copy link

openjdk bot commented Mar 24, 2025

@ktakakuri
Your change (at version 890f013) is now ready to be sponsored by a Committer.

@dholmes-ora
Copy link
Member

@ktakakuri hotspot changes require two reviews. I will try to drum up another reviewer.

@sendaoYan
Copy link
Member

/reviewers 2

@openjdk
Copy link

openjdk bot commented Mar 25, 2025

@sendaoYan Only the author of the pull request or Reviewers are allowed to change the number of required reviewers.

var processBuilder = new ProcessBuilder(systeminfoPath);
List<String> command = new ArrayList<>();
// Force language to English before running systeminfo to get the OS version
command.addAll(List.of("cmd.exe", "/c", "set", "PATH=%PATH%;C:\\Windows\\System32;C:\\Windows\\System32\\wbem", "&&"));
Copy link
Contributor

Choose a reason for hiding this comment

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

Not sure about hardcoding C:\Windows in tests as Windows could be installed on a different volume. Don't you need to use the value of %SystemRoot% to the directory?

Copy link
Member

Choose a reason for hiding this comment

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

I thought it unfortunate that a path needed to be specified, but there is a precedent for assuming C:\Windows:

./jdk/java/lang/ProcessHandle/ProcessUtil.java:   
     return Platform.isWindows() && p.info().command().orElse("").endsWith("C:\\Windows\\System32\\conhost.exe");

though a more general approach would be similar to ./jdk/java/lang/RuntimeTests/exec/WinCommand.java:

     File systemRoot =
            getenv("SystemRoot") != null ? new File(getenv("SystemRoot")) :
            getenv("WINDIR")     != null ? new File(getenv ("WINDIR")) :
            null;
        if (systemRoot == null || ! systemRoot.isDirectory())
            return; // Not Windows as we know it

        String systemDirW = new File(systemRoot, "System32").getPath();

I was also reminded that testing under non-US-English locales is not really supported:
https://htmlpreview.github.io/?https://raw.githubusercontent.com/openjdk/jdk/master/doc/building.html#windows

The recommended and supported way of building the JDK on Windows is to set both the system locale and the user locale to US English. The system setting can be changed by going to the Control Panel, choosing "Regional Settings" -> "Administrative" and then pressing on the "Change System Locale" button.

Since this is annoying for users who prefer another locale, we strive to get the building and testing to work on other locales as well. This is on a "best effort" level, so beware! You might get odd results in both building and testing. If you do, remember that locales other than US English are not supported nor recommended.

It is also imperative to install the US English language pack in Visual Studio. For details, see Microsoft Visual Studio.

Copy link
Member Author

Choose a reason for hiding this comment

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

Thank you for your review. I changed it to use System.getenv().

@openjdk openjdk bot removed sponsor Pull request is ready to be sponsored ready Pull request is ready to be integrated labels Apr 11, 2025
@dholmes-ora
Copy link
Member

I need to re-test this in our CI system.

@dholmes-ora
Copy link
Member

@ktakakuri please merge this with latest master as it is getting along way behind - thanks.

System.getenv("WINDIR") != null ? new File(System.getenv ("WINDIR")) :
null;
if (systemRoot == null || ! systemRoot.isDirectory())
return; // Not Windows as we know it
Copy link
Member

Choose a reason for hiding this comment

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

This doesn't compile - the function returns a String.

Copy link
Member Author

Choose a reason for hiding this comment

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

Even if systemRoot fails to recognize the system, it does not matter if chcp can be executed, so I removed the judgment.

Copy link
Member

@dholmes-ora dholmes-ora left a comment

Choose a reason for hiding this comment

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

Thanks for update. Nothing further from me.

As we are passed RDP1 this will get commited into JDK 26, but as a test fix it is also eligible to be backported to JDK 25 if you chose.

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Jun 9, 2025
@ktakakuri
Copy link
Member Author

@AlanBateman This PR requires two approvals. I apologize for the long delay, but could you review it?

if (systemRoot == null) {
throw new RuntimeException("SystemRoot or WINDIR environment variable is not set.");
}
String systemDirW = new File(systemRoot, "System32").getPath();
Copy link
Contributor

Choose a reason for hiding this comment

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

A drive-by comment is that you could remove the duplicate calls to getenv and just use a simple Path resolve. e.g.

        String systemRoot = System.getenv("SystemRoot");
        if (systemRoot == null) {
            systemRoot = System.getenv("WINDIR");
            if (systemRoot == null) {
                // throw
            }
        }
        String system32 = Path.of(systemRoot, "System32").toString();

// Force language to English before running systeminfo to get the OS version
command.addAll(List.of("cmd.exe", "/c", "set", "PATH=%PATH%;" + systemDirW + ";" + systemDirW + "\\wbem", "&&"));
command.addAll(List.of("chcp", "437", ">nul", "2>&1", "&&"));
command.add(systeminfoPath);
Copy link
Contributor

Choose a reason for hiding this comment

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

I assume it would be more correct to say that it switches the active code page to cp437, the default code page for US english.

@AlanBateman
Copy link
Contributor

@AlanBateman This PR requires two approvals. I apologize for the long delay, but could you review it?

Sure, just have some drive by comments, switching to cp437 should be okay.

@openjdk openjdk bot removed the ready Pull request is ready to be integrated label Jun 25, 2025
@ktakakuri
Copy link
Member Author

@AlanBateman Thank you for the suggested fixes. I modified the code as such.

@bridgekeeper
Copy link

bridgekeeper bot commented Jul 23, 2025

@ktakakuri This pull request has been inactive for more than 4 weeks and will be automatically closed if another 4 weeks passes without any activity. To avoid this, simply issue a /touch or /keepalive command to the pull request. Feel free to ask for assistance if you need help with progressing this pull request towards integration!

@ktakakuri
Copy link
Member Author

/reviewers 2

@openjdk
Copy link

openjdk bot commented Jul 28, 2025

@ktakakuri
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).

@ktakakuri
Copy link
Member Author

@AlanBateman I fixed the code as you suggested. Could you please review it?

@ktakakuri
Copy link
Member Author

@dholmes-ora I have made some fixes, so please review it again.

Copy link
Member

@dholmes-ora dholmes-ora left a comment

Choose a reason for hiding this comment

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

Sorry I did not see that further updates had occurred.

Seems okay.

Thanks

@bridgekeeper
Copy link

bridgekeeper bot commented Aug 30, 2025

@ktakakuri This pull request has been inactive for more than 4 weeks and will be automatically closed if another 4 weeks passes without any activity. To avoid this, simply issue a /touch or /keepalive command to the pull request. Feel free to ask for assistance if you need help with progressing this pull request towards integration!

@ktakakuri
Copy link
Member Author

@AlanBateman I know you're busy, but I'm looking forward to your review.

* @run testng TestAvailableProcessors
*/

import java.io.File;
Copy link
Contributor

Choose a reason for hiding this comment

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

I assume this is a left-over from early iterations.

Copy link
Contributor

@AlanBateman AlanBateman 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, thanks for moving away from the hardcoded root.

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Sep 9, 2025
@ktakakuri
Copy link
Member Author

/integrate

@openjdk openjdk bot added the sponsor Pull request is ready to be sponsored label Sep 10, 2025
@openjdk
Copy link

openjdk bot commented Sep 10, 2025

@ktakakuri
Your change (at version 3490e65) is now ready to be sponsored by a Committer.

@dholmes-ora
Copy link
Member

/sponsor

@openjdk
Copy link

openjdk bot commented Sep 10, 2025

Going to push as commit 9e3fa32.
Since your change was applied there have been 2006 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 10, 2025
@openjdk openjdk bot closed this Sep 10, 2025
@openjdk openjdk bot removed ready Pull request is ready to be integrated rfr Pull request is ready for review sponsor Pull request is ready to be sponsored labels Sep 10, 2025
@openjdk
Copy link

openjdk bot commented Sep 10, 2025

@dholmes-ora @ktakakuri Pushed as commit 9e3fa32.

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

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

Labels

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

Development

Successfully merging this pull request may close these issues.

4 participants