Non static bootstrap method
Matthieu Riou
matthieu at offthelip.org
Mon Feb 21 18:00:02 PST 2011
Hi,
The short version is: can non static bootstrap methods be used to link an
invokedynamic call site? I've tried for some time to make it work but to no
avail, it all ends up in:
cannot convert to (Object,Object,Object)Object:
bootstrap(Caller,Lookup,String,MethodType)CallSite
Caller here is the class in which I've put my non-static bootstrap method,
so the error sort of makes sense and I'm obviously doing it wrong. But then
is there a way to do this? For reference my code is pasted here:
https://gist.github.com/837938 (uses ASM 4), the more interesting bit is
around line 66 of Indy.java.
The longer explanation of what I'm trying to do is compile an outer and an
inner function, each in their classes, each loaded by an anonymous
classloader. The outer can call the inner, which I'd like to be done by
invokedynamic, or even return the inner instance for someone else to call
later (also invokedynamic). So, using Javascript syntax, something that
could look like:
function outer() {
var a = 0;
function inner() {
// ... does something with a
}
inner();
return inner;
}
var inner = outer()
inner();
Without going too much into the details, each call site to inner creates a
new instance from a stub created when inner was first defined. So I need
invokedynamic to bootstrap the call site with that instance, which involves
making the instance available to bootstrap. It can be done by setting a
static field and having a static bootstrap access it, which works fine. But
in practice, as outer can be called several times, in a concurrent
environment it will force me to lock a potentially large chunk of code.
Hoping I'm making sense, thanks for any help.
Matthieu
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.openjdk.java.net/pipermail/mlvm-dev/attachments/20110221/f8aa4301/attachment.html
More information about the mlvm-dev
mailing list