RFR: 8284199: Implementation of Structured Concurrency (Incubator)

Alan Bateman alanb at openjdk.java.net
Mon May 23 11:13:32 UTC 2022


On Sat, 21 May 2022 14:09:59 GMT, ExE Boss <duke at openjdk.java.net> wrote:

>> This is the implementation of JEP 428: Structured Concurrency (Incubator).
>> 
>> This is a non-final API that provides a gentle on-ramp to structure a task as a family of concurrent subtasks, and to coordinate the subtasks as a unit.
>
> src/jdk.incubator.concurrent/share/classes/jdk/incubator/concurrent/StructuredTaskScope.java line 1172:
> 
>> 1170:                 }
>> 1171:             };
>> 1172:             return AccessController.doPrivileged(pa);
> 
> It might be better to use `MethodHandle`s obtained using <code>[jdk.internal.access.SharedSecrets]&#x200B;.getJavaLangInvokeAccess()</code> and <code>[JavaLangInvokeAccess]&#x200B;.findStatic(…)</code> and <code>[JavaLangInvokeAccess]&#x200B;.findVirtual(…)</code> for this, which would avoid going through `AccessController.doPrivilaged(…)`.
> 
> [jdk.internal.access.SharedSecrets]: https://github.com/openjdk/jdk/blob/master/src/java.base/share/classes/jdk/internal/access/SharedSecrets.java
> [JavaLangInvokeAccess]: https://github.com/openjdk/jdk/blob/master/src/java.base/share/classes/jdk/internal/access/JavaLangInvokeAccess.java

I'd prefer not export jdk.internal.access to this module, if possible.  In general, it's a lot easier to reason about the security and integrity of the core platform when java.base doesn't export any of its internal packages.

In any case, I expect this issue will resolve itself once there is a way for code in "core" modules to use preview APIs without needing to be compiled with --enable-preview. The java.management and jdk.incubator.vector modules have the same issue.

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

PR: https://git.openjdk.java.net/jdk/pull/8787


More information about the core-libs-dev mailing list