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

Merge to tag jdk-24 25 #1871

Open
wants to merge 174 commits into
base: sapmachine
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
174 commits
Select commit Hold shift click to select a range
e7d90b9
8343460: ZGC: Crash in ZRemembered::scan_page_and_clear_remset
xmas92 Nov 14, 2024
1e97c1c
8335989: Implement JEP 494: Module Import Declarations (Second Preview)
lahodaj Nov 14, 2024
23a8c71
8341790: Fix ExceptionOccurred in java.desktop
Nov 14, 2024
c977ef7
8342047: Create Template Assertion Predicates with Halt nodes only in…
chhagedorn Nov 14, 2024
abacece
8344011: Remove usage of security manager from Class and reflective APIs
Nov 14, 2024
b54bd82
8344025: Remove unused ISO2022.Encoder.maximumDesignatorLength
Nov 14, 2024
c3776db
8342936: Enhance java.io.IO with parameter-less println() and readln()
lahodaj Nov 14, 2024
bd6152f
8343855: HTTP/2 ConnectionWindowUpdateSender may miss some unprocesse…
dfuch Nov 14, 2024
a8152bd
8343941: IGV: dump graph at different register allocation steps
robcasloz Nov 14, 2024
2b57f40
8343426: ConcurrentSkipListMap.spliterator() can no longer split the …
kabutz Nov 14, 2024
8523880
8342693: Use byte[] as parameter in a FDBigInteger constructor and as…
rgiulietti Nov 14, 2024
81342ac
8343752: The javadoc should contain a note about usages of requires t…
lahodaj Nov 14, 2024
5731ab7
8335991: Implement Simple Source Files and Instance Main Methods (Fou…
lahodaj Nov 14, 2024
2145ace
8341094: Clean up relax_verify in ClassFileParser
coleenp Nov 14, 2024
8ccc48c
8344032: InterpreterRuntime::verify_mdp() missing lock while printing…
coleenp Nov 14, 2024
6757994
8343633: The ClassLoader::print_counters() prints to stdout when logg…
coleenp Nov 14, 2024
6e28cd3
8343488: Test VectorRebracket128Test.java can't exclude by test/hotsp…
Nov 14, 2024
a73226b
8297692: Avoid sending per-region GCPhaseParallel JFR events in G1Sca…
Nov 14, 2024
4d1a51c
8344120: Remove Security Manager dependencies from jdk.crypto.cryptok…
seanjmullan Nov 14, 2024
752e162
8343877: Test AsyncClose.java intermittent fails - Socket.getInputStr…
jaikiran Nov 14, 2024
68164a4
8343953: Test jdk/jfr/threading/TestDeepVirtualStackTrace.java fails …
lmesnik Nov 14, 2024
7e9dfa4
8343785: (fs) Remove syscalls that set file times with microsecond pr…
Nov 14, 2024
e12f514
8343781: Add since checker test to the Serviceability area modules
nizarbenalla Nov 14, 2024
002b985
8342963: TestLargeStub::testUpcall doesn't test upcalls stubs
JornVernee Nov 14, 2024
697f27c
8341964: Add mechanism to disable different parts of TLS cipher suite
Nov 14, 2024
4d4951a
8343889: Test runtime/cds/appcds/redefineClass/RedefineBasicTest.java…
calvinccheung Nov 14, 2024
681a57f
8343064: ClassFormatError: Illegal class name from InnerClassLambdaMe…
liach Nov 14, 2024
2cbce1f
8344071: Mark some jdk/jfr/event/oldobject test flagless until they f…
lmesnik Nov 14, 2024
ec148c1
8344063: Remove doPrivileged calls from swing classes in the java.des…
prrace Nov 14, 2024
d959c7d
8344147: Remove Security Manager dependencies from java.security.sasl…
seanjmullan Nov 14, 2024
7ef2633
8344128: Regression: make help broken after JDK-8340818
nizarbenalla Nov 14, 2024
db56266
8344250: Obsolete the DontYieldALot flag
Nov 14, 2024
9907065
8344065: Remove SecurityManager uses from the java.datatransfer module
prrace Nov 15, 2024
0ae5748
8343982: Remove usage of security manager from ClassLoader and relate…
Nov 15, 2024
2196694
8344104: TestMergeStores fails with ArrayIndexOutOfBoundException
eme64 Nov 15, 2024
857f68c
8344179: SecurityManager cleanup in the ZIP and JAR areas
Nov 15, 2024
bfee766
8344183: (zipfs) SecurityManager cleanup in the ZipFS area
Nov 15, 2024
0c191f6
8344185: Remove calls to SecurityManager in sun.net.ftp
Nov 15, 2024
5b9932f
8338288: Compiler Implementation for Flexible Constructor Bodies (Thi…
mcimadamore Nov 15, 2024
3eece6e
8341907: javac -Xlint should ignore /// on first line of source file
pavelrappo Nov 15, 2024
75c651f
8327156: Avoid copying in StringTable::intern(oop, TRAPS)
Nov 15, 2024
ba39321
8343881: java.lang.classfile.Attribute attributeName() method should…
asotona Nov 15, 2024
5e27608
8344188: Cleanup sun.net.www.protocol.jar.JarFileFactory after JEP 48…
Nov 15, 2024
3245f56
8344164: [s390x] ProblemList hotspot/jtreg/runtime/NMT/VirtualAllocCo…
offamitkumar Nov 15, 2024
a672138
8344161: Argument type mismatch for jfr_type_id
Nov 15, 2024
6cdebf0
8343599: Kmem limit and max values swapped when printing container in…
Nov 15, 2024
84ffb64
8334714: Implement JEP 484: Class-File API
asotona Nov 15, 2024
40a055e
8344228: Revisit SecurityManager usage in java.net.http after JEP 486…
dfuch Nov 15, 2024
3c38ed4
8344314: Revert removal of jdk.internal.java.PreviewFeature.CLASSFILE…
asotona Nov 15, 2024
0b9b82a
8343039: Remove jdk.internal.misc.InternalLock and usages from java.io
Nov 15, 2024
1866c0c
8344259: Annotate Float16 with jdk.internal.ValueBased
Nov 15, 2024
ff12ff5
8340453: C2: Improve encoding of LoadNKlass for compact headers
rkennke Nov 15, 2024
fc8fb34
8344214: Remove Security Manager dependencies from jdk.crypto.mscapi …
seanjmullan Nov 15, 2024
1bb0d3b
8344062: Remove doPrivileged calls from awt and beans classes in the …
prrace Nov 15, 2024
f62e05e
8344231: SecurityManager cleanup in java.lang.module and jdk.internal…
Nov 15, 2024
73fd891
8344216: Remove calls to SecurityManager and and doPrivileged in java…
Nov 15, 2024
f316808
8344189: Cleanup code in sun.net.www.protocol.mailto.MailToURLConnect…
Nov 15, 2024
59ffac8
8342811: java/net/httpclient/PlainProxyConnectionTest.java failed: Un…
vy Nov 15, 2024
c5b6ed8
8344252: SM cleanup in java.util classes
Nov 15, 2024
c388455
8344197: SM cleanup in java.util.concurrent
Nov 15, 2024
276251c
8342826: Improve performance of oopDesc::klass() after JDK-8305895
rkennke Nov 15, 2024
41a2d49
8331497: Implement JEP 483: Ahead-of-Time Class Loading & Linking
iklam Nov 15, 2024
2c509a1
8344326: Move jpackage tests from "jdk.jpackage.tests" package to the…
Nov 15, 2024
da40388
8344315: Clean up sun.net.www.protocol.jrt.JavaRuntimeURLConnection a…
jaikiran Nov 16, 2024
d2e4b51
8344186: Cleanup sun.net.www.MimeTable after JEP 486 integration
jaikiran Nov 16, 2024
a91d4c0
8344233: Remove calls to SecurityManager and doPrivileged in java.net…
jaikiran Nov 16, 2024
d0b770c
8344289: SM cleanup in jdk.internal.util
Nov 16, 2024
fec0d1c
8343777: Add since checker tests to Internationalisation modules
nizarbenalla Nov 16, 2024
aa10ec7
8343123: Nimbus: javax/swing/JInternalFrame/bug6726866.java does not …
prsadhuk Nov 17, 2024
41a627b
8343876: Enhancements to jpackage test lib
Nov 17, 2024
e1c4b49
8343237: Improve the copying of the available set of Currencies
Nov 18, 2024
80e37a9
8344265: RISC-V: Remove unused function get_previous_sp_entry
zifeihan Nov 18, 2024
a47d9ba
8344349: Problemlist jdk/jfr/jvm/TestVirtualThreadExclusion.java befo…
Nov 18, 2024
92b2631
8327652: S390x: Implements SLP support
Nov 18, 2024
543e355
8344298: Test tools/sincechecker/modules/jdk.hotspot.agent/JdkHotspot…
MBaesken Nov 18, 2024
b6c2122
8316151: [macos14] ActionListenerCalledTwiceTest.java fails on macOS 14
prsadhuk Nov 18, 2024
4a7ce1d
8344205: [PPC]: failing assertion: sharedRuntime_ppc.cpp:1652: cookie…
reinrich Nov 18, 2024
6c2ae44
8344204: IGV: Button to enable/disable cutting of long edges
tobiasholenstein Nov 18, 2024
475feb0
8344056: Use markdown format for man pages
magicus Nov 18, 2024
00ff6a3
8344105: Remove SecurityManager and related calls from jdk.attach and…
kevinjwalls Nov 18, 2024
b9c6ce9
8344122: IGV: Extend c2 IdealGraphPrinter to send subgraphs to IGV
tobiasholenstein Nov 18, 2024
ea8f289
8344271: Comparison build fails due to difference in doc summary
lahodaj Nov 18, 2024
5fc4322
8288298: Resolve multiline message parsing ambiguities in UL
aseoane-uu Nov 18, 2024
b8b70c8
8344379: [s390x] build failure due to missing change from JDK-8339466
offamitkumar Nov 18, 2024
5eb0733
8344383: Include ZipArchive and JarArchive directly
magicus Nov 18, 2024
dfddbca
8341916: Remove ProtectionDomain related hotspot code and tests
coleenp Nov 18, 2024
d52d136
8344221: Remove calls to SecurityManager and and doPrivileged in java…
dfuch Nov 18, 2024
9b0ab92
8344034: Remove security manager dependency in Serialization
Nov 18, 2024
162d66a
8318668: java/lang/management/MemoryMXBean/CollectionUsageThreshold.j…
Nov 18, 2024
2078329
8344134: Use static property in SystemLookup
minborg Nov 18, 2024
3e78ff1
8320743: AEAD ciphers throw undocumented exceptions on overflow
driverkt Nov 18, 2024
d76b5b8
8344253: Test java/util/Spliterator/SpliteratorTraversingAndSplitting…
Nov 18, 2024
c4e7dc7
8344389: 32-bit builds fail at CDS build time after JDK-8331497
shipilev Nov 18, 2024
c59adf6
8344330: Remove AccessController.doPrivileged() from jdk.charsets module
naotoj Nov 18, 2024
e9e4200
8343125: Correct the documentation for TreeMap's getFloorEntry and ge…
namannigam Nov 18, 2024
2649406
8344352: 32-bit builds crash after JDK-8305895
shipilev Nov 18, 2024
922b12f
8344078: Remove security manager dependency in java.nio
Nov 18, 2024
70eb95f
8344187: Remove SecurityManager and related calls from java.instrument
kevinjwalls Nov 18, 2024
92271af
8344058: Remove doPrivileged calls from macos platform sources in the…
Nov 18, 2024
de6e013
8344310: Remove Security Manager dependencies from javax.crypto and c…
seanjmullan Nov 18, 2024
f636674
8344247: Move objectWaiter field to VirtualThread instance
pchilano Nov 18, 2024
8d43e0d
8344331: SM cleanup in java.scripting
Nov 18, 2024
5cb0d43
8293040: Argfile documentation for java launcher tool is confusing re…
sormuras Nov 18, 2024
dd86369
8344262: Win32AttachOperationRequest objects are created by using glo…
Nov 19, 2024
3729884
8344371: RISC-V: compiler/intrinsics/chacha/TestChaCha20.java fails a…
RealFYang Nov 19, 2024
9e92a9e
8344059: Remove doPrivileged calls from windows platform sources in t…
prsadhuk Nov 19, 2024
d85dd77
8344365: SecurityManager cleanups in java.sql and java.sql.rowset mod…
Nov 19, 2024
b12c5b4
8344218: Remove calls to SecurityManager and and doPrivileged in java…
Nov 19, 2024
499186b
8343902: javax/swing/plaf/nimbus/8041642/bug8041642.java fails in ubu…
prsadhuk Nov 19, 2024
76a55c3
8341334: CDS: Parallel relocation
shipilev Nov 19, 2024
8bd080b
8341901: Using 'var' keyword switch pattern matching causes compiler …
lahodaj Nov 19, 2024
9d60300
8344199: Incorrect excluded field value set by getEventWriter intrinsic
TobiHartmann Nov 19, 2024
7540fa2
8343884: [s390x] Disallow OptoScheduling
offamitkumar Nov 19, 2024
0d66689
8344393: RISC-V: Remove option UseRVVForBigIntegerShiftIntrinsics
RealFYang Nov 19, 2024
2359736
8344534: Remove leftover import of java.security.AccessControlContext…
Nov 19, 2024
cc8bd63
8344036: Tests tools/jlink/runtimeImage fail on AIX after JDK-8311302
MBaesken Nov 19, 2024
41436bb
8336087: Doccheck: the jpackage command page doesn't show the correct…
Nov 19, 2024
0714114
8344322: Improve capabilities of jpackage test lib to validate error …
Nov 19, 2024
a28e4d8
8342299: Document that jpackage includes (possibly old) VC Redistribu…
Nov 19, 2024
fea5f2b
8344415: Restruct jpackage utility classes
Nov 19, 2024
1717946
8344302: G1: Refactor G1CMTask::do_marking_step to use smaller wrapp…
Nov 19, 2024
59fcfae
8343129: Disable unstable check of ThreadsListHandle.sanity_vm Thread…
Nov 19, 2024
ded01e4
8344327: SM cleanup in jdk.unsupported ReflectionFactory
Nov 19, 2024
dc940ec
8344387: RISC-V: C2: Improve encoding of LoadNKlass for compact headers
Nov 19, 2024
d4cd27e
8344445: MethodCounters don't need a vptr
coleenp Nov 19, 2024
48223f7
8344143: Test jdk/java/lang/Thread/virtual/stress/GetStackTraceALotWh…
Nov 19, 2024
7f672eb
8344550: Compilation error of jpackage test JPackageStringBundle.java…
Nov 19, 2024
78602be
8344024: Unnecessary Hashtable usage in RSAPSSSignature.DIGEST_LENGTHS
Nov 19, 2024
47ebf8d
8342098: Write a test to compare the images
Nov 19, 2024
02ec8ca
8342508: Use latch in BasicMenuUI/bug4983388.java instead of delay
aivanov-jdk Nov 19, 2024
087a07b
8343479: Remove unnecessary @SuppressWarnings annotations (hotspot)
archiecobbs Nov 19, 2024
bb7a840
8342541: Exclude List/KeyEventsTest/KeyEventsTest.java from running o…
Renjithkannath Nov 19, 2024
93e889b
8342449: reimplement: JDK-8327114 Attach in Linux may have wrong beha…
larry-cable Nov 19, 2024
0b1f571
8253440: serviceability/sa/TestJhsdbJstackLineNumbers.java failed wit…
plummercj Nov 19, 2024
6a5256e
8344149: Remove usage of Security Manager from java.rmi
Nov 19, 2024
3328b4e
8343700: ceil_log2 should not loop endlessly
Nov 19, 2024
69c9f25
8344061: Remove doPrivileged calls from shared implementation code in…
prrace Nov 19, 2024
cd45ba3
8342041: Test gc/shenandoah/oom/TestClassLoaderLeak.java slow on Wind…
Nov 19, 2024
aac1f9a
8341793: Fix ExceptionOccurred in jdk.accessibility
Nov 19, 2024
f6f73ce
8344446: Remove security manager dependency from module jdk.sctp
Nov 19, 2024
81e4311
8344077: Remove security manager dependency in java.io
Nov 19, 2024
acdbf83
8341553: Remove UseCompactObjectHeaders extra CDS archives
calvinccheung Nov 19, 2024
f525290
8341935: javac states that -proc:full is the default but the default …
jddarcy Nov 20, 2024
bc7eabd
8344350: Add '.gdbinit' and '.lldbinit' to file '.gitignore'
lgxbslgx Nov 20, 2024
4ddd3de
8344356: Aarch64: implement -XX: VerifyActivationFrameSize
Nov 20, 2024
8a1f9f0
8343476: Remove unnecessary @SuppressWarnings annotations (client)
archiecobbs Nov 20, 2024
189fc8d
8344381: [s390x] Test failures with error: Register type is not known
offamitkumar Nov 20, 2024
587f2b4
8343827: RISC-V: set AlignVector as false if applicable to enable SLP
Nov 20, 2024
5b12a87
8344060: Remove doPrivileged calls from shared implementation code in…
prsadhuk Nov 20, 2024
cf158bc
8341631: JShell should auto-import java.io.IO.*
lahodaj Nov 20, 2024
3a4a9b7
8340145: Problem with generic pattern matching results in internal co…
biboudis Nov 20, 2024
afee740
8343541: C1: Plain memory accesses are emitted with membars with Alw…
Nov 20, 2024
e2f8f1a
8344621: ProblemList runtime/CommandLine/OptionsValidation/TestOption…
Nov 20, 2024
ea7e722
8344010: RISC-V: Zacas do not work with LW locking
robehn Nov 20, 2024
21b8749
8344479: Declare MetaspaceObj::operator delete to be deleted
coleenp Nov 20, 2024
7bb4474
8344579: Clean up forward declarations and includes
coleenp Nov 20, 2024
6f4dfa6
8344190: Cleanup code in sun.net.www.protocol.http and sun.net.www.pr…
jaikiran Nov 20, 2024
db7ee3d
8344223: Remove calls to SecurityManager and doPrivileged in java.net…
jaikiran Nov 20, 2024
4bc826a
8342785: XWindowPeer::getNewLocation() adheres to ICCCM 4.1.5 only wi…
zzag Nov 20, 2024
21f0ed5
8344215: Remove calls to SecurityManager and doPrivileged in java.net…
vy Nov 20, 2024
e11d126
8333796: Add missing serialization functionality to sun.reflect.Refle…
dmlloyd Nov 20, 2024
75420e9
8334431: C2 SuperWord: fix performance regression due to store-to-loa…
eme64 Nov 20, 2024
7d4c3fd
8331295: C2: Do not clone address computations that are indirect memo…
Nov 20, 2024
9be8ac6
8344239: runtime/cds/appcds/jigsaw/addmods/AddmodsOption.java fails o…
calvinccheung Nov 20, 2024
c4c6b1f
8344562: Remove security manager dependency from module jdk.jdi
Nov 20, 2024
080f1cc
8289771: jpackage: ResourceEditor error when path is overly long on W…
Nov 20, 2024
27fda0e
8344578: Clean up left over java.security and sun.security imports in…
prrace Nov 20, 2024
22a39dc
8344064: Remove doPrivileged calls from print/imageio/media classes i…
prrace Nov 20, 2024
da2d7a0
8344595: State transitions in internal VirtualThread comment needs to…
kabutz Nov 20, 2024
b9bf447
8344057: Remove doPrivileged calls from unix platform sources in the …
Nov 20, 2024
a599c30
8344471: Remove SecurityManager related code from java.compiler module
jaikiran Nov 21, 2024
400eb9b
8344524: Remove SecurityManager related code from jdk.jlink module
jaikiran Nov 21, 2024
1343911
8340334: Update jcmd VM.events max parameter to be INT
lmesnik Nov 21, 2024
4fbf272
8344526: RISC-V: implement -XX: VerifyActivationFrameSize
Nov 21, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
8341631: JShell should auto-import java.io.IO.*
Reviewed-by: asotona, cstein
  • Loading branch information
lahodaj committed Nov 20, 2024
commit cf158bc6cdadfdfa944b8ec1d3dc7069c8f055a9
Original file line number Diff line number Diff line change
Expand Up @@ -1001,6 1001,11 @@ public synchronized String readUserLine(String prompt) throws IOException {
return doReadUserLine(prompt, null);
}

@Override
public String readUserLine() throws IOException {
return readUserLine("");
}

private synchronized String doReadUserLine(String prompt, Character mask) throws IOException {
History prevHistory = in.getHistory();
boolean prevDisableCr = Display.DISABLE_CR;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 64,8 @@ public char readUserInputChar() throws IOException {
}

public String readUserLine(String prompt) throws IOException {
userOutput().write(prompt);
userOutput().flush();
throw new UserInterruptException("");
}

Expand All @@ -76,6 78,8 @@ public Writer userOutput() {
}

public char[] readPassword(String prompt) throws IOException {
userOutput().write(prompt);
userOutput().flush();
throw new UserInterruptException("");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 35,7 @@
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintStream;
import java.io.PrintWriter;
import java.io.Reader;
Expand Down Expand Up @@ -1192,7 1193,7 @@ private void initFeedback(String initMode) {

//where
private void startUpRun(String start) {
try (IOContext suin = new ScannerIOContext(new StringReader(start))) {
try (IOContext suin = new ScannerIOContext(new StringReader(start), userout)) {
while (run(suin)) {
if (!live) {
resetState();
Expand Down Expand Up @@ -3125,7 3126,7 @@ private boolean runFile(String filename, String context) {
throw new FileNotFoundException(filename);
}
}
try (var scannerIOContext = new ScannerIOContext(scanner)) {
try (var scannerIOContext = new ScannerIOContext(scanner, userout)) {
run(scannerIOContext);
}
return true;
Expand Down Expand Up @@ -3288,8 3289,10 @@ private boolean doReload(ReplayableHistory history, boolean echo, Options oldOpt
resetState();
}
if (history != null) {
run(new ReloadIOContext(history.iterable(),
echo ? cmdout : null));
try (ReloadIOContext ctx = new ReloadIOContext(history.iterable(),
echo ? cmdout : null, userout)) {
run(ctx);
}
}
return true;
}
Expand Down Expand Up @@ -4107,6 4110,8 @@ public void close() throws IOException {
public String readLine(String prompt) {
try {
return input.readUserLine(prompt);
} catch (UserInterruptException ex) {
return null;
} catch (IOException ex) {
throw new IOError(ex);
}
Expand All @@ -4125,6 4130,8 @@ public String readLine() throws IOError {
public char[] readPassword(String prompt) {
try {
return input.readPassword(prompt);
} catch (UserInterruptException ex) {
return null;
} catch (IOException ex) {
throw new IOError(ex);
}
Expand All @@ -4144,6 4151,12 @@ public Charset charset() {

abstract class NonInteractiveIOContext extends IOContext {

private final Writer userOutput;

public NonInteractiveIOContext(PrintStream userOutput) {
this.userOutput = new OutputStreamWriter(userOutput);
}

@Override
public boolean interactiveOutput() {
return false;
Expand Down Expand Up @@ -4178,17 4191,33 @@ public void afterUserCode() {
@Override
public void replaceLastHistoryEntry(String source) {
}

@Override
public Writer userOutput() {
return userOutput;
}

@Override
public void close() {
try {
userOutput.flush();
} catch (IOException _) {
//ignore
}
}

}

class ScannerIOContext extends NonInteractiveIOContext {
private final Scanner scannerIn;

ScannerIOContext(Scanner scannerIn) {
ScannerIOContext(Scanner scannerIn, PrintStream userOutput) {
super(userOutput);
this.scannerIn = scannerIn;
}

ScannerIOContext(Reader rdr) throws FileNotFoundException {
this(new Scanner(rdr));
ScannerIOContext(Reader rdr, PrintStream userOutput) throws FileNotFoundException {
this(new Scanner(rdr), userOutput);
}

@Override
Expand All @@ -4202,6 4231,7 @@ public String readLine(String firstLinePrompt, String continuationPrompt, boolea

@Override
public void close() {
super.close();
scannerIn.close();
}

Expand All @@ -4215,7 4245,8 @@ class ReloadIOContext extends NonInteractiveIOContext {
private final Iterator<String> it;
private final PrintStream echoStream;

ReloadIOContext(Iterable<String> history, PrintStream echoStream) {
ReloadIOContext(Iterable<String> history, PrintStream echoStream, PrintStream userOutput) {
super(userOutput);
this.it = history.iterator();
this.echoStream = echoStream;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 117,9 @@ private int readChars(char[] data, int off, int len) throws IOException {

private char[] readChars() throws IOException {
int actualLen = readInt();
if (actualLen == (-1)) {
return null;
}
char[] result = new char[actualLen];
for (int i = 0; i < actualLen; i ) {
result[i] = (char) ((remoteOutput.read() << 8) |
Expand Down Expand Up @@ -267,6 270,9 @@ public String readLine(Locale locale, String format, Object... args) {
remoteInput.write(Task.READ_LINE.ordinal());
sendChars(chars, 0, chars.length);
char[] line = readChars();
if (line == null) {
return null;
}
return new String(line);
});
} catch (IOException ex) {
Expand Down Expand Up @@ -417,8 423,12 @@ public synchronized void write(int b) throws IOException {
char[] data = readCharsOrNull(1);
if (data != null) {
String line = console.readLine(new String(data));
char[] chars = line.toCharArray();
sendChars(sinkOutput, chars, 0, chars.length);
if (line == null) {
sendInt(sinkOutput, -1);
} else {
char[] chars = line.toCharArray();
sendChars(sinkOutput, chars, 0, chars.length);
}
bp = 0;
}
}
Expand All @@ -432,7 442,11 @@ public synchronized void write(int b) throws IOException {
char[] data = readCharsOrNull(1);
if (data != null) {
char[] chars = console.readPassword(new String(data));
sendChars(sinkOutput, chars, 0, chars.length);
if (chars == null) {
sendInt(sinkOutput, -1);
} else {
sendChars(sinkOutput, chars, 0, chars.length);
}
bp = 0;
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1 1,2 @@
import module java.base;
import static java.io.IO.*;
36 changes: 35 additions & 1 deletion test/langtools/jdk/jshell/ConsoleToolTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 23,7 @@

/*
* @test
* @bug 8331535
* @bug 8331535 8341631
* @summary Test the JShell tool Console handling
* @modules jdk.internal.le/jdk.internal.org.jline.reader
* jdk.jshell/jdk.internal.jshell.tool: open
Expand Down Expand Up @@ -56,6 56,40 @@ public void testOutput() {
);
}

@Test //JDK-8341631
public void testIO() {
test(new String[] {"--enable-preview"},
a -> {assertCommandWithOutputAndTerminal(a,
"java.io.IO.readln(\"%%s\");\ninput", //newline automatically appended
"$1 ==> \"input\"",
"""
\u0005java.io.IO.readln(\"%%s\");
%%sinput
""");},
a -> {assertCommandWithOutputAndTerminal(a,
"java.io.IO.readln();\ninput!", //newline automatically appended
"$2 ==> \"input!\"",
"""
\u0005java.io.IO.readln();
input!
""");},
a -> {assertCommandWithOutputAndTerminal(a,
"java.io.IO.println(\"Hello, World!\");",
"",
"""
\u0005java.io.IO.println(\"Hello, World!\");
Hello, World!
""");},
a -> {assertCommandWithOutputAndTerminal(a,
"java.io.IO.println();",
"",
"""
\u0005java.io.IO.println();

""");}
);
}

void assertCommandWithOutputAndTerminal(boolean a, String command, String out, String terminalOut) {
assertCommand(a, command, out, null, null, null, null, terminalOut);
}
Expand Down
45 changes: 40 additions & 5 deletions test/langtools/jdk/jshell/StartOptionTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 22,7 @@
*/

/*
* @test 8151754 8080883 8160089 8170162 8166581 8172102 8171343 8178023 8186708 8179856 8185840 8190383
* @test 8151754 8080883 8160089 8170162 8166581 8172102 8171343 8178023 8186708 8179856 8185840 8190383 8341631
* @summary Testing startExCe-up options.
* @modules jdk.compiler/com.sun.tools.javac.api
* jdk.compiler/com.sun.tools.javac.main
Expand Down Expand Up @@ -366,14 366,49 @@ public void testShowVersion() {
}

public void testPreviewEnabled() {
String fn = writeToFile("System.out.println(\"prefix\");\n"
"System.out.println(MethodHandle.class.getName());\n"
"System.out.println(\"suffix\");\n"
"/exit\n");
String fn = writeToFile(
"""
System.out.println(\"prefix\");
System.out.println(MethodHandle.class.getName());
System.out.println(\"suffix\");
/exit
""");
startCheckUserOutput(s -> assertEquals(s, "prefix\nsuffix\n"),
fn);
startCheckUserOutput(s -> assertEquals(s, "prefix\njava.lang.invoke.MethodHandle\nsuffix\n"),
"--enable-preview", fn);
//JDK-8341631:
String fn2 = writeToFile(
"""
System.out.println(\"prefix\");
IO.println(\"test\");
System.out.println(\"suffix\");
/exit
""");
startCheckUserOutput(s -> assertEquals(s, "prefix\nsuffix\n"),
fn2);
startCheckUserOutput(s -> assertEquals(s, "prefix\ntest\nsuffix\n"),
"--enable-preview", fn2);
}
public void testInput() {
//readLine(String):
String readLinePrompt = writeToFile(
"""
var v = System.console().readLine("prompt: ");
System.out.println(v);
/exit
""");
startCheckUserOutput(s -> assertEquals(s, "prompt: null\n"),
readLinePrompt);
//readPassword(String):
String readPasswordPrompt = writeToFile(
"""
var v = System.console().readPassword("prompt: ");
System.out.println(java.util.Arrays.toString(v));
/exit
""");
startCheckUserOutput(s -> assertEquals(s, "prompt: null\n"),
readPasswordPrompt);
}

@AfterMethod
Expand Down