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

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

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

Ruby.incrementCallerCount介绍

[英]Increment the count of backtraces generated by code in this runtime.
[中]增加代码在此运行时生成的回溯计数。

代码示例

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

private RubyStackTraceElement[] getTraceSubset(int level, Integer length, StackTraceElement[] stacktrace) {
  runtime.incrementCallerCount();
  
  if (length != null && length == 0) return new RubyStackTraceElement[0];
  
  RubyStackTraceElement[] trace =
      TraceType.Gather.CALLER.getBacktraceData(this, stacktrace, false).getBacktrace(runtime);
  
  int traceLength = safeLength(level, length, trace);
  
  if (traceLength < 0) return null;
  
  trace = Arrays.copyOfRange(trace, level, level + traceLength);
  
  if (RubyInstanceConfig.LOG_CALLERS) TraceType.dumpCaller(trace);
  
  return trace;
}

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

private RubyStackTraceElement[] getTraceSubset(int level, Integer length, StackTraceElement[] stacktrace) {
  runtime.incrementCallerCount();
  
  if (length != null && length == 0) return new RubyStackTraceElement[0];
  
  RubyStackTraceElement[] trace =
      TraceType.Gather.CALLER.getBacktraceData(this, stacktrace, false).getBacktrace(runtime);
  
  int traceLength = safeLength(level, length, trace);
  
  if (traceLength < 0) return null;
  
  trace = Arrays.copyOfRange(trace, level, level + traceLength);
  
  if (RubyInstanceConfig.LOG_CALLERS) TraceType.dumpCaller(trace);
  
  return trace;
}

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

/**
 * Create an Array with backtrace information for Kernel#caller
 * @param runtime
 * @param level
 * @param length
 * @return an Array with the backtrace
 */
public IRubyObject createCallerBacktrace(int level, Integer length, StackTraceElement[] stacktrace) {
  runtime.incrementCallerCount();
  
  RubyStackTraceElement[] trace = getTraceSubset(level, length, stacktrace);
  
  if (trace == null) return nil;
  
  RubyArray newTrace = runtime.newArray(trace.length);
  for (int i = level; i - level < trace.length; i++) {
    addBackTraceElement(runtime, newTrace, trace[i - level]);
  }
  
  if (RubyInstanceConfig.LOG_CALLERS) TraceType.dumpCaller(newTrace);
  
  return newTrace;
}

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

/**
 * Create an Array with backtrace information for Kernel#caller
 * @param runtime
 * @param level
 * @param length
 * @return an Array with the backtrace
 */
public IRubyObject createCallerBacktrace(int level, Integer length, StackTraceElement[] stacktrace) {
  runtime.incrementCallerCount();
  
  RubyStackTraceElement[] trace = getTraceSubset(level, length, stacktrace);
  
  if (trace == null) return nil;
  
  RubyArray newTrace = runtime.newArray(trace.length);
  for (int i = level; i - level < trace.length; i++) {
    addBackTraceElement(runtime, newTrace, trace[i - level]);
  }
  
  if (RubyInstanceConfig.LOG_CALLERS) TraceType.dumpCaller(newTrace);
  
  return newTrace;
}

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

/**
 * Create an array containing Thread::Backtrace::Location objects for the
 * requested caller trace level and length.
 *
 * @param level the level at which the trace should start
 * @param length the length of the trace
 * @return an Array with the backtrace locations
 */
public IRubyObject createCallerLocations(int level, Integer length, StackTraceElement[] stacktrace) {
  runtime.incrementCallerCount();
  RubyStackTraceElement[] fullTrace = getFullTrace(length, stacktrace);
  int traceLength = safeLength(level, length, fullTrace);
  // MRI started returning [] instead of nil some time after 1.9 (#4891)
  if (traceLength < 0) return runtime.newEmptyArray();
  RubyArray backTrace = RubyThread.Location.newLocationArray(runtime, fullTrace, level, traceLength);
  if (RubyInstanceConfig.LOG_CALLERS) TraceType.logCaller(backTrace);
  return backTrace;
}

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

/**
 * Create an array containing Thread::Backtrace::Location objects for the
 * requested caller trace level and length.
 *
 * @param level the level at which the trace should start
 * @param length the length of the trace
 * @return an Array with the backtrace locations
 */
public IRubyObject createCallerLocations(int level, Integer length, StackTraceElement[] stacktrace) {
  runtime.incrementCallerCount();
  RubyStackTraceElement[] fullTrace = getFullTrace(length, stacktrace);
  int traceLength = safeLength(level, length, fullTrace);
  // MRI started returning [] instead of nil some time after 1.9 (#4891)
  if (traceLength < 0) return runtime.newEmptyArray();
  RubyArray backTrace = RubyThread.Location.newLocationArray(runtime, fullTrace, level, traceLength);
  if (RubyInstanceConfig.LOG_CALLERS) TraceType.logCaller(backTrace);
  return backTrace;
}

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

/**
 * Create an Array with backtrace information for Kernel#caller
 * @param level
 * @param length
 * @return an Array with the backtrace
 */
public IRubyObject createCallerBacktrace(int level, Integer length, StackTraceElement[] stacktrace) {
  runtime.incrementCallerCount();
  RubyStackTraceElement[] fullTrace = getFullTrace(length, stacktrace);
  int traceLength = safeLength(level, length, fullTrace);
  // MRI started returning [] instead of nil some time after 1.9 (#4891)
  if (traceLength < 0) return runtime.newEmptyArray();
  final IRubyObject[] traceArray = new IRubyObject[traceLength];
  for (int i = 0; i < traceLength; i++) {
    traceArray[i] = RubyStackTraceElement.to_s_mri(this, fullTrace[i + level]);
  }
  RubyArray backTrace = RubyArray.newArrayMayCopy(runtime, traceArray);
  if (RubyInstanceConfig.LOG_CALLERS) TraceType.logCaller(backTrace);
  return backTrace;
}

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

/**
 * Create an Array with backtrace information for Kernel#caller
 * @param level
 * @param length
 * @return an Array with the backtrace
 */
public IRubyObject createCallerBacktrace(int level, Integer length, StackTraceElement[] stacktrace) {
  runtime.incrementCallerCount();
  RubyStackTraceElement[] fullTrace = getFullTrace(length, stacktrace);
  int traceLength = safeLength(level, length, fullTrace);
  // MRI started returning [] instead of nil some time after 1.9 (#4891)
  if (traceLength < 0) return runtime.newEmptyArray();
  final IRubyObject[] traceArray = new IRubyObject[traceLength];
  for (int i = 0; i < traceLength; i++) {
    traceArray[i] = RubyStackTraceElement.to_s_mri(this, fullTrace[i + level]);
  }
  RubyArray backTrace = RubyArray.newArrayMayCopy(runtime, traceArray);
  if (RubyInstanceConfig.LOG_CALLERS) TraceType.logCaller(backTrace);
  return backTrace;
}

相关文章

Ruby类方法