Review Request: JDK-8235521: Replacement API for Unsafe::ensureClassInitialized

Mandy Chung mandy.chung at oracle.com
Thu Jun 4 19:33:05 UTC 2020


Lookup::accessClass sets the precedence to return Class for method 
chaining.  So this new method follows the existing convention.

Mandy

On 6/4/20 12:31 PM, Florent Guillaume wrote:
> Hi,
>
> Why can't it just return void?
>
> Florent
>
> On Thu, Jun 4, 2020 at 9:22 PM Mandy Chung <mandy.chung at oracle.com 
> <mailto:mandy.chung at oracle.com>> wrote:
>
>
>
>     On 6/4/20 9:43 AM, Chris Hegarty wrote:
>     > Mandy,
>     >
>     > I think this looks good. Just a few minor comments...
>     >
>     > The spec wording is hard, since the method is offering a
>     conditional initialization. I guess I expected to see something
>     like “initializes targetClass, if it has not been initialized
>     already”, or some such.
>
>     I added:
>         "This method causes {@code targetClass} to be initialized if
>     it has
>     not been already initialized."
>
>     to make it clear.
>     >
>     > The input and output is the same class instance. I don’t quite
>     get that from the spec. Can these be coupled together more
>     obviously by their descriptions? Maybe "@return targetClass, that
>     is initialized"
>
>     @return the class that has been initialized.
>
>     I changed it to:
>               * @return {@code targetClass} that has been initialized
>
>     Mandy
>     >
>     > -Chris.
>     >
>     >> On 4 Jun 2020, at 00:16, Mandy Chung <mandy.chung at oracle.com
>     <mailto:mandy.chung at oracle.com>> wrote:
>     >>
>     >> This proposes a new `Lookup::ensureClassInitialized` API as a
>     replacement
>     >> for `sun.misc.Unsafe::ensureClassInitialized`.The Lookup object
>     must have
>     >> the access to the given class being initialized.
>     >>
>     >> CSR: https://bugs.openjdk.java.net/browse/JDK-8245871
>     >>
>     >> webrev:
>     >> http://cr.openjdk.java.net/~mchung/jdk15/webrevs/8235521/webrev.01/
>     >>
>     >> This patch converts the JDK use of
>     `jdk.internal.misc.Unsafe::ensureClassInitialized` to
>     >> call this new API where appropriate.
>     `Unsafe::ensureClassInitialized` remains for java.lang.invoke.*
>     internal implementation use.
>     >>
>     >> A framework can use `Lookup::privateLookupIn` to access a class
>     in another module if the module authorizes it by opening the
>     packages for it to access. Or a user can produce a less privileged
>     lookup by Lookup::dropLookupMode and pass it to the framework.
>     >>
>     >> `Class::ensureInitialized` was considered as an alternative.
>     The downside for this option is that it would be caller sensitive
>     in order to ensure the caller has the proper access to this
>     class.  And it may not work for frameworks which have no access to
>     user classes. It would have to fallback toClass::forName` limited
>     solution.
>     >>
>     >> Thanks
>     >> Mandy
>     >>
>
>
>
> -- 
> Nuxeo Logo <https://www.nuxeo.com/> 	
>
> Florent Guillaume Head of R&D LinkedIn 
> <https://www.linkedin.com/in/fguillaume/> Twitter 
> <https://twitter.com/efge> Github <https://github.com/efge>
>
> Nuxeo Content Services Platform. Stay ahead.
>



More information about the core-libs-dev mailing list