APIdia Launch Partner
Top Description Inners Fields Constructors Methods
java.util.concurrent

pack-priv final Class StructuredTaskScopeImpl<T, R, R_X extends Throwable>

extends Object
implements StructuredTaskScope<T, R, R_X extends Throwable>
Class Inheritance
All Implemented Interfaces
java.util.concurrent.StructuredTaskScope, java.lang.AutoCloseable
Imports
java.lang.invoke.MethodHandles, .VarHandle, java.time.Duration, java.util.Objects, java.util.function.UnaryOperator, jdk.internal.misc.ThreadFlock, jdk.internal.invoke.MhUtil, jdk.internal.vm.annotation.Stable

StructuredTaskScope implementation.

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv static record
StructuredTaskScopeImpl.ConfigImpl

Configuration implementation.

pack-priv static class
StructuredTaskScopeImpl.SubtaskImpl<T>

Subtask implementation, runs the task specified to the fork method.

Field Summary

Modifier and TypeField and Description
private static final VarHandle
private volatile boolean
private final ThreadFlock
private final StructuredTaskScope.Joiner<? super T, ? extends R, R_X>
private static final int
private static final int
private static final int
private static final int
private volatile int
private final ThreadFactory
private volatile boolean
private Future<?>

Constructor Summary

AccessConstructor and Description
private
StructuredTaskScopeImpl(StructuredTaskScope.Joiner<? super T, ? extends R, R_X> joiner, ThreadFactory threadFactory, String name)

Method Summary

Modifier and TypeMethod and Description
private void
cancel()

Cancel the scope if not already cancelled.

private void
cancelTimeout()

Cancels the timer task if set.

public void
close()

Implements java.util.concurrent.StructuredTaskScope.close.

Closes this scope.

private void
ensureOwner()

Throws WrongThreadException if the current thread is not the owner thread.

public <U extends T> StructuredTaskScope.Subtask<U>
fork(Callable<? extends U> task)

Implements java.util.concurrent.StructuredTaskScope.fork.

Forks a subtask by starting a new thread in this scope to execute a value-returning method.

public <U extends T> StructuredTaskScope.Subtask<U>
fork(Runnable task)

Implements java.util.concurrent.StructuredTaskScope.fork.

Forks a subtask by starting a new thread in this scope to execute a method that does not return a result.

private void
interruptAll()

Interrupts all threads in this scope, except the current thread.

public boolean
isCancelled()

Implements java.util.concurrent.StructuredTaskScope.isCancelled.

Returns true if this scope is cancelled or in the process of being cancelled, otherwise false.

private boolean
isJoinCompleted()

Returns true if join has been invoked and there is an outcome.

public R
join()

Implements java.util.concurrent.StructuredTaskScope.join.

Returns a result, or throws, after waiting for all subtasks to complete or the scope to be cancelled.

private <U extends T> void
onComplete(StructuredTaskScopeImpl.SubtaskImpl<U> subtask)

Invoked by the thread for a subtask when the subtask completes before scope is cancelled.

pack-priv static <T, R, R_X extends Throwable> StructuredTaskScope<T, R, R_X>
open(StructuredTaskScope.Joiner<? super T, ? extends R, R_X> joiner, UnaryOperator<StructuredTaskScope.Configuration> configOperator)

Hides java.util.concurrent.StructuredTaskScope.open.

Returns a new StructuredTaskScope to use the given Joiner object and with configuration that is the result of applying the given function to the default configuration.

private void
scheduleTimeout(Duration timeout)

Schedules a task to cancel the scope on timeout.

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

CANCELLEDback to summary
private static final VarHandle CANCELLED
cancelledback to summary
private volatile boolean cancelled
flockback to summary
private final ThreadFlock flock
joinerback to summary
private final StructuredTaskScope.Joiner<? super T, ? extends R, R_X> joiner
ST_CLOSEDback to summary
private static final int ST_CLOSED
ST_FORKEDback to summary
private static final int ST_FORKED
ST_JOIN_COMPLETEDback to summary
private static final int ST_JOIN_COMPLETED
ST_JOIN_STARTEDback to summary
private static final int ST_JOIN_STARTED
stateback to summary
private volatile int state
threadFactoryback to summary
private final ThreadFactory threadFactory
timeoutExpiredback to summary
private volatile boolean timeoutExpired
timerTaskback to summary
private Future<?> timerTask

