jakartaee / concurrency

Eclipse Project for Concurrency Utilities
https://projects.eclipse.org/projects/ee4j.cu
Other
68 stars 38 forks source link

[clarification]: Is virtual thread support mandatory for Java 21 environments in Concurrency 3.1? #493

Closed tnagao7 closed 2 months ago

tnagao7 commented 2 months ago

Specification

https://github.com/jakartaee/concurrency/blob/RELEASE-3.1.0-RC2/api/src/main/java/jakarta/enterprise/concurrent/ManagedExecutorDefinition.java#L218-L221

I need clarification on ...

I need clarification on virtual thread support in Jakarta Concurrency 3.1:

Is virtual thread support mandatory for Java 21 environments in Concurrency 3.1? In other words, is it required for all Jakarta Concurrency 3.1 compatible implementations that run on Java 21 to provide virtual thread support?

Additional information

I'd like to know the above to develop an implementation of Jakarta Concurrency 3.1, but I couldn't find a clear statement in the spec. The spec document (jakarta-concurrency.adoc) does not mention about this. The javadoc contains a statement that reads that virtual thread support can be optional as below.

https://github.com/jakartaee/concurrency/blob/a89b2522796eca917d0137577fcfddb3db3b381c/api/src/main/java/jakarta/enterprise/concurrent/ManagedExecutorDefinition.java#L218-L221

njr-11 commented 2 months ago

Is virtual thread support mandatory for Java 21 environments in Concurrency 3.1? In other words, is it required for all Jakarta Concurrency 3.1 compatible implementations that run on Java 21 to provide virtual thread support?

No, it is not mandatory for a Jakarta Concurrency 3.1 compatible implementation to support virtual threads on Java 21 or any other Java level.

The statement which you cited from the JavaDoc defining the virtual setting on ManagedExecutorDefinition (which also appears on some of the other resource definitions) is consistent with this. It allows the user to configure a value of true to ask for virtual threads, but does not require that the implementation provide or use virtual threads. This allows for the usage of Java 17 where there are no virtual threads as well as accommodates one of the vendors which insisted on not being required to support virtual threads on Java 21.

tnagao7 commented 2 months ago

No, it is not mandatory for a Jakarta Concurrency 3.1 compatible implementation to support virtual threads on Java 21 or any other Java level.

Does it mean that it is acceptable for an implementation without virtual thread support to skip TCK tests regarding virtual threads? In Jakarta Concurrency 3.1 TCK, there are tests checking the virtual setting in ee.jakarta.tck.concurrent.spec.Platform.virtual:

https://github.com/jakartaee/concurrency/tree/main/tck/src/main/java/ee/jakarta/tck/concurrent/spec/Platform/virtual

njr-11 commented 2 months ago

Does it mean that it is acceptable for an implementation without virtual thread support to skip TCK tests regarding virtual threads?

No, TCK cannot be skipped. These tests are written to match the specification requirements around virtual so that usage of virtual threads or platform threads by an implementation for virtual=true will both yield passing results.

tnagao7 commented 2 months ago

I see. I understand that TCK is designed to be able to run even on an implementation that produces platform threads regardless of the virtual setting. Thank you very much for your clarification.