The JSR 292 — invokedynamic
Written by Jevgeni Kabanov on May 20, 2008 – 8:21 amI read through the first draft of JSR 292 this morning and had several questions that I’m not 100% sure the current specification addresses:
- Can I rebind the
CallSiteafter I have set theMethodHandle? - Can I keep a reference to
CallSites at all? - Is the
setMethodHanldemethod implied to be thread-safe?
The reason I’m asking is that the only way to rebind a method as seen in spec is lazily, by invalidating all the call sites in the class (or everywhere) and rebinding methods when called. It may sometimes be necessary or easier to do that eagerly and it looks like the current API does allow that. It should either be forbidden explicitly or allowed explicitly.
I’ll send a link to the JSR-292-COMMENTS list as well, but perhaps someone knows the answer already?
Tags: java, jvm
Posted in cool | 3 Comments »
3 Comments to “The JSR 292 — invokedynamic”
Leave a Comment
Additional comments powered by BackType
May 20th, 2008 at 10:24 am
Thanks for giving it a read! Taking your questions in reverse order: 3. Since the linkage state is a single method handle (one reference), there are no race conditions, so it’s thread safe. 2. Yes, the spec. guarantees this; search for “the dynamic language can save it away”. 1. Yes; see the second paragraph of the section “Target method processing”.
May 20th, 2008 at 1:28 pm
Thanks, John! Do I understand correctly that several CallSites can share a single StaticContext?
May 21st, 2008 at 7:51 am
Yes.