Constructor Detail

StructuredTaskScopeImplback to summary
private StructuredTaskScopeImpl(StructuredTaskScope.Joiner<? super T, ? extends R, R_X> joiner, ThreadFactory threadFactory, String name)
Annotations
@SuppressWarnings:this-escape

Method Detail

cancelback to summary
private void cancel()

Cancel the scope if not already cancelled.

cancelTimeoutback to summary
private void cancelTimeout()

Cancels the timer task if set.

closeback to summary
public void close()

Implements java.util.concurrent.StructuredTaskScope.close.

Doc from java.util.concurrent.StructuredTaskScope.close.

Closes this scope.

This method first cancels the scope, if not already cancelled. This interrupts the threads executing unfinished subtasks. This method then waits for all threads to finish. If interrupted while waiting then it will continue to wait until the threads finish, before completing with the interrupted status set.

This method may only be invoked by the scope owner. If the scope is already closed then the scope owner invoking this method has no effect.

A StructuredTaskScope is intended to be used in a structured manner. If this method is called to close a scope before nested scopes are closed then it closes the underlying construct of each nested scope (in the reverse order that they were created in), closes this scope, and then throws StructureViolationException. Similarly, if this method is called to close a scope while executing with scoped value bindings, and the scope was created before the scoped values were bound, then StructureViolationException is thrown after closing the scope. If a thread terminates without first closing scopes that it owns then termination will cause the underlying construct of each of its open scopes to be closed. Closing is performed in the reverse order that the scopes were created in. Thread termination may therefore be delayed when the scope owner has to wait for threads forked in these scopes to finish.

Annotations
@Override
ensureOwnerback to summary
private void ensureOwner()

Throws WrongThreadException if the current thread is not the owner thread.

forkback to summary
public <U extends T> StructuredTaskScope.Subtask<U> fork(Callable<? extends U> task)

Implements java.util.concurrent.StructuredTaskScope.fork.

Doc from java.util.concurrent.StructuredTaskScope.fork.

Forks a subtask by starting a new thread in this scope to execute a value-returning method. The new thread executes the subtask concurrently with the current thread. The parameter to this method is a Callable, the new thread executes its call() method. The thread inherits the current thread's scoped value bindings that must match the bindings captured when the scope was opened.

If the scope was opened with a function to produce the Configuration for the scope, and a ThreadFactory is set, then its newThread(Runnable) method is invoked to create the thread that will execute the subtask. RejectedExecutionException is thrown if the newThread(Runnable) method returns null. If a ThreadFactory is not set, the fork(Callable) method creates an unnamed virtual thread to execute the subtask.

This method returns a Subtask object as a handle to the forked subtask. If the scope is cancelled, the Subtask is returned in the UNAVAILABLE state without creating a thread. In some usages, Subtask object will be used by the "main" task (the scope owner) to get the subtask's outcome (result or exception) after it has invoked join() to wait for all subtasks to complete. In other usages, the scope is created with a Joiner that produces the outcome for the main task to process after joining. A Joiner that produces a result reduces the need for bookkeeping and the need for the main task to retain references to Subtask objects for correlation purposes.

To ensure correct usage, the Subtask.get() method may only be called by the scope owner to get the result of a successful subtask after it has waited for subtasks to complete with the join() method. Similarly, the Subtask.exception() method may only be called by the scope owner to get the exception (or error) of a failed subtask after it has joined.

This method may only be invoked by the scope owner.

Joiner Implementers:

If the scope was opened with a Joiner, its onFork(Subtask) method is invoked with the newly created Subtask object before the thread is created. It is invoked with the subtask in the UNAVAILABLE state. If the method throws an exception or error then it is propagated by the fork(Callable) method without creating a thread to execute the subtask. If the scope is not already cancelled, and the onFork method return false, then a thread is created and scheduled to start execution of the subtask. If the scope is cancelled, or the onFork method returns true to cancel the scope, fork(Callable) returns the subtask in the UNAVAILABLE state.

If the subtask executes and completes (successfully or with an exception) before the scope is cancelled, then the thread invokes the Joiner's onComplete(Subtask) method with the subtask in the SUCCESS or FAILED state. If the onComplete(Subtask) method returns true then the scope is cancelled, if not already cancelled. If the onComplete(Subtask) method completes with an exception or error, then the thread executes the uncaught exception handler before the thread terminates.

Annotations
@Override
forkback to summary
public <U extends T> StructuredTaskScope.Subtask<U> fork(Runnable task)

Implements java.util.concurrent.StructuredTaskScope.fork.

Doc from java.util.concurrent.StructuredTaskScope.fork.

Forks a subtask by starting a new thread in this scope to execute a method that does not return a result.

This method works exactly the same as fork(Callable) except that the parameter to this method is a Runnable, the new thread executes its run() method, and Subtask.get() returns null if the subtask completes successfully.

Annotations
@Override
interruptAllback to summary
private void interruptAll()

Interrupts all threads in this scope, except the current thread.

isCancelledback to summary
public boolean isCancelled()

Implements java.util.concurrent.StructuredTaskScope.isCancelled.

Doc from java.util.concurrent.StructuredTaskScope.isCancelled.

Returns true if this scope is cancelled or in the process of being cancelled, otherwise false.

Cancelling the scope prevents new threads from starting in the scope and interrupts threads executing unfinished subtasks. It may take some time before the interrupted threads finish execution; this method may return true before all threads have been interrupted or before all threads have finished.

Annotations
@Override
isJoinCompletedback to summary
private boolean isJoinCompleted()

Returns true if join has been invoked and there is an outcome.

joinback to summary
public R join() throws Joiner:R_X, InterruptedException

Implements java.util.concurrent.StructuredTaskScope.join.

Doc from java.util.concurrent.StructuredTaskScope.join.

Returns a result, or throws, after waiting for all subtasks to complete or the scope to be cancelled.

If the scope was opened with the open() or open(UnaryOperator) method, then join() waits for all subtasks to succeed or any subtask to fail. It returns null if all subtasks complete successfully. It throws ExecutionException if any subtask fails, with exception from the first subtask to fail as the cause. If a timeout is configured and the timeout expires before or while waiting, it throws ExecutionException with a CancelledByTimeoutException as the cause.

If the scope was opened with a Joiner, it is invoked after waiting or cancellation to produce the outcome (result or exception). This includes the timeout case where a timeout is configured and it expires before or while waiting in the join() method.

This method may only be invoked by the scope owner. It may only be invoked once to get the result, exception or timeout outcome, unless the previous invocation resulted in an InterruptedException being thrown.

Joiner Implementers:

When all subtasks complete, or the scope cancelled, this method invokes the Joiner's result() or timeout() method to produce the outcome (result or exception) for the join() method. The result() method is invoked for the "no timeout" case. The timeout() method is invoked for the timeout case. If the outcome for the timeout case is an exception then it is thrown with a CancelledByTimeoutException as the cause.

Annotations
@Override
Exceptions
Joiner:R_X:
when the outcome is an exception
InterruptedException:
if the current thread is interrupted while waiting or this method is invoked with the current thread's interrupted status set. The current thread's interrupted status is cleared when this exception is thrown.
onCompleteback to summary
private <U extends T> void onComplete(StructuredTaskScopeImpl.SubtaskImpl<U> subtask)

Invoked by the thread for a subtask when the subtask completes before scope is cancelled.

openback to summary
pack-priv static <T, R, R_X extends Throwable> StructuredTaskScope<T, R, R_X> open(StructuredTaskScope.Joiner<? super T, ? extends R, R_X> joiner, UnaryOperator<StructuredTaskScope.Configuration> configOperator)

Hides java.util.concurrent.StructuredTaskScope.open.

Returns a new StructuredTaskScope to use the given Joiner object and with configuration that is the result of applying the given function to the default configuration.

scheduleTimeoutback to summary
private void scheduleTimeout(Duration timeout)

Schedules a task to cancel the scope on timeout.

toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Annotations
@Override
java.util.concurrent back to summary

pack-priv final Record StructuredTaskScopeImpl.ConfigImpl

