Error in sequence initialisation of Lookup

John Rose John.Rose at Sun.COM
Mon Jun 8 22:57:49 PDT 2009


On Jun 5, 2009, at 1:31 AM, Rémi Forax wrote:

> This program throw an Internal Error
> ...
> MethodHandles$Lookup static init calls MethodHandles.<clinit>
> but *before* the call to initLookup(), the class MethodHandleImpl need
> to be initialized,
> so its <clinit> is called and raise the InternalError.
>
> static final Lookup IMPL_LOOKUP = new Lookup(null);
> static { MethodHandleImpl.initLookup(IMPL_TOKEN, IMPL_LOOKUP);
>
> A simple patch, even if it doesn't solve the real problem is to
> change the visibility of the constant PUBLIC_LOOKUP in Lookup
> and to provide an access through a method in MethodHandles
>
> public static Lookup lookup() {
>  return new Lookup();
> }
>
> public static Lookup publicLookup() {
>  return Lookup.PUBLIC_LOOKUP;
> }

That's a good fix, and in fact a better API than PUBLIC_LOOKUP.  Let's  
use MHs.publicLookup() as the API.

An alternate fix (and something I put in also just for stability) is  
to have MHs.Lookup trigger static initialization of MHs before it does  
anything else.

-- John



More information about the mlvm-dev mailing list