Skip to content

Commit 28f2591

Browse files
committed
8370568: Refer to Thread.interrupted as "interrupted status" consistently
Reviewed-by: jpai, rriggs, alanb
1 parent eab5644 commit 28f2591

File tree

77 files changed

+260
-256
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

77 files changed

+260
-256
lines changed

make/langtools/tools/javacserver/server/CompilerThreadPool.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2014, 2024, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2014, 2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -61,7 +61,7 @@ public void shutdown() {
6161
} catch (InterruptedException ie) {
6262
// (Re-)Cancel if current thread also interrupted
6363
pool.shutdownNow();
64-
// Preserve interrupt status
64+
// Preserve interrupted status
6565
Thread.currentThread().interrupt();
6666
}
6767
}

src/java.base/share/classes/java/lang/Object.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 1994, 2024, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 1994, 2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -383,7 +383,7 @@ public final void wait(long timeoutMillis) throws InterruptedException {
383383
try {
384384
wait0(timeoutMillis);
385385
} catch (InterruptedException e) {
386-
// virtual thread's interrupt status needs to be cleared
386+
// virtual thread's interrupted status needs to be cleared
387387
vthread.getAndClearInterrupt();
388388
throw e;
389389
}

src/java.base/share/classes/java/lang/Process.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -774,7 +774,7 @@ public long pid() {
774774
* @implSpec
775775
* This implementation executes {@link #waitFor()} in a separate thread
776776
* repeatedly until it returns successfully. If the execution of
777-
* {@code waitFor} is interrupted, the thread's interrupt status is preserved.
777+
* {@code waitFor} is interrupted, the thread's interrupted status is preserved.
778778
* <p>
779779
* When {@link #waitFor()} returns successfully the CompletableFuture is
780780
* {@linkplain java.util.concurrent.CompletableFuture#complete completed} regardless

src/java.base/share/classes/java/lang/Thread.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ public class Thread implements Runnable {
228228
// thread name
229229
private volatile String name;
230230

231-
// interrupt status (read/written by VM)
231+
// interrupted status (read/written by VM)
232232
volatile boolean interrupted;
233233

234234
// context ClassLoader
@@ -355,7 +355,7 @@ void inheritScopedValueBindings(ThreadContainer container) {
355355

356356
/* The object in which this thread is blocked in an interruptible I/O
357357
* operation, if any. The blocker's interrupt method should be invoked
358-
* after setting this thread's interrupt status.
358+
* after setting this thread's interrupted status.
359359
*/
360360
private Interruptible nioBlocker;
361361

@@ -1535,22 +1535,22 @@ private void exit() {
15351535
* Object#wait(long, int) wait(long, int)} methods of the {@link Object}
15361536
* class, or of the {@link #join()}, {@link #join(long)}, {@link
15371537
* #join(long, int)}, {@link #sleep(long)}, or {@link #sleep(long, int)}
1538-
* methods of this class, then its interrupt status will be cleared and it
1538+
* methods of this class, then its interrupted status will be cleared and it
15391539
* will receive an {@link InterruptedException}.
15401540
*
15411541
* <p> If this thread is blocked in an I/O operation upon an {@link
15421542
* java.nio.channels.InterruptibleChannel InterruptibleChannel}
1543-
* then the channel will be closed, the thread's interrupt
1543+
* then the channel will be closed, the thread's interrupted
15441544
* status will be set, and the thread will receive a {@link
15451545
* java.nio.channels.ClosedByInterruptException}.
15461546
*
15471547
* <p> If this thread is blocked in a {@link java.nio.channels.Selector}
1548-
* then the thread's interrupt status will be set and it will return
1548+
* then the thread's interrupted status will be set and it will return
15491549
* immediately from the selection operation, possibly with a non-zero
15501550
* value, just as if the selector's {@link
15511551
* java.nio.channels.Selector#wakeup wakeup} method were invoked.
15521552
*
1553-
* <p> If none of the previous conditions hold then this thread's interrupt
1553+
* <p> If none of the previous conditions hold then this thread's interrupted
15541554
* status will be set. </p>
15551555
*
15561556
* <p> Interrupting a thread that is not alive need not have any effect.
@@ -1560,7 +1560,7 @@ private void exit() {
15601560
* will report it via {@link #interrupted()} and {@link #isInterrupted()}.
15611561
*/
15621562
public void interrupt() {
1563-
// Setting the interrupt status must be done before reading nioBlocker.
1563+
// Setting the interrupted status must be done before reading nioBlocker.
15641564
interrupted = true;
15651565
interrupt0(); // inform VM of interrupt
15661566

src/java.base/share/classes/java/lang/VirtualThread.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -483,12 +483,12 @@ private void mount() {
483483
Thread carrier = Thread.currentCarrierThread();
484484
setCarrierThread(carrier);
485485

486-
// sync up carrier thread interrupt status if needed
486+
// sync up carrier thread interrupted status if needed
487487
if (interrupted) {
488488
carrier.setInterrupt();
489489
} else if (carrier.isInterrupted()) {
490490
synchronized (interruptLock) {
491-
// need to recheck interrupt status
491+
// need to recheck interrupted status
492492
if (!interrupted) {
493493
carrier.clearInterrupt();
494494
}
@@ -721,7 +721,7 @@ public void run() {
721721
/**
722722
* Parks until unparked or interrupted. If already unparked then the parking
723723
* permit is consumed and this method completes immediately (meaning it doesn't
724-
* yield). It also completes immediately if the interrupt status is set.
724+
* yield). It also completes immediately if the interrupted status is set.
725725
*/
726726
@Override
727727
void park() {
@@ -756,7 +756,7 @@ void park() {
756756
* Parks up to the given waiting time or until unparked or interrupted.
757757
* If already unparked then the parking permit is consumed and this method
758758
* completes immediately (meaning it doesn't yield). It also completes immediately
759-
* if the interrupt status is set or the waiting time is {@code <= 0}.
759+
* if the interrupted status is set or the waiting time is {@code <= 0}.
760760
*
761761
* @param nanos the maximum number of nanoseconds to wait.
762762
*/
@@ -799,7 +799,7 @@ void parkNanos(long nanos) {
799799
/**
800800
* Parks the current carrier thread up to the given waiting time or until
801801
* unparked or interrupted. If the virtual thread is interrupted then the
802-
* interrupt status will be propagated to the carrier thread.
802+
* interrupted status will be propagated to the carrier thread.
803803
* @param timed true for a timed park, false for untimed
804804
* @param nanos the waiting time in nanoseconds
805805
*/

src/java.base/share/classes/java/net/DatagramSocket.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 1995, 2024, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 1995, 2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -611,13 +611,13 @@ public void send(DatagramPacket p) throws IOException {
611611
* with a {@link DatagramChannel DatagramChannel}. In that case,
612612
* interrupting a thread receiving a datagram packet will close the
613613
* underlying channel and cause this method to throw {@link
614-
* java.nio.channels.ClosedByInterruptException} with the interrupt
615-
* status set.
614+
* java.nio.channels.ClosedByInterruptException} with the thread's
615+
* interrupted status set.
616616
* <li> The datagram socket uses the system-default socket implementation and
617617
* a {@linkplain Thread#isVirtual() virtual thread} is receiving a
618618
* datagram packet. In that case, interrupting the virtual thread will
619619
* cause it to wakeup and close the socket. This method will then throw
620-
* {@code SocketException} with the interrupt status set.
620+
* {@code SocketException} with the thread's interrupted status set.
621621
* </ol>
622622
*
623623
* @param p the {@code DatagramPacket} into which to place

src/java.base/share/classes/java/net/ServerSocket.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 1995, 2024, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 1995, 2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -406,13 +406,13 @@ public SocketAddress getLocalSocketAddress() {
406406
* with a {@link ServerSocketChannel ServerSocketChannel}. In that
407407
* case, interrupting a thread accepting a connection will close the
408408
* underlying channel and cause this method to throw {@link
409-
* java.nio.channels.ClosedByInterruptException} with the interrupt
410-
* status set.
409+
* java.nio.channels.ClosedByInterruptException} with the thread's
410+
* interrupted status set.
411411
* <li> The socket uses the system-default socket implementation and a
412412
* {@linkplain Thread#isVirtual() virtual thread} is accepting a
413413
* connection. In that case, interrupting the virtual thread will
414414
* cause it to wakeup and close the socket. This method will then throw
415-
* {@code SocketException} with the interrupt status set.
415+
* {@code SocketException} with the thread's interrupted status set.
416416
* </ol>
417417
*
418418
* @implNote

src/java.base/share/classes/java/net/Socket.java

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -573,12 +573,13 @@ void setConnected() {
573573
* a {@link SocketChannel SocketChannel}.
574574
* In that case, interrupting a thread establishing a connection will
575575
* close the underlying channel and cause this method to throw
576-
* {@link ClosedByInterruptException} with the interrupt status set.
576+
* {@link ClosedByInterruptException} with the thread's interrupted
577+
* status set.
577578
* <li> The socket uses the system-default socket implementation and a
578579
* {@linkplain Thread#isVirtual() virtual thread} is establishing a
579580
* connection. In that case, interrupting the virtual thread will
580581
* cause it to wakeup and close the socket. This method will then throw
581-
* {@code SocketException} with the interrupt status set.
582+
* {@code SocketException} with the thread's interrupted status set.
582583
* </ol>
583584
*
584585
* @param endpoint the {@code SocketAddress}
@@ -613,12 +614,13 @@ public void connect(SocketAddress endpoint) throws IOException {
613614
* a {@link SocketChannel SocketChannel}.
614615
* In that case, interrupting a thread establishing a connection will
615616
* close the underlying channel and cause this method to throw
616-
* {@link ClosedByInterruptException} with the interrupt status set.
617+
* {@link ClosedByInterruptException} with the thread's interrupted
618+
* status set.
617619
* <li> The socket uses the system-default socket implementation and a
618620
* {@linkplain Thread#isVirtual() virtual thread} is establishing a
619621
* connection. In that case, interrupting the virtual thread will
620622
* cause it to wakeup and close the socket. This method will then throw
621-
* {@code SocketException} with the interrupt status set.
623+
* {@code SocketException} with the thread's interrupted status set.
622624
* </ol>
623625
*
624626
* @apiNote Establishing a TCP/IP connection is subject to connect timeout settings
@@ -886,13 +888,14 @@ public SocketChannel getChannel() {
886888
* a {@link SocketChannel SocketChannel}.
887889
* In that case, interrupting a thread reading from the input stream
888890
* will close the underlying channel and cause the read method to
889-
* throw {@link ClosedByInterruptException} with the interrupt
890-
* status set.
891+
* throw {@link ClosedByInterruptException} with the thread's
892+
* interrupted status set.
891893
* <li> The socket uses the system-default socket implementation and a
892894
* {@linkplain Thread#isVirtual() virtual thread} is reading from the
893895
* input stream. In that case, interrupting the virtual thread will
894896
* cause it to wakeup and close the socket. The read method will then
895-
* throw {@code SocketException} with the interrupt status set.
897+
* throw {@code SocketException} with the thread's interrupted
898+
* status set.
896899
* </ol>
897900
*
898901
* <p>Under abnormal conditions the underlying connection may be
@@ -1026,13 +1029,14 @@ public void close() throws IOException {
10261029
* a {@link SocketChannel SocketChannel}.
10271030
* In that case, interrupting a thread writing to the output stream
10281031
* will close the underlying channel and cause the write method to
1029-
* throw {@link ClosedByInterruptException} with the interrupt status
1030-
* set.
1032+
* throw {@link ClosedByInterruptException} with the thread's
1033+
* interrupted status set.
10311034
* <li> The socket uses the system-default socket implementation and a
10321035
* {@linkplain Thread#isVirtual() virtual thread} is writing to the
10331036
* output stream. In that case, interrupting the virtual thread will
10341037
* cause it to wakeup and close the socket. The write method will then
1035-
* throw {@code SocketException} with the interrupt status set.
1038+
* throw {@code SocketException} with the thread's interrupted
1039+
* status set.
10361040
* </ol>
10371041
*
10381042
* <p> Closing the returned {@link java.io.OutputStream OutputStream}

src/java.base/share/classes/java/nio/channels/ClosedByInterruptException.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
/**
2929
* Checked exception received by a thread when another thread interrupts it
3030
* while it is blocked in an I/O operation upon a channel. Before this
31-
* exception is thrown the channel will have been closed and the interrupt
31+
* exception is thrown the channel will have been closed and the interrupted
3232
* status of the previously-blocked thread will have been set.
3333
*
3434
* @since 1.4

src/java.base/share/classes/java/nio/channels/DatagramChannel.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2000, 2024, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2000, 2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -290,7 +290,7 @@ public abstract <T> DatagramChannel setOption(SocketOption<T> name, T value)
290290
* If another thread interrupts the current thread
291291
* while the connect operation is in progress, thereby
292292
* closing the channel and setting the current thread's
293-
* interrupt status
293+
* interrupted status
294294
*
295295
* @throws UnresolvedAddressException
296296
* If the given remote address is not fully resolved
@@ -389,7 +389,7 @@ public abstract DatagramChannel connect(SocketAddress remote)
389389
* If another thread interrupts the current thread
390390
* while the read operation is in progress, thereby
391391
* closing the channel and setting the current thread's
392-
* interrupt status
392+
* interrupted status
393393
*
394394
* @throws IOException
395395
* If some other I/O error occurs
@@ -443,7 +443,7 @@ public abstract DatagramChannel connect(SocketAddress remote)
443443
* If another thread interrupts the current thread
444444
* while the read operation is in progress, thereby
445445
* closing the channel and setting the current thread's
446-
* interrupt status
446+
* interrupted status
447447
*
448448
* @throws UnresolvedAddressException
449449
* If the given remote address is not fully resolved

0 commit comments

Comments
 (0)