org.jruby.Ruby.getNoMethodError()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(11.4k)|赞(0)|评价(0)|浏览(99)

本文整理了Java中org.jruby.Ruby.getNoMethodError方法的一些代码示例,展示了Ruby.getNoMethodError的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Ruby.getNoMethodError方法的具体详情如下:
包路径:org.jruby.Ruby
类名称:Ruby
方法名:getNoMethodError

Ruby.getNoMethodError介绍

暂无

代码示例

代码示例来源:origin: org.jruby/jruby-core

/**
 * Construct a NoMethodError with a pre-formatted message.
 *
 * @param message the pre-formatted message
 * @param name the name that failed
 * @param args the original arguments to the call that failed
 * @return a new NoMethodError
 */
public RaiseException newNoMethodError(String message, String name, IRubyObject args) {
  return new RubyNoMethodError(this, getNoMethodError(), message, name, args).toThrowable();
}

代码示例来源:origin: org.jruby/jruby-complete

/**
 * Construct a NoMethodError with a pre-formatted message.
 *
 * @param message the pre-formatted message
 * @param name the name that failed
 * @param args the original arguments to the call that failed
 * @return a new NoMethodError
 */
public RaiseException newNoMethodError(String message, String name, IRubyObject args) {
  return new RubyNoMethodError(this, getNoMethodError(), message, name, args).toThrowable();
}

代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby

public RaiseException newNoMethodError(String message, String name, IRubyObject args) {
  return new RaiseException(new RubyNoMethodError(this, getNoMethodError(), message, name, args), true);
}

代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby

public RaiseException newNoMethodError(String message, String name, IRubyObject args) {
  return new RaiseException(new RubyNoMethodError(this, getNoMethodError(), message, name, args), true);
}

代码示例来源:origin: org.jruby/jruby-complete

/**
 * Construct a NoMethodError that formats its message with an sprintf format string.
 *
 * This works like {@link #newNameError(String, IRubyObject, IRubyObject)} but accepts
 * a java.lang.String for name and a RubyArray of the original call arguments.
 *
 * @see Ruby#newNameError(String, IRubyObject, IRubyObject)
 *
 * @return a new NoMethodError
 */
public RaiseException newNoMethodError(String message, IRubyObject recv, String name, RubyArray args, boolean privateCall) {
  RubySymbol nameStr = newSymbol(name);
  IRubyObject msg = new RubyNameError.RubyNameErrorMessage(this, message, recv, nameStr);
  RubyException err = RubyNoMethodError.newNoMethodError(getNoMethodError(), msg, nameStr, args, privateCall);
  return err.toThrowable();
}

代码示例来源:origin: org.jruby/jruby-core

/**
 * Construct a NoMethodError that formats its message with an sprintf format string.
 *
 * This works like {@link #newNameError(String, IRubyObject, IRubyObject)} but accepts
 * a java.lang.String for name and a RubyArray of the original call arguments.
 *
 * @see Ruby#newNameError(String, IRubyObject, IRubyObject)
 *
 * @return a new NoMethodError
 */
public RaiseException newNoMethodError(String message, IRubyObject recv, String name, RubyArray args, boolean privateCall) {
  RubySymbol nameStr = newSymbol(name);
  IRubyObject msg = new RubyNameError.RubyNameErrorMessage(this, message, recv, nameStr);
  RubyException err = RubyNoMethodError.newNoMethodError(getNoMethodError(), msg, nameStr, args, privateCall);
  return err.toThrowable();
}

代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby

protected static IRubyObject methodMissingDirect(ThreadContext context, IRubyObject recv, RubySymbol symbol, Visibility lastVis, CallType lastCallType, IRubyObject[] args, Block block) {
  Ruby runtime = context.runtime;
  
  // create a lightweight thunk
  IRubyObject msg = new RubyNameError.RubyNameErrorMessage(runtime,
                               recv,
                               symbol,
                               lastVis,
                               lastCallType);
  final IRubyObject[]exArgs;
  final RubyClass exc;
  if (lastCallType != CallType.VARIABLE) {
    exc = runtime.getNoMethodError();
    exArgs = new IRubyObject[]{msg, symbol, RubyArray.newArrayNoCopy(runtime, args, 1)};
  } else {
    exc = runtime.getNameError();
    exArgs = new IRubyObject[]{msg, symbol};
  }
  throw new RaiseException((RubyException)exc.newInstance(context, exArgs, Block.NULL_BLOCK));
}

代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby

