Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: jruby/jruby
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 10fd56716282
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 82b771a73ec4
Choose a head ref
  • 2 commits
  • 2 files changed
  • 1 contributor

Commits on Sep 6, 2016

  1. Deprecate frame-sensitive "invoke" methods and add "invokeFrom".

    This is in response to callers not seting up frame and breaking
    visibility checks in #4134. This goes along with #4138.
    headius committed Sep 6, 2016
    Copy the full SHA
    999ee4f View commit details
  2. Merge pull request #4139 from headius/deprecate_framed_invoke

    Deprecate framed invoke
    headius authored Sep 6, 2016
    Copy the full SHA
    82b771a View commit details
Showing with 362 additions and 111 deletions.
  1. +305 −100 core/src/main/java/org/jruby/RubyClass.java
  2. +57 −11 core/src/main/java/org/jruby/runtime/Helpers.java
405 changes: 305 additions & 100 deletions core/src/main/java/org/jruby/RubyClass.java
Original file line number Diff line number Diff line change
@@ -500,25 +500,10 @@ public RubyClass makeMetaClass(RubyClass superClass) {
}
}

@Deprecated
public IRubyObject invoke(ThreadContext context, IRubyObject self, int methodIndex, String name, IRubyObject[] args, CallType callType, Block block) {
return invoke(context, self, name, args, callType, block);
}

public boolean notVisibleAndNotMethodMissing(DynamicMethod method, String name, IRubyObject caller, CallType callType) {
return !method.isCallableFrom(caller, callType) && !name.equals("method_missing");
}

public IRubyObject invoke(ThreadContext context, IRubyObject self, String name,
CallType callType, Block block) {
DynamicMethod method = searchMethod(name);
IRubyObject caller = context.getFrameSelf();
if (shouldCallMethodMissing(method, name, caller, callType)) {
return Helpers.callMethodMissing(context, self, method.getVisibility(), name, callType, block);
}
return method.call(context, self, this, name, block);
}

