Skip to content

Instantly share code, notes, and snippets.

@nahi
Created March 29, 2012 12:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nahi/2236839 to your computer and use it in GitHub Desktop.
Save nahi/2236839 to your computer and use it in GitHub Desktop.
diff --git a/src/org/jruby/runtime/invokedynamic/InvokeDynamicSupport.java b/src/org/jruby/runtime/invokedynamic/InvokeDynamicSupport.java
index 17e442c..13de470 100644
--- a/src/org/jruby/runtime/invokedynamic/InvokeDynamicSupport.java
+++ b/src/org/jruby/runtime/invokedynamic/InvokeDynamicSupport.java
@@ -426,8 +426,11 @@ public class InvokeDynamicSupport {
getValue = filterReturnValue(getValue, nullToNil);
// prepare fallback
- MethodHandle fallback = findStatic(InvokeDynamicSupport.class, "getVariableFallback", methodType(IRubyObject.class, VariableSite.class, IRubyObject.class));
- fallback = fallback.bindTo(site);
+ MethodHandle fallback = site.getTarget();
+ if (fallback == null) {
+ fallback = findStatic(InvokeDynamicSupport.class, "getVariableFallback", methodType(IRubyObject.class, VariableSite.class, IRubyObject.class));
+ fallback = fallback.bindTo(site);
+ }
// prepare test
MethodHandle test = findStatic(InvocationLinker.class, "testRealClass", methodType(boolean.class, RubyClass.class, IRubyObject.class));
@@ -455,8 +458,11 @@ public class InvokeDynamicSupport {
setValue = foldArguments(returnValue, setValue);
// prepare fallback
- MethodHandle fallback = findStatic(InvokeDynamicSupport.class, "setVariableFallback", methodType(IRubyObject.class, VariableSite.class, IRubyObject.class, IRubyObject.class));
- fallback = fallback.bindTo(site);
+ MethodHandle fallback = site.getTarget();
+ if (fallback == null) {
+ fallback = findStatic(InvokeDynamicSupport.class, "setVariableFallback", methodType(IRubyObject.class, VariableSite.class, IRubyObject.class, IRubyObject.class));
+ fallback = fallback.bindTo(site);
+ }
// prepare test
MethodHandle test = findStatic(InvocationLinker.class, "testRealClass", methodType(boolean.class, RubyClass.class, IRubyObject.class));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment