RFR: 8357797: Use StructuredTaskScopeImpl.ST_NEW for state init

Alan Bateman alanb at openjdk.org
Mon May 26 16:49:51 UTC 2025


On Mon, 26 May 2025 16:37:01 GMT, Aleksey Shipilev <shade at openjdk.org> wrote:

> SonarCloud complains `ST_NEW` constant is not used. Looks to me the constructor implicitly relies on default value for `state`. It would be cleaner to initialize it explicitly
> 
> Additional testing:
>  - [x] Linux x86_64 server fastdebug, `java/util/concurrent`

src/java.base/share/classes/java/util/concurrent/StructuredTaskScopeImpl.java line 70:

> 68:         this.joiner = joiner;
> 69:         this.threadFactory = threadFactory;
> 70:         this.flock = ThreadFlock.open((name != null) ? name : Objects.toIdentityString(this));

Unnecessary but okay. Do you mind moving it to the end of constructor as the fields are initialized in order declaration order in this constructor.

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/25452#discussion_r2107647128


More information about the core-libs-dev mailing list