extends Record
implements Configuration
Class Inheritance
All Implemented Interfaces
java.util.concurrent.StructuredTaskScope.Configuration
Record Components
threadFactory:ThreadFactory 
name:String 
timeout:Duration 

Configuration implementation.

Field Summary

Modifier and TypeField and Description
private final String
name

Record Component accessed by name().

private final ThreadFactory
threadFactory

Record Component accessed by threadFactory().

private final Duration
timeout

Record Component accessed by timeout().

Constructor Summary

AccessConstructor and Description
pack-priv
ConfigImpl(ThreadFactory threadFactory, String name, Duration timeout)

Method Summary

Modifier and TypeMethod and Description
pack-priv static StructuredTaskScope.Configuration
public final boolean
equals(Object o)

Implements abstract java.lang.Record.equals.

Indicates whether some other object is "equal to" this one.

public final int
hashCode()

Implements abstract java.lang.Record.hashCode.

Returns a hash code value for the record.

public String
name()

Record Component getter of name.

public ThreadFactory
threadFactory()

Record Component getter of threadFactory.

public Duration
timeout()

Record Component getter of timeout.

public final String
toString()

Implements abstract java.lang.Record.toString.

Returns a string representation of the record.

public StructuredTaskScope.Configuration
withName(String name)

Implements java.util.concurrent.StructuredTaskScope.Configuration.withName.

Returns a new Configuration object with the given scope name.

public StructuredTaskScope.Configuration
withThreadFactory(ThreadFactory threadFactory)

Implements java.util.concurrent.StructuredTaskScope.Configuration.withThreadFactory.

Returns a new Configuration object with the given thread factory.

public StructuredTaskScope.Configuration
withTimeout(Duration timeout)

Implements java.util.concurrent.StructuredTaskScope.Configuration.withTimeout.

Returns a new Configuration object with the given timeout.

Field Detail

nameback to summary
private final String name

Record Component accessed by name().

threadFactoryback to summary
private final ThreadFactory threadFactory

Record Component accessed by threadFactory().

timeoutback to summary
private final Duration timeout

Record Component accessed by timeout().

Constructor Detail

ConfigImplback to summary
pack-priv ConfigImpl(ThreadFactory threadFactory, String name, Duration timeout)

Method Detail

defaultConfigback to summary
pack-priv static StructuredTaskScope.Configuration defaultConfig()
equalsback to summary
public final boolean equals(Object o)

Implements abstract java.lang.Record.equals.

Doc from java.lang.Record.equals.

Indicates whether some other object is "equal to" this one. In addition to the general contract of Object.equals, record classes must further obey the invariant that when a record instance is "copied" by passing the result of the record component accessor methods to the canonical constructor, as follows:

    R copy = new R(r.c1(), r.c2(), ..., r.cn());
then it must be the case that r.equals(copy).
hashCodeback to summary
public final int hashCode()

Implements abstract java.lang.Record.hashCode.

Doc from java.lang.Record.hashCode.

Returns a hash code value for the record. Obeys the general contract of Object.hashCode. For records, hashing behavior is constrained by the refined contract of Record.equals, so that any two records created from the same components must have the same hash code.

nameback to summary
public String name()

Record Component getter of name.

threadFactoryback to summary
public ThreadFactory threadFactory()

Record Component getter of threadFactory.

timeoutback to summary
public Duration timeout()

Record Component getter of timeout.

toStringback to summary
public final String toString()

Implements abstract java.lang.Record.toString.

Doc from java.lang.Record.toString.

Returns a string representation of the record. In accordance with the general contract of Object#toString(), the toString method returns a string that "textually represents" this record. The result should be a concise but informative representation that is easy for a person to read.

In addition to this general contract, record classes must further participate in the invariant that any two records which are equal must produce equal strings. This invariant is necessarily relaxed in the rare case where corresponding equal component values might fail to produce equal strings for themselves.

withNameback to summary
public StructuredTaskScope.Configuration withName(String name)

Implements java.util.concurrent.StructuredTaskScope.Configuration.withName.

Doc from java.util.concurrent.StructuredTaskScope.Configuration.withName.

Returns a new Configuration object with the given scope name. The other components are the same as this object. A scope is optionally named for the purposes of monitoring and management.

