On Sat, 21 May 2022 16:25:57 GMT, Alan Bateman <al...@openjdk.org> wrote:

>> 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.

Yes, we will add a more general internal for source that participate in preview 
APIs, and then the use of reflection can be removed. (The Vector API PR has a 
focused fix to the compiler, since it cannot use the reflection trick).

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

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

Reply via email to