-
Notifications
You must be signed in to change notification settings - Fork 5.8k
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
8293579: tools/jpackage/share/jdk/jpackage/tests/UnicodeArgsTest.java fails on Japanese Windows platform #10226
Conversation
… fails on Japanese Windows platform
👋 Welcome back tkiriyama! A progress list of the required criteria for merging this PR into |
@tkiriyama The following label will be automatically applied to this pull request:
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. |
Webrevs
|
I just wonder if the fix is working as intended... Since JDK18, |
You’re right. |
|
… fails on Japanese Windows platform
@naotoj |
It would be good to have a comment in the source code describing that this works only for Japanese encodings then. |
|
||
String encoding = System.getProperty("native.encoding"); | ||
switch (encoding) { | ||
default: |
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.
What I meant by the previous comment was to replace this default
clause to:
case "Cp1252", "UTF-8" -> testString = new String(Character.toChars(0x00E9));
And for other unknown encodings:
default -> {
System.out.println("Test skipped"); // or better message
return;
}
And your fix:
case "MS932", "SJIS" -> testString = new String(Character.toChars(0x3042));
This way only the encodings that are guaranteed to succeed are tested.
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 am sorry to misunderstand your comment.
I don’t know whether "é"(0x00e9) exists only in "Cp1252", "UTF-8".
Will that be no problem that this test is skipped in other encordings? If skipped, the pattern for its encording probably won't be added forever. I think the other pattern should be added when this test fails. However I will follow the policy of OpenJDK.
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 agree skipping the test is not the best solution. Leaving a hint in the comments on how to fix the issue looks better alternative.
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.
Well, what concerns me with the current fix is that it is simply patching only the case for the Japanese setup. We don't know if the same failure would happen in other setups (I'm pretty sure the same failure would happen with some Chinese Windows setups) which makes the test fragile. If that happens, we are not sure if it is a real bug or a test case false positive at a glance. For that reason, I think we should only run tests on the setup where we are sure the false positive won't happen (by skipping other unknown host encodings). And for the purpose of this test, that should suffice the need.
Another option would be to actually check if the test string can be encoded with a CharsetEncoder, but that may be overkill.
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 don't think it will be many practical setups where this test fails. This test has been around for more than 2 years and this is the first accident.
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.
At least, the results in different encodings are the same as before the fix.
How about not fixing the pattern for other encordings to avoid false negative?
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.
This looks good to me. The only requirement to the value of testString
is that it is a letter outside of the Basic Latin character set. So picking a letter that can be encoded in the active encoding works.
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.
Although I still prefer preventing possible errors in the test, the change does not make it worse than before.
Mailing list message from John Platts on core-libs-dev: The issue can be worked around on Windows 10 Version 1903 or later (including Windows 11) by modifying the src/java.base/windows/native/launcher/java.manifest file as follows: <assemblyIdentity <!-- Identify the application security requirements. --> <!-- Indicate JDK is high-dpi aware. --> <!-- Indicate this JDK version is Windows 7 compatible --> The GetACP() and GetOEMCP() functions will both return 65001 on Windows 10 Version 1903 or later if the above changes are made to src/java.base/windows/native/launcher/java.manifest. Also make sure that the sun.jnu.encoding property is set to UTF-8 if GetACP() returns 65001. Note that it is possible for GetACP() and GetOEMCP() to return values other than 65001 on Windows 10 Version 1809 or earlier or if the JVM is embedded in an application that does not have the <utf8:activeCodePage>UTF-8</utf8:activeCodePage> setting in its manifest. ________________________________ On Wed, 28 Sep 2022 09:45:32 GMT, KIRIYAMA Takuya <duke at openjdk.org> wrote:
test/jdk/tools/jpackage/share/jdk/jpackage/tests/UnicodeArgsTest.java line 55:
What I meant by the previous comment was to replace this `default` clause to: case "Cp1252", "UTF-8" -> testString = new String(Character.toChars(0x00E9)); And for other unknown encodings: default -> { And your fix: case "MS932", "SJIS" -> testString = new String(Character.toChars(0x3042)); This way only the encodings that are guaranteed to succeed are tested. ------------- PR: https://git.openjdk.org/jdk/pull/10226 |
|
||
String encoding = System.getProperty("native.encoding"); | ||
switch (encoding) { | ||
default: |
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.
This looks good to me. The only requirement to the value of testString
is that it is a letter outside of the Basic Latin character set. So picking a letter that can be encoded in the active encoding works.
@tkiriyama 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 287 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 (@alexeysemenyukoracle, @naotoj, @sashamatveev) but any other Committer may sponsor as well. ➡️ To flag this PR as ready for integration with the above commit message, type |
This would be a good enhancement for the jpackage. |
Thank you for all reviews. I hope this fix integrated. |
/integrate |
@tkiriyama |
/sponsor |
Going to push as commit 121d4a5.
Your commit was automatically rebased without conflicts. |
@naotoj @tkiriyama Pushed as commit 121d4a5. 💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored. |
Could you please review the JDK-8293579 bug fixes?
tools/jpackage/share/jdk/jpackage/tests/UnicodeArgsTest.java attempts to give
the launcher the character which is encoded by Windows API WideCharToMultiByte()
from UNICODE "é"(0x00e9) as an argument. However, this test fails because the
code point "é"(0x00e9) cannot be treated on Japanese Windows.
WideCharToMultiByte() encodes characters as Shift-JIS on Japanese Windows, but
the code point "é"(0x00e9) does not exist in Shift-JIS, and it is replaced with
"e"(0x0065) as substitute. Therefore, "é"(0x00e9) and "e"(0x0065) are compared
in this test and judged to be different characters, and return as failed.
So, in the Japanese encoding("MS932", "SJIS"), the test should be modified to
give a character such as "あ"(0x3042) as the launcher's argument instead of
"é"(0x00e9).
Progress
Issue
Reviewers
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk pull/10226/head:pull/10226
$ git checkout pull/10226
Update a local copy of the PR:
$ git checkout pull/10226
$ git pull https://git.openjdk.org/jdk pull/10226/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 10226
View PR using the GUI difftool:
$ git pr show -t 10226
Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/10226.diff