public IRubyObject finvoke(ThreadContext context, IRubyObject self, String name, Block block) {
DynamicMethod method = searchMethod(name);
if (shouldCallMethodMissing(method)) {
@@ -527,100 +512,170 @@ public IRubyObject finvoke(ThreadContext context, IRubyObject self, String name,
return method.call(context, self, this, name, block);
}

public IRubyObject invoke(ThreadContext context, IRubyObject self, String name,
IRubyObject[] args, CallType callType, Block block) {
public IRubyObject finvoke(ThreadContext context, IRubyObject self, String name,
IRubyObject[] args, Block block) {
assert args != null;
DynamicMethod method = searchMethod(name);
IRubyObject caller = context.getFrameSelf();
if (shouldCallMethodMissing(method, name, caller, callType)) {
return Helpers.callMethodMissing(context, self, method.getVisibility(), name, callType, args, block);
if (shouldCallMethodMissing(method)) {
return Helpers.callMethodMissing(context, self, method.getVisibility(), name, CallType.FUNCTIONAL, args, block);
}
return method.call(context, self, this, name, args, block);
}

public IRubyObject finvoke(ThreadContext context, IRubyObject self, String name,
IRubyObject[] args, Block block) {
assert args != null;
IRubyObject arg, Block block) {
DynamicMethod method = searchMethod(name);
if (shouldCallMethodMissing(method)) {
return Helpers.callMethodMissing(context, self, method.getVisibility(), name, CallType.FUNCTIONAL, args, block);
return Helpers.callMethodMissing(context, self, method.getVisibility(), name, CallType.FUNCTIONAL, arg, block);
}
return method.call(context, self, this, name, args, block);
return method.call(context, self, this, name, arg, block);
}

public IRubyObject invoke(ThreadContext context, IRubyObject self, String name,
IRubyObject arg, CallType callType, Block block) {
public IRubyObject finvoke(ThreadContext context, IRubyObject self, String name,
IRubyObject arg0, IRubyObject arg1, Block block) {
DynamicMethod method = searchMethod(name);
IRubyObject caller = context.getFrameSelf();
if (shouldCallMethodMissing(method, name, caller, callType)) {
return Helpers.callMethodMissing(context, self, method.getVisibility(), name, callType, arg, block);
if (shouldCallMethodMissing(method)) {
return Helpers.callMethodMissing(context, self, method.getVisibility(), name, CallType.FUNCTIONAL, arg0, arg1, block);
}
return method.call(context, self, this, name, arg, block);
return method.call(context, self, this, name, arg0, arg1, block);
}

public IRubyObject finvoke(ThreadContext context, IRubyObject self, String name,
IRubyObject arg, Block block) {
IRubyObject arg0, IRubyObject arg1, IRubyObject arg2, Block block) {
DynamicMethod method = searchMethod(name);
if (shouldCallMethodMissing(method)) {
return Helpers.callMethodMissing(context, self, method.getVisibility(), name, CallType.FUNCTIONAL, arg, block);
return Helpers.callMethodMissing(context, self, method.getVisibility(), name, CallType.FUNCTIONAL, arg0, arg1, arg2, block);
}
return method.call(context, self, this, name, arg, block);
return method.call(context, self, this, name, arg0, arg1, arg2, block);
}

public IRubyObject invoke(ThreadContext context, IRubyObject self, String name,
IRubyObject arg0, IRubyObject arg1, CallType callType, Block block) {
public IRubyObject finvoke(ThreadContext context, IRubyObject self, String name) {
DynamicMethod method = searchMethod(name);
if (shouldCallMethodMissing(method)) {
return Helpers.callMethodMissing(context, self, method.getVisibility(), name, CallType.FUNCTIONAL, Block.NULL_BLOCK);
}
return method.call(context, self, this, name);
}

/**
* Same behavior as finvoke, but uses the given caller object to check visibility if callType demands it.
*/
public IRubyObject invokeFrom(ThreadContext context, CallType callType, IRubyObject caller, IRubyObject self, String name,
Block block) {
DynamicMethod method = searchMethod(name);
IRubyObject caller = context.getFrameSelf();
if (shouldCallMethodMissing(method, name, caller, callType)) {
return Helpers.callMethodMissing(context, self, method.getVisibility(), name, callType, arg0, arg1, block);
return Helpers.callMethodMissing(context, self, method.getVisibility(), name, callType, block);
}
return method.call(context, self, this, name, arg0, arg1, block);
return method.call(context, self, this, name, block);
}

public IRubyObject finvoke(ThreadContext context, IRubyObject self, String name,
IRubyObject arg0, IRubyObject arg1, Block block) {
/**
* Same behavior as finvoke, but uses the given caller object to check visibility if callType demands it.
*/
public IRubyObject invokeFrom(ThreadContext context, CallType callType, IRubyObject caller, IRubyObject self, String name,
IRubyObject[] args, Block block) {
assert args != null;
DynamicMethod method = searchMethod(name);
if (shouldCallMethodMissing(method)) {
return Helpers.callMethodMissing(context, self, method.getVisibility(), name, CallType.FUNCTIONAL, arg0, arg1, block);
if (shouldCallMethodMissing(method, name, caller, callType)) {
return Helpers.callMethodMissing(context, self, method.getVisibility(), name, callType, args, block);
}
return method.call(context, self, this, name, arg0, arg1, block);
return method.call(context, self, this, name, args, block);
}

public IRubyObject invoke(ThreadContext context, IRubyObject self, String name,
IRubyObject arg0, IRubyObject arg1, IRubyObject arg2, CallType callType, Block block) {
/**
* Same behavior as finvoke, but uses the given caller object to check visibility if callType demands it.
*/
public IRubyObject invokeFrom(ThreadContext context, CallType callType, IRubyObject caller, IRubyObject self, String name,
IRubyObject arg, Block block) {
DynamicMethod method = searchMethod(name);
IRubyObject caller = context.getFrameSelf();
if (shouldCallMethodMissing(method, name, caller, callType)) {
return Helpers.callMethodMissing(context, self, method.getVisibility(), name, callType, arg0, arg1, arg2, block);
return Helpers.callMethodMissing(context, self, method.getVisibility(), name, callType, arg, block);
}
return method.call(context, self, this, name, arg0, arg1, arg2, block);
return method.call(context, self, this, name, arg, block);
}

public IRubyObject finvoke(ThreadContext context, IRubyObject self, String name,
IRubyObject arg0, IRubyObject arg1, IRubyObject arg2, Block block) {
/**
* Same behavior as finvoke, but uses the given caller object to check visibility if callType demands it.
*/
public IRubyObject invokeFrom(ThreadContext context, CallType callType, IRubyObject caller, IRubyObject self, String name,
IRubyObject arg0, IRubyObject arg1, Block block) {
DynamicMethod method = searchMethod(name);
if (shouldCallMethodMissing(method)) {
return Helpers.callMethodMissing(context, self, method.getVisibility(), name, CallType.FUNCTIONAL, arg0, arg1, arg2, block);
if (shouldCallMethodMissing(method, name, caller, callType)) {
return Helpers.callMethodMissing(context, self, method.getVisibility(), name, callType, arg0, arg1, block);
}
return method.call(context, self, this, name, arg0, arg1, block);
}

/**
* Same behavior as finvoke, but uses the given caller object to check visibility if callType demands it.
*/
public IRubyObject invokeFrom(ThreadContext context, CallType callType, IRubyObject caller, IRubyObject self, String name,
IRubyObject arg0, IRubyObject arg1, IRubyObject arg2, Block block) {
DynamicMethod method = searchMethod(name);
if (shouldCallMethodMissing(method, name, caller, callType)) {
return Helpers.callMethodMissing(context, self, method.getVisibility(), name, callType, arg0, arg1, arg2, block);
}
return method.call(context, self, this, name, arg0, arg1, arg2, block);
}

public IRubyObject invoke(ThreadContext context, IRubyObject self, String name,
CallType callType) {
/**
* Same behavior as finvoke, but uses the given caller object to check visibility if callType demands it.
*/
public IRubyObject invokeFrom(ThreadContext context, CallType callType, IRubyObject caller, IRubyObject self, String name) {
DynamicMethod method = searchMethod(name);
IRubyObject caller = context.getFrameSelf();
if (shouldCallMethodMissing(method, name, caller, callType)) {
return Helpers.callMethodMissing(context, self, method.getVisibility(), name, callType, Block.NULL_BLOCK);
}
return method.call(context, self, this, name);
}

public IRubyObject finvoke(ThreadContext context, IRubyObject self, String name) {
/**
* Same behavior as finvoke, but uses the given caller object to check visibility if callType demands it.
*/
public IRubyObject invokeFrom(ThreadContext context, CallType callType, IRubyObject caller, IRubyObject self, String name,
IRubyObject[] args) {
assert args != null;
DynamicMethod method = searchMethod(name);
if (shouldCallMethodMissing(method)) {
return Helpers.callMethodMissing(context, self, method.getVisibility(), name, CallType.FUNCTIONAL, Block.NULL_BLOCK);
if (shouldCallMethodMissing(method, name, caller, callType)) {
return Helpers.callMethodMissing(context, self, method.getVisibility(), name, callType, args, Block.NULL_BLOCK);
}
return method.call(context, self, this, name);
return method.call(context, self, this, name, args);
}

/**
* Same behavior as finvoke, but uses the given caller object to check visibility if callType demands it.
*/
public IRubyObject invokeFrom(ThreadContext context, CallType callType, IRubyObject caller, IRubyObject self, String name,
IRubyObject arg) {
DynamicMethod method = searchMethod(name);
if (shouldCallMethodMissing(method, name, caller, callType)) {
return Helpers.callMethodMissing(context, self, method.getVisibility(), name, callType, arg, Block.NULL_BLOCK);
}
return method.call(context, self, this, name, arg);
}

/**
* Same behavior as finvoke, but uses the given caller object to check visibility if callType demands it.
*/
public IRubyObject invokeFrom(ThreadContext context, CallType callType, IRubyObject caller, IRubyObject self, String name,
IRubyObject arg0, IRubyObject arg1) {
DynamicMethod method = searchMethod(name);
if (shouldCallMethodMissing(method, name, caller, callType)) {
return Helpers.callMethodMissing(context, self, method.getVisibility(), name, callType, arg0, arg1, Block.NULL_BLOCK);
}
return method.call(context, self, this, name, arg0, arg1);
}

/**
* Same behavior as finvoke, but uses the given caller object to check visibility if callType demands it.
*/
public IRubyObject invokeFrom(ThreadContext context, CallType callType, IRubyObject caller, IRubyObject self, String name,
IRubyObject arg0, IRubyObject arg1, IRubyObject arg2) {
DynamicMethod method = searchMethod(name);
if (shouldCallMethodMissing(method, name, caller, callType)) {
return Helpers.callMethodMissing(context, self, method.getVisibility(), name, callType, arg0, arg1, arg2, Block.NULL_BLOCK);
}
return method.call(context, self, this, name, arg0, arg1, arg2);
}

/**
@@ -834,17 +889,6 @@ private static IRubyObject checkFuncallMissing(ThreadContext context, RubyClass
}
}

public IRubyObject invoke(ThreadContext context, IRubyObject self, String name,
IRubyObject[] args, CallType callType) {
assert args != null;
DynamicMethod method = searchMethod(name);
IRubyObject caller = context.getFrameSelf();
if (shouldCallMethodMissing(method, name, caller, callType)) {
return Helpers.callMethodMissing(context, self, method.getVisibility(), name, callType, args, Block.NULL_BLOCK);
}
return method.call(context, self, this, name, args);
}

public IRubyObject finvoke(ThreadContext context, IRubyObject self, String name,
IRubyObject[] args) {
assert args != null;
@@ -855,16 +899,6 @@ public IRubyObject finvoke(ThreadContext context, IRubyObject self, String name,
return method.call(context, self, this, name, args);
}

public IRubyObject invoke(ThreadContext context, IRubyObject self, String name,
IRubyObject arg, CallType callType) {
DynamicMethod method = searchMethod(name);
IRubyObject caller = context.getFrameSelf();
if (shouldCallMethodMissing(method, name, caller, callType)) {
return Helpers.callMethodMissing(context, self, method.getVisibility(), name, callType, arg, Block.NULL_BLOCK);
}
return method.call(context, self, this, name, arg);
}

public IRubyObject finvoke(ThreadContext context, IRubyObject self, String name,
IRubyObject arg) {
DynamicMethod method = searchMethod(name);
@@ -874,16 +908,6 @@ public IRubyObject finvoke(ThreadContext context, IRubyObject self, String name,
return method.call(context, self, this, name, arg);
}

public IRubyObject invoke(ThreadContext context, IRubyObject self, String name,
IRubyObject arg0, IRubyObject arg1, CallType callType) {
DynamicMethod method = searchMethod(name);
IRubyObject caller = context.getFrameSelf();
if (shouldCallMethodMissing(method, name, caller, callType)) {
return Helpers.callMethodMissing(context, self, method.getVisibility(), name, callType, arg0, arg1, Block.NULL_BLOCK);
}
return method.call(context, self, this, name, arg0, arg1);
}

public IRubyObject finvoke(ThreadContext context, IRubyObject self, String name,
IRubyObject arg0, IRubyObject arg1) {
DynamicMethod method = searchMethod(name);
@@ -893,16 +917,6 @@ public IRubyObject finvoke(ThreadContext context, IRubyObject self, String name,
return method.call(context, self, this, name, arg0, arg1);
}

public IRubyObject invoke(ThreadContext context, IRubyObject self, String name,
IRubyObject arg0, IRubyObject arg1, IRubyObject arg2, CallType callType) {
DynamicMethod method = searchMethod(name);
IRubyObject caller = context.getFrameSelf();
if (shouldCallMethodMissing(method, name, caller, callType)) {
return Helpers.callMethodMissing(context, self, method.getVisibility(), name, callType, arg0, arg1, arg2, Block.NULL_BLOCK);
}
return method.call(context, self, this, name, arg0, arg1, arg2);
}

public IRubyObject finvoke(ThreadContext context, IRubyObject self, String name,
IRubyObject arg0, IRubyObject arg1, IRubyObject arg2) {
DynamicMethod method = searchMethod(name);
@@ -2111,6 +2125,197 @@ public IRubyObject smartLoadOldUser(IRubyObject data) {
}
}

// DEPRECATED METHODS

@Deprecated
public IRubyObject invoke(ThreadContext context, IRubyObject self, int methodIndex, String name, IRubyObject[] args, CallType callType, Block block) {
return invoke(context, self, name, args, callType, block);
}

/**
* This method is deprecated because it depends on having a Ruby frame pushed for checking method visibility,
* and there's no way to enforce that. Most users of this method probably don't need to check visibility.
*
* See https://github.com/jruby/jruby/issues/4134
*
* @deprecated Use finvoke if you do not want visibility-checking or invokeFrom if you do.
*/
public IRubyObject invoke(ThreadContext context, IRubyObject self, String name,
CallType callType, Block block) {
DynamicMethod method = searchMethod(name);
IRubyObject caller = context.getFrameSelf();
if (shouldCallMethodMissing(method, name, caller, callType)) {
return Helpers.callMethodMissing(context, self, method.getVisibility(), name, callType, block);
}
return method.call(context, self, this, name, block);
}

/**
* This method is deprecated because it depends on having a Ruby frame pushed for checking method visibility,
* and there's no way to enforce that. Most users of this method probably don't need to check visibility.
*
* See https://github.com/jruby/jruby/issues/4134
*
* @deprecated Use finvoke if you do not want visibility-checking or invokeFrom if you do.
*/
public IRubyObject invoke(ThreadContext context, IRubyObject self, String name,
IRubyObject[] args, CallType callType, Block block) {
assert args != null;
DynamicMethod method = searchMethod(name);
IRubyObject caller = context.getFrameSelf();
if (shouldCallMethodMissing(method, name, caller, callType)) {
return Helpers.callMethodMissing(context, self, method.getVisibility(), name, callType, args, block);
}
return method.call(context, self, this, name, args, block);
}

/**
* This method is deprecated because it depends on having a Ruby frame pushed for checking method visibility,
* and there's no way to enforce that. Most users of this method probably don't need to check visibility.
*
* See https://github.com/jruby/jruby/issues/4134
*
* @deprecated Use finvoke if you do not want visibility-checking or invokeFrom if you do.
*/
public IRubyObject invoke(ThreadContext context, IRubyObject self, String name,
IRubyObject arg, CallType callType, Block block) {
DynamicMethod method = searchMethod(name);
IRubyObject caller = context.getFrameSelf();
if (shouldCallMethodMissing(method, name, caller, callType)) {
return Helpers.callMethodMissing(context, self, method.getVisibility(), name, callType, arg, block);
}
return method.call(context, self, this, name, arg, block);
}

/**
* This method is deprecated because it depends on having a Ruby frame pushed for checking method visibility,
* and there's no way to enforce that. Most users of this method probably don't need to check visibility.
*
* See https://github.com/jruby/jruby/issues/4134
*
* @deprecated Use finvoke if you do not want visibility-checking or invokeFrom if you do.
*/
public IRubyObject invoke(ThreadContext context, IRubyObject self, String name,
IRubyObject arg0, IRubyObject arg1, CallType callType, Block block) {
DynamicMethod method = searchMethod(name);
IRubyObject caller = context.getFrameSelf();
if (shouldCallMethodMissing(method, name, caller, callType)) {
return Helpers.callMethodMissing(context, self, method.getVisibility(), name, callType, arg0, arg1, block);
}
return method.call(context, self, this, name, arg0, arg1, block);
}

/**
* This method is deprecated because it depends on having a Ruby frame pushed for checking method visibility,
* and there's no way to enforce that. Most users of this method probably don't need to check visibility.
*
* See https://github.com/jruby/jruby/issues/4134
*
* @deprecated Use finvoke if you do not want visibility-checking or invokeFrom if you do.
*/
public IRubyObject invoke(ThreadContext context, IRubyObject self, String name,
IRubyObject arg0, IRubyObject arg1, IRubyObject arg2, CallType callType, Block block) {
DynamicMethod method = searchMethod(name);
IRubyObject caller = context.getFrameSelf();
if (shouldCallMethodMissing(method, name, caller, callType)) {
return Helpers.callMethodMissing(context, self, method.getVisibility(), name, callType, arg0, arg1, arg2, block);
}
return method.call(context, self, this, name, arg0, arg1, arg2, block);
}

/**
* This method is deprecated because it depends on having a Ruby frame pushed for checking method visibility,
* and there's no way to enforce that. Most users of this method probably don't need to check visibility.
*
* See https://github.com/jruby/jruby/issues/4134
*
* @deprecated Use finvoke if you do not want visibility-checking or invokeFrom if you do.
*/
public IRubyObject invoke(ThreadContext context, IRubyObject self, String name,
CallType callType) {
DynamicMethod method = searchMethod(name);
IRubyObject caller = context.getFrameSelf();
if (shouldCallMethodMissing(method, name, caller, callType)) {
return Helpers.callMethodMissing(context, self, method.getVisibility(), name, callType, Block.NULL_BLOCK);
}
return method.call(context, self, this, name);
}

/**
* This method is deprecated because it depends on having a Ruby frame pushed for checking method visibility,
* and there's no way to enforce that. Most users of this method probably don't need to check visibility.
*
* See https://github.com/jruby/jruby/issues/4134
*
* @deprecated Use finvoke if you do not want visibility-checking or invokeFrom if you do.
*/
public IRubyObject invoke(ThreadContext context, IRubyObject self, String name,
IRubyObject[] args, CallType callType) {
assert args != null;
DynamicMethod method = searchMethod(name);
IRubyObject caller = context.getFrameSelf();
if (shouldCallMethodMissing(method, name, caller, callType)) {
return Helpers.callMethodMissing(context, self, method.getVisibility(), name, callType, args, Block.NULL_BLOCK);
}
return method.call(context, self, this, name, args);
}

/**
* This method is deprecated because it depends on having a Ruby frame pushed for checking method visibility,
* and there's no way to enforce that. Most users of this method probably don't need to check visibility.
*
* See https://github.com/jruby/jruby/issues/4134
*
* @deprecated Use finvoke if you do not want visibility-checking or invokeFrom if you do.
*/
public IRubyObject invoke(ThreadContext context, IRubyObject self, String name,
IRubyObject arg, CallType callType) {
DynamicMethod method = searchMethod(name);
IRubyObject caller = context.getFrameSelf();
if (shouldCallMethodMissing(method, name, caller, callType)) {
return Helpers.callMethodMissing(context, self, method.getVisibility(), name, callType, arg, Block.NULL_BLOCK);
}
return method.call(context, self, this, name, arg);
}

/**
* This method is deprecated because it depends on having a Ruby frame pushed for checking method visibility,
* and there's no way to enforce that. Most users of this method probably don't need to check visibility.
*
* See https://github.com/jruby/jruby/issues/4134
*
* @deprecated Use finvoke if you do not want visibility-checking or invokeFrom if you do.
*/
public IRubyObject invoke(ThreadContext context, IRubyObject self, String name,
IRubyObject arg0, IRubyObject arg1, CallType callType) {
DynamicMethod method = searchMethod(name);
IRubyObject caller = context.getFrameSelf();
if (shouldCallMethodMissing(method, name, caller, callType)) {
return Helpers.callMethodMissing(context, self, method.getVisibility(), name, callType, arg0, arg1, Block.NULL_BLOCK);
}
return method.call(context, self, this, name, arg0, arg1);
}

/**
* This method is deprecated because it depends on having a Ruby frame pushed for checking method visibility,
* and there's no way to enforce that. Most users of this method probably don't need to check visibility.
*
* See https://github.com/jruby/jruby/issues/4134
*
* @deprecated Use finvoke if you do not want visibility-checking or invokeFrom if you do.
*/
public IRubyObject invoke(ThreadContext context, IRubyObject self, String name,
IRubyObject arg0, IRubyObject arg1, IRubyObject arg2, CallType callType) {
DynamicMethod method = searchMethod(name);
IRubyObject caller = context.getFrameSelf();
if (shouldCallMethodMissing(method, name, caller, callType)) {
return Helpers.callMethodMissing(context, self, method.getVisibility(), name, callType, arg0, arg1, arg2, Block.NULL_BLOCK);
}
return method.call(context, self, this, name, arg0, arg1, arg2);
}

// OBJECT STATE

protected final Ruby runtime;
private ObjectAllocator allocator; // the default allocator
protected ObjectMarshal marshal;
68 changes: 57 additions & 11 deletions core/src/main/java/org/jruby/runtime/Helpers.java
Original file line number Diff line number Diff line change
@@ -411,17 +411,6 @@ public static IRubyObject invoke(ThreadContext context, IRubyObject self, String
return self.getMetaClass().finvoke(context, self, name, args);
}

public static IRubyObject invoke(ThreadContext context, IRubyObject self, String name, CallType callType) {
return Helpers.invoke(context, self, name, IRubyObject.NULL_ARRAY, callType, Block.NULL_BLOCK);
}
public static IRubyObject invoke(ThreadContext context, IRubyObject self, String name, IRubyObject[] args, CallType callType, Block block) {
return self.getMetaClass().invoke(context, self, name, args, callType, block);
}

public static IRubyObject invoke(ThreadContext context, IRubyObject self, String name, IRubyObject arg, CallType callType, Block block) {
return self.getMetaClass().invoke(context, self, name, arg, callType, block);
}

public static IRubyObject invokeAs(ThreadContext context, RubyClass asClass, IRubyObject self, String name, IRubyObject[] args, Block block) {
return asClass.finvoke(context, self, name, args, block);
}
@@ -442,6 +431,27 @@ public static IRubyObject invokeAs(ThreadContext context, RubyClass asClass, IRu
return asClass.finvoke(context, self, name, arg0, arg1, arg2, block);
}

/**
* Same behavior as invoke, but uses the given caller object to check visibility if callType demands it.
*/
public static IRubyObject invokeFrom(ThreadContext context, IRubyObject caller, IRubyObject self, String name, IRubyObject[] args, CallType callType, Block block) {
return self.getMetaClass().invokeFrom(context, callType, caller, self, name, args, block);
}

/**
* Same behavior as invoke, but uses the given caller object to check visibility if callType demands it.
*/
public static IRubyObject invokeFrom(ThreadContext context, IRubyObject caller, IRubyObject self, String name, IRubyObject arg, CallType callType, Block block) {
return self.getMetaClass().invokeFrom(context, callType, caller, self, name, arg, block);
}

/**
* Same behavior as invoke, but uses the given caller object to check visibility if callType demands it.
*/
public static IRubyObject invokeFrom(ThreadContext context, IRubyObject caller, IRubyObject self, String name, CallType callType) {
return self.getMetaClass().invokeFrom(context, callType, caller, self, name, IRubyObject.NULL_ARRAY, Block.NULL_BLOCK);
}

// MRI: rb_check_funcall
public static IRubyObject invokeChecked(ThreadContext context, IRubyObject self, String name) {
return self.getMetaClass().finvokeChecked(context, self, name);
@@ -2791,4 +2801,40 @@ public static String encodeParameterList(List<String[]> args) {
return builder.toString();
}

/**
* This method is deprecated because it depends on having a Ruby frame pushed for checking method visibility,
* and there's no way to enforce that. Most users of this method probably don't need to check visibility.
*
* See https://github.com/jruby/jruby/issues/4134
*
* @deprecated Use finvoke if you do not want visibility-checking or invokeFrom if you do.
*/
public static IRubyObject invoke(ThreadContext context, IRubyObject self, String name, IRubyObject[] args, CallType callType, Block block) {
return self.getMetaClass().invoke(context, self, name, args, callType, block);
}

/**
* This method is deprecated because it depends on having a Ruby frame pushed for checking method visibility,
* and there's no way to enforce that. Most users of this method probably don't need to check visibility.
*
* See https://github.com/jruby/jruby/issues/4134
*
* @deprecated Use finvoke if you do not want visibility-checking or invokeFrom if you do.
*/
public static IRubyObject invoke(ThreadContext context, IRubyObject self, String name, IRubyObject arg, CallType callType, Block block) {
return self.getMetaClass().invoke(context, self, name, arg, callType, block);
}

/**
* This method is deprecated because it depends on having a Ruby frame pushed for checking method visibility,
* and there's no way to enforce that. Most users of this method probably don't need to check visibility.
*
* See https://github.com/jruby/jruby/issues/4134
*
* @deprecated Use finvoke if you do not want visibility-checking or invokeFrom if you do.
*/
public static IRubyObject invoke(ThreadContext context, IRubyObject self, String name, CallType callType) {
return Helpers.invoke(context, self, name, IRubyObject.NULL_ARRAY, callType, Block.NULL_BLOCK);
}

}