need little help for class loading & invokeDynamics
Rémi Forax
forax at univ-mlv.fr
Fri Jan 14 00:04:39 PST 2011
On 01/14/2011 06:15 AM, Marvin Hansen wrote:
> Hi Folks,
>
> I've started to work on invokeDynamics but I need a little help to
> understand how to use it right. For learning purpose, I've written a
> little class, that loads another class, does the method look-up and
> (should) execute the located method. The example in the methodHandle
> JavaDoc was my starting point but as usual it's not that easy since it
> works well for JDK classes but not with loading my own class which
> causes a “NoAccessException”.
>
> I suppose that I need to deal with CallSite& Bootstraping but I've
> not yet figured out how to patch class-loading, methodHandle,
> Bootstraping& invocation together in order to make it work. The
> JavaDoc says, that before an invokedynamic instruction can be executed
> a CallSite must be linked via boostrap method that produces a
> methodHandle. That makes sense for me.
>
> However, the CallSite JavaDoc is a little bit short on illustrating
> how to use it together with class-loading.
> The given example bootstrap Method:
>
> private static CallSite bootstrapDynamic(MethodHandles.Lookup caller,
> String name, MethodType type) {
> // ignore caller and name, but match the type:
> return new ConstantCallSite(MethodHandles.collectArguments(printArgs, type));
> }
>
> looks fine but this method is neither used nor linked or registered
> in the sample code of the JavaDoc so here are my related questions:
>
> 1) What is needed in a bootstrap method to produce a working callSite
> for a loaded class?
>
> 2) How is the bootstrap method linked to an invokedynamic instruction?
> The spec does not have the @BootstrapMethod anymore so what's the
> current way of linking?
The bootstrap method is know encoded as argument of the invokedynamic
instruction.
So each invokedynamic can have its own bootstrap method.
The main problem is that there is no way currently to emit an
invokedynamic in Java,
see
http://weblogs.java.net/blog/forax/archive/2011/01/07/call-invokedynamic-java
> 3) Should the class-loading be done by the bootstrap method or is it
> fine to do it before?
Fine to do it before.
>
> I really appriciate any input, since I'm new to InvokeDynamics and not
> familiar with all concepts.
>
> marvin
Rémi
More information about the mlvm-dev
mailing list