protected static IRubyObject methodMissingDirect(ThreadContext context, IRubyObject recv, RubySymbol symbol, Visibility lastVis, CallType lastCallType, IRubyObject[] args, Block block) {
  Ruby runtime = context.runtime;
  
  // create a lightweight thunk
  IRubyObject msg = new RubyNameError.RubyNameErrorMessage(runtime,
                               recv,
                               symbol,
                               lastVis,
                               lastCallType);
  final IRubyObject[]exArgs;
  final RubyClass exc;
  if (lastCallType != CallType.VARIABLE) {
    exc = runtime.getNoMethodError();
    exArgs = new IRubyObject[]{msg, symbol, RubyArray.newArrayNoCopy(runtime, args, 1)};
  } else {
    exc = runtime.getNameError();
    exArgs = new IRubyObject[]{msg, symbol};
  }
  throw new RaiseException((RubyException)exc.newInstance(context, exArgs, Block.NULL_BLOCK));
}

代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby

public static IRubyObject methodMissing(ThreadContext context, IRubyObject recv, String name, Visibility lastVis, CallType lastCallType, IRubyObject[] args, Block block) {
  Ruby runtime = context.runtime;
  RubySymbol symbol = runtime.newSymbol(name);
  // create a lightweight thunk
  IRubyObject msg = new RubyNameError.RubyNameErrorMessage(runtime,
                               recv,
                               symbol,
                               lastVis,
                               lastCallType);
  final IRubyObject[]exArgs;
  final RubyClass exc;
  if (lastCallType != CallType.VARIABLE) {
    exc = runtime.getNoMethodError();
    exArgs = new IRubyObject[]{msg, symbol, RubyArray.newArrayNoCopy(runtime, args)};
  } else {
    exc = runtime.getNameError();
    exArgs = new IRubyObject[]{msg, symbol};
  }
  throw new RaiseException((RubyException)exc.newInstance(context, exArgs, Block.NULL_BLOCK));
}

代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby

public static IRubyObject methodMissing(ThreadContext context, IRubyObject recv, String name, Visibility lastVis, CallType lastCallType, IRubyObject[] args, Block block) {
  Ruby runtime = context.runtime;
  RubySymbol symbol = runtime.newSymbol(name);
  // create a lightweight thunk
  IRubyObject msg = new RubyNameError.RubyNameErrorMessage(runtime,
                               recv,
                               symbol,
                               lastVis,
                               lastCallType);
  final IRubyObject[]exArgs;
  final RubyClass exc;
  if (lastCallType != CallType.VARIABLE) {
    exc = runtime.getNoMethodError();
    exArgs = new IRubyObject[]{msg, symbol, RubyArray.newArrayNoCopy(runtime, args)};
  } else {
    exc = runtime.getNameError();
    exArgs = new IRubyObject[]{msg, symbol};
  }
  throw new RaiseException((RubyException)exc.newInstance(context, exArgs, Block.NULL_BLOCK));
}

代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby

public IRubyObject finvokeChecked(ThreadContext context, IRubyObject self, String name) {
  DynamicMethod method = searchMethod(name);
  if(method.isUndefined()) {
    DynamicMethod methodMissing = searchMethod("method_missing");
    if(methodMissing.isUndefined() || methodMissing.equals(context.runtime.getDefaultMethodMissing())) {
      return null;
    }
    try {
      return Helpers.callMethodMissing(context, self, method.getVisibility(), name, CallType.FUNCTIONAL, Block.NULL_BLOCK);
    } catch(RaiseException e) {
      if(context.runtime.getNoMethodError().isInstance(e.getException())) {
        if(self.respondsTo(name)) {
          throw e;
        } else {
          // we swallow, so we also must clear $!
          context.setErrorInfo(context.nil);
          return null;
        }
      } else {
        throw e;
      }
    }
  }
  return method.call(context, self, this, name);
}

代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby

public IRubyObject finvokeChecked(ThreadContext context, IRubyObject self, String name) {
  DynamicMethod method = searchMethod(name);
  if(method.isUndefined()) {
    DynamicMethod methodMissing = searchMethod("method_missing");
    if(methodMissing.isUndefined() || methodMissing.equals(context.runtime.getDefaultMethodMissing())) {
      return null;
    }
    try {
      return Helpers.callMethodMissing(context, self, method.getVisibility(), name, CallType.FUNCTIONAL, Block.NULL_BLOCK);
    } catch(RaiseException e) {
      if(context.runtime.getNoMethodError().isInstance(e.getException())) {
        if(self.respondsTo(name)) {
          throw e;
        } else {
          // we swallow, so we also must clear $!
          context.setErrorInfo(context.nil);
          return null;
        }
      } else {
        throw e;
      }
    }
  }
  return method.call(context, self, this, name);
}

代码示例来源:origin: org.jruby/jruby-complete

