Skip to content
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

8282042: [testbug] FileEncodingTest.java depends on default encoding #7525

Closed
wants to merge 3 commits into from

Conversation

backwaterred
Copy link
Contributor

@backwaterred backwaterred commented Feb 17, 2022

FileEncodingTest expects all non-Windows platforms will have Charset.defaultCharset().name() set to US-ASCII when file.encoding is set to COMPAT. This assumption does not hold for AIX where it is ISO-8859-1.

According to JEP-400, we should expect Charset.defaultCharset().name() to equal System.getProperty("native.encoding") whenever the COMPAT flag is set. From JEP-400: "... if file.encoding is set to COMPAT on the command line, then the run-time value of file.encoding will be the same as the run-time value of native.encoding...". So one way to resolve this is to choose the value for each system from the native.encoding property.

With these changes however, my test systems continue to fail.

  • AIX reports: Default Charset: ISO-8859-1, expected: ISO8859-1
  • Linux/Z reports: Default Charset: US-ASCII, expected: ANSI_X3.4-1968
  • Linux/PowerLE reports: Default Charset: US-ASCII, expected: ANSI_X3.4-1968

Note that the expected value is populated from native.encoding.

This implies more work to be done. It looks to me that some modification to java_props_md.c may be needed to ensure that the System properties for native.encoding return canonical names.


A tempting alternative is to set the expected value for AIX to "ISO-8859-1" in the test explicitly, as was done for the Windows expected encoding prior to this proposed change. The main advantage to this alternative is that it is quick and easy, but the disadvantages are that it fails to test that COMPAT behaves as specified in JEP-400, and the approach does not scale well if it happens that other systems require other cases. I wonder if this is the reason non-English locals are excluded by the test.

Proceeding with this change and the work implied by the new failures it highlights goes beyond the scope of what I thought was a simple testbug. So I'm opening this up for some comments before proceeding down the rabbit hole of further changes. If there is generally positive support for this direction I'm happy to make the modifications necessary to populate native.encoding with canonical names. As I am new to OpenJDK, I am especially looking to ensure that changing the value returned by native.encoding will not have unintended consequences elsewhere in the project.


Progress

  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue
  • Change must be properly reviewed

Issue

  • JDK-8282042: [testbug] FileEncodingTest.java depends on default encoding

Reviewers

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.java.net/jdk pull/7525/head:pull/7525
$ git checkout pull/7525

Update a local copy of the PR:
$ git checkout pull/7525
$ git pull https://git.openjdk.java.net/jdk pull/7525/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 7525

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

Using diff file

Download this PR as a diff file:
https://git.openjdk.java.net/jdk/pull/7525.diff

@bridgekeeper
Copy link

bridgekeeper bot commented Feb 17, 2022

👋 Welcome back backwaterred! 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 17, 2022

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

  • core-libs

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.

@backwaterred backwaterred changed the title [testbug] FileEncodingTest.java depends on default encoding 8282042: [testbug] FileEncodingTest.java depends on default encoding Feb 17, 2022
@openjdk openjdk bot added the rfr Pull request is ready for review label Feb 17, 2022
@mlbridge
Copy link

mlbridge bot commented Feb 17, 2022

@naotoj
Copy link
Member

naotoj commented Feb 18, 2022

The purpose of this test is to check the default encoding for the environments known to be correct. Thus those test values are hardcoded. Replacing it with System.getProperty("native.encoding") would introduce some uncertainty because the test may not be run under the C locale.
As to the suggestion to canonicalize native.encoding, it was introduced for users to obtain the encoding name that used to be the value of file.encoding prior to JEP 400. So normalizing it to the canonicalized name, such as ANSI_X3.4-1968 to US-ASCII would somewhat defy the purpose.
Now, back to the test case, the test blindly assumes that C locale's default code set is US-ASCII which is not correct (as in this issue), it only requires Portable Character Set, which US-ASCII/ISO-8859-1/UTF-8 all suffice. I would change the test to check if the platform is AIX, then check the charset for COMPAT to ISO-8859-1.

@backwaterred
Copy link
Contributor Author

Thanks for your feedback Naoto.

I agree it's a little odd to test the way I proposed above, as it introduces uncertainty as you mentioned, as well as other issues like both native.encoding and Charsets.defaultCharset() being wrong, but being wrong in the same way. The main part of testing this way was the quoted line from JEP-400 (of which I recognize you are an author). Maybe I'm being too literal; in my testing the encodings match, even if the names are aliases of the ones I expect. In addition, you have a good point about the purpose of the COMPAT flag being compatibility. I agree that it's not really appropriate to change the values of native.encoding to the canonical ones.

I was feeling torn between the proposed option and alternative, and your feedback definitely sways me towards the alternative. I'll change this PR to simply add an exception to the test for AIX.

@backwaterred
Copy link
Contributor Author

The test now passes on AIX, and Linux/Z. So I believe this change can be merged once reviewed.

@backwaterred
Copy link
Contributor Author

/integrate auto

@openjdk openjdk bot added the auto label Feb 18, 2022
@openjdk
Copy link

openjdk bot commented Feb 18, 2022

@backwaterred This pull request will be automatically integrated when it is ready

Copy link
Member

@naotoj naotoj 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.
Nit: Please add the issue # to the @bug tag, and modify the copyright year to 2021, 2022.

