The JSR 292 — invokedynamic

I 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 CallSite after I have set the MethodHandle?
  • Can I keep a reference to CallSites at all?
  • Is the setMethodHanlde method 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: ,

  • http://blogs.sun.com/jrose/ John Rose

    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”.

  • Jevgeni Kabanov

    Thanks, John! Do I understand correctly that several CallSites can share a single StaticContext?

  • http://blogs.sun.com/jrose/ John Rose

    Yes.