RFR: 8287186: JDK modules participating in preview [v2]

Paul Sandoz psandoz at openjdk.java.net
Tue Jun 14 16:45:14 UTC 2022


On Wed, 8 Jun 2022 22:07:38 GMT, liach <duke at openjdk.java.net> wrote:

>> Paul Sandoz has updated the pull request incrementally with one additional commit since the last revision:
>> 
>>   Let java.management participate in preview features.
>
> Just curious, is it still up to incubator modules' discretion to avoid accidental user access to preview content via the modules without enabling preview, like the `PreviewFeatures.ensureEnabled()` in `StructuredTaskScope`?

@liach it depends on the API and its scope. A constructor of `StructuredTaskScope` specifies that it implicitly uses a virtual thread factory, so it performs a preview runtime check. 

The same check is also performed by `Thread.ofVirtual`, ensuring developers cannot reflectively work around 
`--enable-preview` when creating virtual threads. This approach is feasible since the API surface is so small.

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

PR: https://git.openjdk.org/jdk/pull/9087


More information about the core-libs-dev mailing list