On Fri, 26 May 2023 21:29:14 GMT, Chen Liang <li...@openjdk.org> wrote:

>>> This approach also requires the Class loading checks since the interface is 
>>> not unconditionally exported and fails security manager.
>> 
>> Are you referring to `ClassLoader::checkPackageAccess` change?   As MHProxy 
>> implements `sun.invoke.WrapperInstance`, it needs to export 
>> `java.base/sun.invoke` to the dynamic module.    The change to 
>> `ClassLoader::checkPackageAccess` doesn't make sense for this.
>
> Yes. Unfortunately, it fails at 
> https://github.com/openjdk/jdk/blob/bd21e68e679c41c98f39dd2fbd38270ae7d55ed9/src/java.base/share/classes/java/lang/SecurityManager.java#L1317
>  because a conditionally-exported package is considered a 
> non-(unconditionally-)exported package.

If we keep a cache of all MHProxy classes, I think this would not need 
`sun.invoke.WrapperInstance`.   OTOH, `sun.invoke` does not have any other 
class except `WrapperInstance` and the `ensureOriginalLookup` method would need 
to be in an internal class.   So no problem of implementing 
`sun.invoke.WrapperInstance`.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/13197#discussion_r1207387430

Reply via email to