Annotations
@Override
withThreadFactoryback to summary
public StructuredTaskScope.Configuration withThreadFactory(ThreadFactory threadFactory)

Implements java.util.concurrent.StructuredTaskScope.Configuration.withThreadFactory.

Doc from java.util.concurrent.StructuredTaskScope.Configuration.withThreadFactory.

Returns a new Configuration object with the given thread factory. The other components are the same as this object. The thread factory is used by a scope to create threads when forking subtasks.

Annotations
@Override
withTimeoutback to summary
public StructuredTaskScope.Configuration withTimeout(Duration timeout)

Implements java.util.concurrent.StructuredTaskScope.Configuration.withTimeout.

Doc from java.util.concurrent.StructuredTaskScope.Configuration.withTimeout.

Returns a new Configuration object with the given timeout. The other components are the same as this object.

Annotations
@Override
java.util.concurrent back to summary

pack-priv final Class StructuredTaskScopeImpl.SubtaskImpl<T>

extends Object
implements StructuredTaskScope.Subtask<T>, Runnable
Class Inheritance
All Implemented Interfaces
java.lang.Runnable, java.util.concurrent.StructuredTaskScope.Subtask, java.util.function.Supplier

Subtask implementation, runs the task specified to the fork method.

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static record

Field Summary

Modifier and TypeField and Description
private volatile Object
private static final StructuredTaskScopeImpl.SubtaskImpl.AltResult
private final StructuredTaskScopeImpl<? super T, ?, ?>
private final Callable<? extends T>
private Thread

Constructor Summary

AccessConstructor and Description
pack-priv
SubtaskImpl(StructuredTaskScopeImpl<? super T, ?, ?> scope, Callable<? extends T> task)

Method Summary

Modifier and TypeMethod and Description
private void
ensureJoinedIfNotSubtask()

Throws IllegalStateException if the caller thread is not the subtask and the scope owner has not joined.

public Throwable
exception()

Implements java.util.concurrent.StructuredTaskScope.Subtask.exception.

Returns the exception or error thrown by this subtask if it failed.

public T
get()

Implements java.util.concurrent.StructuredTaskScope.Subtask.get.

Returns the result of this subtask if it completed successfully.

public void
run()

Implements java.lang.Runnable.run.

Runs this operation.

pack-priv void
setThread(Thread thread)

Sets the thread for this subtask.

public StructuredTaskScope.Subtask.State
state()

Implements java.util.concurrent.StructuredTaskScope.Subtask.state.

Returns the subtask state.

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

resultback to summary
private volatile Object result
RESULT_NULLback to summary
private static final StructuredTaskScopeImpl.SubtaskImpl.AltResult RESULT_NULL
scopeback to summary
private final StructuredTaskScopeImpl<? super T, ?, ?> scope
taskback to summary
private final Callable<? extends T> task
threadback to summary
private Thread thread
Annotations
@Stable

Constructor Detail

SubtaskImplback to summary
pack-priv SubtaskImpl(StructuredTaskScopeImpl<? super T, ?, ?> scope, Callable<? extends T> task)

Method Detail

ensureJoinedIfNotSubtaskback to summary
private void ensureJoinedIfNotSubtask()

Throws IllegalStateException if the caller thread is not the subtask and the scope owner has not joined.

exceptionback to summary
public Throwable exception()

Implements java.util.concurrent.StructuredTaskScope.Subtask.exception.

Doc from java.util.concurrent.StructuredTaskScope.Subtask.exception.

Returns the exception or error thrown by this subtask if it failed. If the scope is cancelled, the subtask failed before the scope was cancelled. If the subtask was forked with fork(Callable) then the exception or error thrown by the call() method is returned. If the subtask was forked with fork(Runnable) then the exception or error thrown by the run() method is returned.

Code executing in the scope owner thread can use this method to get the exception thrown by a failed subtask after it has joined.

Code executing in a Joiner onComplete(Subtask) method should test that the state is FAILED before using this method to get the exception.

This method may be invoked by any thread after the scope owner has joined. The only case where this method can be used to get the exception before the scope owner has joined is when called from the onComplete(Subtask) method.

Annotations
@Override
getback to summary
public T get()

