8298971: Move Console implementation into jdk internal package#4452
8298971: Move Console implementation into jdk internal package#4452fitzsim wants to merge 6 commits into
Conversation
|
👋 Welcome back fitzsim! A progress list of the required criteria for merging this PR into |
|
❗ This change is not yet ready to be integrated. |
|
This backport pull request has now been updated with issue from the original commit. |
Copy just the src/java.base/share/classes/jdk/internal/io/JdkConsole.java file addition from jdk21u-dev 8a9911ef1762ae837e427ec9d91b1399ba33b6e4: 8295803: Console should be usable in jshell and other environments
This is part of a simplified backport of these two changes: 8298416: Console should be declared `sealed` 8298971: Move Console implementation into jdk internal package This commit shows the Java code movement without noise (though the result does not compile). Note that the removal of the line in LineReader.read: end = cbuf.length; shortly after the "no space left..." comment, is intentional. It was approved in the original pull request: openjdk/jdk#11615 (comment) Copy src/java.base/share/classes/jdk/internal/io/JdkConsoleImpl.java as of jdk21u-dev 24b3b2b66f0bed3e9812999a5b6d511f31e9ad1f.
This is part of a simplified backport of these two changes: 8298416: Console should be declared `sealed` 8298971: Move Console implementation into jdk internal package This is a backport of only the src/java.base/share/classes/java/io/PrintWriter.java change from jdk21u-dev 8a9911ef1762ae837e427ec9d91b1399ba33b6e4: 8295803: Console should be usable in jshell and other environments This change is required by the new java.io.Console implementation in the next commit.
This is part of a simplified backport of these two changes: 8298416: Console should be declared `sealed` 8298971: Move Console implementation into jdk internal package This commit fills in the new implementation of java.io.Console by copying the implementation of src/java.base/share/classes/java/io/ProxyingConsole.java as of jdk21u-dev f1d3049fa80260f207dc6a794485b6f582d66fe1.
This is part of a simplified backport of these two changes: 8298416: Console should be declared `sealed` 8298971: Move Console implementation into jdk internal package This commit contains the native Unix changes; native Windows changes to follow. Copy src/java.base/unix/native/libjava/JdkConsoleImpl_md.c as of jdk21u-dev 24b3b2b66f0bed3e9812999a5b6d511f31e9ad1f.
…d() on Windows Backport-of: e7e371212163ba6a56a9a365c662da3fa1a0fe47 This is a required follow-up after the simplified backport of these two changes: 8298416: Console should be declared `sealed` 8298971: Move Console implementation into jdk internal package Copy src/java.base/windows/native/libjava/Console_md.c and src/java.base/windows/native/libjava/JdkConsoleImpl_md.c as of jdk21u-dev 24b3b2b66f0bed3e9812999a5b6d511f31e9ad1f.
|
Hi @fitzsim |
|
Hi @GoeLin , thanks for taking a look at this. I picked 8298971 only because the title conceptually most closely described what this set of changes is doing. I debated instead just making this a new bug report/pull request. I did try to make the actual changes not introduce any CSRs. I agree with the amount of code changes being worrying, and 17 (and subsequently 11 and 8) only. I tried to make clear with each commit that the resulting Console.java contents match very closely the contents of ProxyingConsole.java from 21 and onward, for what it's worth. I am certainly interested in seeing your suggested approach. |
|
Hi, you find my backport draft of 8366261 at #4482 |
I have been tasked with fixing:
for 17, 11 and 8, for parity with Oracle's JDK releases.
The affected
java.io.Consolecode has been significantly reorganized in 21 and newer versions, to allow advanced features like different console providers (via the newjdk.consolesystem property) and to supportSystem.console().readPassword()injshell. The reorganization makes use of class sealing, which is available in 17 but not 11 or 8.This pull request is my attempt to lay the foundation to be able to smoothly backport
JdkConsoleImplchanges to 17, 11 and 8.I have applied parts of the following fixes:
and I have backported:
so as not to break Windows.
I have tried to make each commit on this branch as small as possible to clearly show what is changing.
Assuming this is applied, the subsequent backports required to fix JDK-8354469:
apply readily. I have created a branch to show this:
https://github.com/fitzsim/jdk17u-dev/commits/delegate-console-and-backport-keytool-8354469/
I confirmed that on that branch, keytool no longer exposes the password when standard output is redirected.
I did some multi-threaded testing of
System.console().format()andSystem.console().readPassword()to verify the locking in the merge of ProxyConsole.java into Console.java seems correct.CI testing shows no regressions, though
System.console()does not seem to have muchtier1test coverage.On my
Fedora 43 x86-64machine,make test TEST=all(with the changes rebased to36f3b1ae7f2cb0acc6409e2b686757756c2fea50) shows roughly the same results before and after the patch.Before:
After:
One difference was
sun/security/ssl/X509KeyManager/PreferredKey.javawhich passed before and failed after. The cause was thedummycertificate in./test/jdk/javax/net/ssl/etc/keystoreexpiring over the weekend:I happened to run the test suite unpatched before the expiration and patched after the expiration. The same test fails for the same reason on
jdk21u-dev.Refreshing the
dummycertificate causes the test case to pass again:however
./test/jdk/javax/net/ssl/etc/READMEmentions that it should be "Version 1" generated by a hackedkeytoolcommand, so this is just a workaround. The real fix is to backport JDK-8384815.The rest of the jtreg results differences were in
java/awtandjavax/swing, unrelated toSystem.console().Progress
Issue
Reviewing
Using
gitCheckout this PR locally:
$ git fetch https://git.openjdk.org/jdk17u-dev.git pull/4452/head:pull/4452$ git checkout pull/4452Update a local copy of the PR:
$ git checkout pull/4452$ git pull https://git.openjdk.org/jdk17u-dev.git pull/4452/headUsing Skara CLI tools
Checkout this PR locally:
$ git pr checkout 4452View PR using the GUI difftool:
$ git pr show -t 4452Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk17u-dev/pull/4452.diff
Using Webrev
Link to Webrev Comment