-
Notifications
You must be signed in to change notification settings - Fork 6.1k
8361972: Clarify the condition of System.console() about standard input/output #26299
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
base: master
Are you sure you want to change the base?
8361972: Clarify the condition of System.console() about standard input/output #26299
Conversation
👋 Welcome back naoto! A progress list of the required criteria for merging this PR into |
❗ This change is not yet ready to be integrated. |
Webrevs
|
* example by a background job scheduler, then it may not | ||
* have a console. | ||
* example by a background job scheduler, or if one or both of the | ||
* standard input or output has been redirected, then it may not have a |
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.
If we are claiming that System.console()
should only return a "Console instance only when both standard input and output are connected to a terminal." then is the may wording not restrictive enough? Or is that nuance negligible?
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.
Intention here is that, we do want to restirct to not return JLine based Console when either/both of stdin/out is redirected, I think we would not want to restrict them as the spec. For example, System.console()
in jshell returns non-null, even if the remote JVM is not-attached to a terminal. I will describe this sublety in the CSR
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.
OK, I see your point. It is a hint as to what the behavior of this implementation does, but not enforced in the specification by any means as indicated by the may wording. Nit: if that is the case, then shouldn't there technically be minimal compatibility risk in the CSR, since nothing is being "enforced" specification wise.
@@ -45,8 +45,9 @@ | |||
* output streams then its console will exist and will typically be | |||
* connected to the keyboard and display from which the virtual machine | |||
* was launched. If the virtual machine is started automatically, for |
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 think it might read easier if we reword the structure of the sentence to make it more concise.
E.g.
The virtual machine may not have a console if started automatically, (e.g., by a background scheduler) or if either the standard input or output has been redirected.
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.
New wording lgtm.
* example by a background job scheduler, then it may not have a | ||
* console. Regardless of how the virtual machine was created, it may not | ||
* have a console if either the standard input or output stream is | ||
* redirected. |
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.
Can you clarify what the intent of "it may not have a console" is? Initially I though the intention was that there is no Console when either stdout or stdin is redirected. However, the sentence suggests there may or may not be a Console.
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 was considering the case for jshell
, where its System.console()
returns a Console
instance regardless of the isTTY
state:
return console = new RemoteConsole(remoteOutput, remoteInput); |
That led me to use may
in the updated spec. I'd appreciate your suggestions on wording.
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.
Since the decision of whether a console exists is dependent on the implementation as specified,
Whether a virtual machine has a console is dependent upon the underlying platform
And the existing wording in this paragraph uses open-ended words such as "may" and "typically", it makes sense to me that this change would follow the same style of wording. If you wanted to concretely define what this implementation does, using one of the @impl
tags to describe the behavior could be an option?
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.
Okay, so the intent is to specify that it is implementation or configuration specific as to whether there is a Console when standard input or output, but not both, are redirected, is that right? What should users expect isTerminal to return in this case?
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.
For the jshell case, I think it can return true
from its isTerminal()
as it is infact interactive environment. That means all the Console implementations return true
so that we can replace that "may not have a Console" with "will not have a Console", which is clearer.
This accompanies the fix for JDK-8361613, which restricts
System.console()
to return aConsole
instance only when both standard input and output are connected to a terminal. The change here is solely a specification clarification and tightening of thejava.io.Console
javadoc to reflect this behavior. We are separating the spec clarification because the fix itself may be backported to prior LTS releases without requiring a Maintenance Review process.Progress
Issues
Reviewers
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/26299/head:pull/26299
$ git checkout pull/26299
Update a local copy of the PR:
$ git checkout pull/26299
$ git pull https://git.openjdk.org/jdk.git pull/26299/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 26299
View PR using the GUI difftool:
$ git pr show -t 26299
Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/26299.diff
Using Webrev
Link to Webrev Comment