Copy link
Member

@naotoj naotoj left a comment

Choose a reason for hiding this comment

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

Looks good.

@openjdk
Copy link

openjdk bot commented Feb 18, 2022

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

8282042: [testbug] FileEncodingTest.java depends on default encoding

Adds expected encoding "ISO-8859-1" for AIX in FileEncodingTest.java

Reviewed-by: naoto

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 107 new commits pushed to the master branch:

  • d3749de: 8277488: Add expiry exception for Digicert (geotrustglobalca) expiring in May 2022
  • 3943c89: 8282044: [JVMCI] Export _sha3_implCompress, _md5_implCompress and aarch64::_has_negatives stubs to JVMCI compiler.
  • 7ce75af: 8255266: Update Public Suffix List to 3c213aa
  • cfbfd9b: 8282103: fix macosx-generic typo in ProblemList
  • 413bef6: 8282049: AArch64: Use ZR for integer zero immediate volatile stores
  • cf6984d: 8282086: Update jib profile to not set build to 0
  • f5120b7: 8282056: Clean up com.sun.tools.javac.util.GraphUtils
  • e336504: 8280866: SuppressWarnings does not work properly in package-info and module-info
  • e8224f7: 8282089: [BACKOUT] Parallel: Refactor PSCardTable::scavenge_contents_parallel
  • 834d55c: 8277300: Issues with javadoc support for preview features
  • ... and 97 more: https://git.openjdk.java.net/jdk/compare/83b6e4bc04db89a846a1b6c2d0666efe139f8f61...master

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 (@naotoj) 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 ready Pull request is ready to be integrated label Feb 18, 2022
@openjdk
Copy link

openjdk bot commented Feb 18, 2022

/integrate

@openjdk openjdk bot added the sponsor Pull request is ready to be sponsored label Feb 18, 2022
@openjdk
Copy link

openjdk bot commented Feb 18, 2022

@openjdk[bot]
Your change (at version ac38c8f) is now ready to be sponsored by a Committer.

@RogerRiggs
Copy link
Contributor

/label remove auto

Automatic integration is not appropriate and should not be used except in time sensitive cases.
It can preempt other reviewers from having a chance to review and comment.

@openjdk
Copy link

openjdk bot commented Feb 18, 2022

@RogerRiggs
The label auto is not a valid label.
These labels are valid:

  • serviceability
  • hotspot
  • hotspot-compiler
  • ide-support
  • kulla
  • i18n
  • shenandoah
  • jdk
  • javadoc
  • security
  • hotspot-runtime
  • jmx
  • build
  • nio
  • client
  • core-libs
  • compiler
  • net
  • hotspot-gc
  • hotspot-jfr

@backwaterred
Copy link
Contributor Author

/label remove auto

Automatic integration is not appropriate and should not be used except in time sensitive cases. It can preempt other reviewers from having a chance to review and comment.

Ok. I will avoid using it in the future. I don't have commiter rights, so I was just looking to signal that I am happy for this change to be integrated when it has been reviewed. It seemed to fall under the 'benign changes' category of the /integrate command's documentation.

If there is other feedback, I am happy to incorporate it 😄

@backwaterred
Copy link
Contributor Author

/summary Adds expected encoding "ISO-8859-1" for AIX in FileEncodingTest.java

@openjdk
Copy link

openjdk bot commented Feb 18, 2022

@backwaterred Setting summary to Adds expected encoding "ISO-8859-1" for AIX in FileEncodingTest.java

@naotoj
Copy link
Member

naotoj commented Feb 22, 2022

/sponsor

@openjdk
Copy link

openjdk bot commented Feb 22, 2022

Going to push as commit 58e1882.
Since your change was applied there have been 129 commits pushed to the master branch:

  • 3cb3867: 8281315: Unicode, (?i) flag and backreference throwing IndexOutOfBounds Exception
  • 957dae0: 8280958: G1/Parallel: Unify marking code structure
  • e44d067: 8244593: Clean up GNM/NM after JEP 381
  • 41355e2: 8276686: Malformed Javadoc inline tags in JDK source in /java/util/regex/Pattern.java
  • 022d807: 8271008: appcds/*/MethodHandlesAsCollectorTest.java tests time out because of excessive GC (CodeCache GC Threshold) in loom
  • ab6d8e6: 8260328: Drop redundant CSS properties from java.desktop HTML files
  • b95310b: 8282220: contentType should not be a PKCS7's member
  • bc43320: 8281543: Remove unused code/headerfile dtraceAttacher.hpp
  • f953952: 8281745: Create a regression test for JDK-4514331
  • e0b4962: 8282190: Typo in javadoc of java.time.format.DateTimeFormatter#getDecimalStyle
  • ... and 119 more: https://git.openjdk.java.net/jdk/compare/83b6e4bc04db89a846a1b6c2d0666efe139f8f61...master

Your commit was automatically rebased without conflicts.

@openjdk openjdk bot added the integrated Pull request has been integrated label Feb 22, 2022
@openjdk openjdk bot closed this Feb 22, 2022
@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 Feb 22, 2022
@openjdk
Copy link

openjdk bot commented Feb 22, 2022

@naotoj @backwaterred Pushed as commit 58e1882.

💡 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
auto core-libs [email protected] integrated Pull request has been integrated
Development

Successfully merging this pull request may close these issues.

3 participants