Implements java.util.concurrent.StructuredTaskScope.Subtask.get.

Doc from java.util.concurrent.StructuredTaskScope.Subtask.get.

Returns the result of this subtask if it completed successfully. If the scope is cancelled, the subtask completed successfully before the scope was cancelled. If the subtask was forked with fork(Callable) then the result from the call() method is returned. If the subtask was forked with fork(Runnable) then null is returned.

Code executing in the scope owner thread can use this method to get the result of a successful subtask after it has joined.

Code executing in the Joiner onComplete(Subtask) method should test that the state is SUCCESS before using this method to get the result.

This method may be invoked by any thread after the scope owner has joined. The only case where this method can be used to get the result before the scope owner has joined is when called from the onComplete(Subtask) method.

Annotations
@Override
runback to summary
public void run()

Implements java.lang.Runnable.run.

Doc from java.lang.Runnable.run.

Runs this operation.

Annotations
@Override
setThreadback to summary
pack-priv void setThread(Thread thread)

Sets the thread for this subtask.

stateback to summary
public StructuredTaskScope.Subtask.State state()

Implements java.util.concurrent.StructuredTaskScope.Subtask.state.

Doc from java.util.concurrent.StructuredTaskScope.Subtask.state.

Returns the subtask state.

Annotations
@Override
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Annotations
@Override
java.util.concurrent back to summary

private final Record StructuredTaskScopeImpl.SubtaskImpl.AltResult

extends Record
Class Inheritance
Record Components
state:StructuredTaskScope.Subtask.State 
exception:Throwable 

Field Summary

Modifier and TypeField and Description
private final Throwable
exception

Record Component accessed by exception().

private final StructuredTaskScope.Subtask.State
state

Record Component accessed by state().

Constructor Summary

AccessConstructor and Description
pack-priv
private

Method Summary

Modifier and TypeMethod and Description
public final boolean
equals(Object o)

Implements abstract java.lang.Record.equals.

Indicates whether some other object is "equal to" this one.

public Throwable
exception()

Record Component getter of exception.

public final int
hashCode()

Implements abstract java.lang.Record.hashCode.

Returns a hash code value for the record.

public StructuredTaskScope.Subtask.State
state()

Record Component getter of state.

public final String
toString()

Implements abstract java.lang.Record.toString.

Returns a string representation of the record.

Field Detail

exceptionback to summary
private final Throwable exception

Record Component accessed by exception().

stateback to summary
private final StructuredTaskScope.Subtask.State state

Record Component accessed by state().

Constructor Detail

AltResultback to summary
pack-priv AltResult(StructuredTaskScope.Subtask.State state)
AltResultback to summary
private AltResult(StructuredTaskScope.Subtask.State state, Throwable exception)

Method Detail

equalsback to summary
public final boolean equals(Object o)

Implements abstract java.lang.Record.equals.

Doc from java.lang.Record.equals.

Indicates whether some other object is "equal to" this one. In addition to the general contract of Object.equals, record classes must further obey the invariant that when a record instance is "copied" by passing the result of the record component accessor methods to the canonical constructor, as follows:

    R copy = new R(r.c1(), r.c2(), ..., r.cn());
then it must be the case that r.equals(copy).
exceptionback to summary
public Throwable exception()

Record Component getter of exception.

hashCodeback to summary
public final int hashCode()

Implements abstract java.lang.Record.hashCode.

Doc from java.lang.Record.hashCode.

Returns a hash code value for the record. Obeys the general contract of Object.hashCode. For records, hashing behavior is constrained by the refined contract of Record.equals, so that any two records created from the same components must have the same hash code.

stateback to summary
public StructuredTaskScope.Subtask.State state()

Record Component getter of state.

toStringback to summary
public final String toString()

Implements abstract java.lang.Record.toString.

Doc from java.lang.Record.toString.

Returns a string representation of the record. In accordance with the general contract of Object#toString(), the toString method returns a string that "textually represents" this record. The result should be a concise but informative representation that is easy for a person to read.

In addition to this general contract, record classes must further participate in the invariant that any two records which are equal must produce equal strings. This invariant is necessarily relaxed in the rare case where corresponding equal component values might fail to produce equal strings for themselves.