-
Notifications
You must be signed in to change notification settings - Fork 6.1k
8359732: Make standard i/o encoding related system properties StaticProperty
#25860
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
👋 Welcome back naoto! A progress list of the required criteria for merging this PR into |
@naotoj 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 52 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. ➡️ To integrate this PR with the above commit message to the |
@naotoj The following labels 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 lists. If you would like to change these labels, use the /label pull request command. |
Webrevs
|
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've verified that all relevant occurrences of std{in,err,out}.encoding
are covered, except the ones src/java.base/share/classes/java/lang/System.java
, which, I presume, is left out intentionally.
jdk.jlink, | ||
jdk.jpackage, | ||
jdk.jshell, | ||
jdk.net; |
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 some point we will need to re-visit all these qualified exports so that java.base exports as few of these internal packages as possible.
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 original intent of StaticProperties was to limit it to the base module.
Other modules are free to read the property themselves.
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.
Thanks, Alan and Roger. Limited the modification within the java.base
module.
@@ -107,7 +108,7 @@ public void reattach() { | |||
}; | |||
|
|||
|
|||
Charset charset = Charset.forName(System.getProperty("stdin.encoding"), Charset.defaultCharset()); | |||
Charset charset = Charset.forName(StaticProperty.stdinEncoding(), Charset.defaultCharset()); |
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 is the jhsdb tool, just wondering why it needs to be changed.
@@ -797,7 +799,7 @@ public TTY() throws Exception { | |||
this.handler = new EventHandler(this, true, trackVthreads); | |||
} | |||
try { | |||
Charset charset = Charset.forName(System.getProperty("stdin.encoding"), Charset.defaultCharset()); | |||
Charset charset = Charset.forName(StaticProperty.stdinEncoding(), Charset.defaultCharset()); |
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 is the example jdb debugger, I assume okay to let it read the stdin.encoding property.
@@ -95,7 +97,7 @@ public SimpleScriptContext() { | |||
} | |||
|
|||
private static InputStreamReader stdinReader() { | |||
Charset charset = Charset.forName(System.getProperty("stdin.encoding"), Charset.defaultCharset()); | |||
Charset charset = Charset.forName(StaticProperty.stdinEncoding(), Charset.defaultCharset()); |
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 is the jrunscript command line tool. I suppose it's possible it could run a script that changes stdin.encoding.
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.
Static properties should not be used outside of java.base.
The "for internal use only" should have said "java.base internal use only"
Adding a comment to that effect would be a good idea.
jdk.jlink, | ||
jdk.jpackage, | ||
jdk.jshell, | ||
jdk.net; |
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 original intent of StaticProperties was to limit it to the base module.
Other modules are free to read the property themselves.
/label remove hotspot-jfr,kulla,serviceability |
@naotoj The The |
Initially I left them as it is too early to call, but just noticed StaticProperty class was initialized a few lines above, so it is safe to call them. Replaced. |
setOut0(newPrintStream(fdOut, props.getProperty("stdout.encoding"))); | ||
initialErr = newPrintStream(fdErr, props.getProperty("stderr.encoding")); | ||
setOut0(newPrintStream(fdOut, StaticProperty.stdoutEncoding())); | ||
initialErr = newPrintStream(fdErr, StaticProperty.stderrEncoding()); |
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 is initPhase1 where we've just saved the initial properties. I think it would be better to not change this. It would be okay to use tempProps here too, but I think clearer as is.
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.
Latest version looks okay but I think better to drop the change to System.initPhase1.
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.
lgtm
Reverted the changes in the |
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 updates look fine.
Thanks for the reviews! |
Going to push as commit 9c3eaa4.
Your commit was automatically rebased without conflicts. |
Refactored the internal handling of
stdin/out/err.encoding
to allow setting them only via command-line options by converting them intoStaticProperty
. This change prevents unexpected behavior caused by applications modifying these properties at runtime usingSystem.setProperty()
.Progress
Issue
StaticProperty
(Enhancement - P4)Reviewers
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/25860/head:pull/25860
$ git checkout pull/25860
Update a local copy of the PR:
$ git checkout pull/25860
$ git pull https://git.openjdk.org/jdk.git pull/25860/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 25860
View PR using the GUI difftool:
$ git pr show -t 25860
Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/25860.diff
Using Webrev
Link to Webrev Comment