private static IRubyObject checkFuncallMissing(ThreadContext context, RubyClass klass, IRubyObject self, String method, IRubyObject... args) {
  final Ruby runtime = context.runtime;
  DynamicMethod me = klass.searchMethod("respond_to_missing?");
  // MRI: basic_obj_respond_to_missing ...
  if ( me != null && ! me.isUndefined() && ! me.isBuiltin() ) {
    IRubyObject ret;
    if (me.getArity().getValue() == 1) {
      ret = me.call(context, self, klass, "respond_to_missing?", runtime.newSymbol(method));
    } else {
      ret = me.call(context, self, klass, "respond_to_missing?", runtime.newSymbol(method), runtime.getTrue());
    }
    if ( ! ret.isTrue() ) return null;
  }
  if ( klass.isMethodBuiltin("method_missing") ) return null;
  final IRubyObject $ex = context.getErrorInfo();
  try {
    return checkFuncallExec(context, self, method, args);
  }
  catch (RaiseException e) {
    context.setErrorInfo($ex); // restore $!
    return checkFuncallFailed(context, self, method, runtime.getNoMethodError(), args);
  }
}

代码示例来源:origin: org.jruby/jruby-core

private static IRubyObject checkFuncallMissing(ThreadContext context, RubyClass klass, IRubyObject self, String method, IRubyObject... args) {
  final Ruby runtime = context.runtime;
  DynamicMethod me = klass.searchMethod("respond_to_missing?");
  // MRI: basic_obj_respond_to_missing ...
  if ( me != null && ! me.isUndefined() && ! me.isBuiltin() ) {
    IRubyObject ret;
    if (me.getArity().getValue() == 1) {
      ret = me.call(context, self, klass, "respond_to_missing?", runtime.newSymbol(method));
    } else {
      ret = me.call(context, self, klass, "respond_to_missing?", runtime.newSymbol(method), runtime.getTrue());
    }
    if ( ! ret.isTrue() ) return null;
  }
  if ( klass.isMethodBuiltin("method_missing") ) return null;
  final IRubyObject $ex = context.getErrorInfo();
  try {
    return checkFuncallExec(context, self, method, args);
  }
  catch (RaiseException e) {
    context.setErrorInfo($ex); // restore $!
    return checkFuncallFailed(context, self, method, runtime.getNoMethodError(), args);
  }
}

代码示例来源:origin: org.jruby/jruby-complete

private static IRubyObject checkFuncallMissing(ThreadContext context, RubyClass klass, IRubyObject self, String method, CachingCallSite respondToMissingSite, CachingCallSite methodMissingSite, IRubyObject... args) {
  final Ruby runtime = context.runtime;
  DynamicMethod me = respondToMissingSite.retrieveCache(klass).method;
  // MRI: basic_obj_respond_to_missing ...
  if ( me != null && ! me.isUndefined() && ! me.isBuiltin() ) {
    IRubyObject ret;
    if (me.getArity().getValue() == 1) {
      ret = me.call(context, self, klass, "respond_to_missing?", runtime.newSymbol(method));
    } else {
      ret = me.call(context, self, klass, "respond_to_missing?", runtime.newSymbol(method), runtime.getTrue());
    }
    if ( ! ret.isTrue() ) return null;
  }
  if (methodMissingSite.retrieveCache(klass).method.isBuiltin()) return null;
  final IRubyObject $ex = context.getErrorInfo();
  try {
    return checkFuncallExec(context, self, method, methodMissingSite, args);
  }
  catch (RaiseException e) {
    context.setErrorInfo($ex); // restore $!
    return checkFuncallFailed(context, self, method, runtime.getNoMethodError(), args);
  }
}

代码示例来源:origin: org.jruby/jruby-core

private static IRubyObject checkFuncallMissing(ThreadContext context, RubyClass klass, IRubyObject self, String method, CachingCallSite respondToMissingSite, CachingCallSite methodMissingSite, IRubyObject... args) {
  final Ruby runtime = context.runtime;
  DynamicMethod me = respondToMissingSite.retrieveCache(klass).method;
  // MRI: basic_obj_respond_to_missing ...
  if ( me != null && ! me.isUndefined() && ! me.isBuiltin() ) {
    IRubyObject ret;
    if (me.getArity().getValue() == 1) {
      ret = me.call(context, self, klass, "respond_to_missing?", runtime.newSymbol(method));
    } else {
      ret = me.call(context, self, klass, "respond_to_missing?", runtime.newSymbol(method), runtime.getTrue());
    }
    if ( ! ret.isTrue() ) return null;
  }
  if (methodMissingSite.retrieveCache(klass).method.isBuiltin()) return null;
  final IRubyObject $ex = context.getErrorInfo();
  try {
    return checkFuncallExec(context, self, method, methodMissingSite, args);
  }
  catch (RaiseException e) {
    context.setErrorInfo($ex); // restore $!
    return checkFuncallFailed(context, self, method, runtime.getNoMethodError(), args);
  }
}

相关文章

微信公众号

最新文章

更多

Ruby类方法