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

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

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

Ruby.getKernel介绍

暂无

代码示例

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

private void receivedAnException(ThreadContext context, IRubyObject exception) {
  RubyModule kernelModule = getRuntime().getKernel();
  debug(this, "before propagating exception");
  kernelModule.callMethod(context, "raise", exception);
}

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

private void receivedAnException(ThreadContext context, IRubyObject exception) {
  RubyModule kernelModule = getRuntime().getKernel();
  debug(this, "before propagating exception");
  kernelModule.callMethod(context, "raise", exception);
}

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

private static IRubyObject raiseBecauseCritical(ThreadContext context) {
  Ruby runtime = context.runtime;
  return RubyKernel.raise(context, runtime.getKernel(), new IRubyObject[]{runtime.getThreadError(), runtime.newString("timeout within critical section")}, Block.NULL_BLOCK);
}

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

private static IRubyObject raiseBecauseCritical(ThreadContext context) {
  Ruby runtime = context.runtime;
  return RubyKernel.raise(context, runtime.getKernel(), new IRubyObject[]{runtime.getThreadError(), runtime.newString("timeout within critical section")}, Block.NULL_BLOCK);
}

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

/**
 * Cache built-in versions of several core methods, to improve performance by using identity comparison (==) rather
 * than going ahead with dynamic dispatch.
 *
 * @param runtime
 */
static void recacheBuiltinMethods(Ruby runtime) {
  RubyModule module = runtime.getKernel();
  runtime.setRespondToMethod(module.searchMethod("respond_to?"));
  runtime.setRespondToMissingMethod(module.searchMethod("respond_to_missing?"));
}

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

/**
 * Cache built-in versions of several core methods, to improve performance by using identity comparison (==) rather
 * than going ahead with dynamic dispatch.
 *
 * @param runtime
 */
static void recacheBuiltinMethods(Ruby runtime) {
  RubyModule module = runtime.getKernel();
  runtime.setRespondToMethod(module.searchMethod("respond_to?"));
  runtime.setRespondToMissingMethod(module.searchMethod("respond_to_missing?"));
}

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

static RubyModule getModuleForAutoload(Ruby runtime, IRubyObject recv) {
  RubyModule module = recv instanceof RubyModule ? (RubyModule) recv : recv.getMetaClass().getRealClass();
  if (module == runtime.getKernel()) {
    // special behavior if calling Kernel.autoload directly
    module = runtime.getObject().getSingletonClass();
  }
  return module;
}

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

static RubyModule getModuleForAutoload(Ruby runtime, IRubyObject recv) {
  RubyModule module = recv instanceof RubyModule ? (RubyModule) recv : recv.getMetaClass().getRealClass();
  if (module == runtime.getKernel()) {
    // special behavior if calling Kernel.autoload directly
    module = runtime.getObject().getSingletonClass();
  }
  return module;
}

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

/**
 * Cache built-in versions of several core methods, to improve performance by using identity comparison (==) rather
 * than going ahead with dynamic dispatch.
 *
 * @param runtime
 */
static void recacheBuiltinMethods(Ruby runtime) {
  RubyModule module = runtime.getKernel();
  runtime.setRespondToMethod(module.searchMethod("respond_to?"));
  if (!runtime.is1_9()) { // method_missing is in BasicObject in 1.9
    runtime.setDefaultMethodMissing(module.searchMethod("method_missing"));
  }
}

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

public static void define(final Ruby runtime) {
  runtime.getKernel().defineAnnotatedMethods(Kernel.class);
  final RubyModule Kernel = runtime.getKernel();
  Kernel.addMethodInternal("java", new JavaPackageMethod(Kernel, "java"));
  Kernel.addMethodInternal("javax", new JavaPackageMethod(Kernel, "javax"));
  Kernel.addMethodInternal("javafx", new JavaPackageMethod(Kernel, "javafx"));
  Kernel.addMethodInternal("com", new JavaPackageMethod(Kernel, "com"));
  Kernel.addMethodInternal("org", new JavaPackageMethod(Kernel, "org"));
}

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

public static void define(final Ruby runtime) {
  runtime.getKernel().defineAnnotatedMethods(Kernel.class);
  final RubyModule Kernel = runtime.getKernel();
  Kernel.addMethodInternal("java", new JavaPackageMethod(Kernel, "java"));
  Kernel.addMethodInternal("javax", new JavaPackageMethod(Kernel, "javax"));
  Kernel.addMethodInternal("javafx", new JavaPackageMethod(Kernel, "javafx"));
  Kernel.addMethodInternal("com", new JavaPackageMethod(Kernel, "com"));
  Kernel.addMethodInternal("org", new JavaPackageMethod(Kernel, "org"));
}

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

private static RubyModule getModuleForAutoload(Ruby runtime, IRubyObject recv) {
  RubyModule module = recv instanceof RubyModule ? (RubyModule) recv : recv.getMetaClass().getRealClass();
  if (module == runtime.getKernel()) {
    // special behavior if calling Kernel.autoload directly
    if (runtime.is1_9()) {
      module = runtime.getObject().getSingletonClass();
    } else {
      module = runtime.getObject();
    }
  }
  return module;
}

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

private static IRubyObject raiseTimeoutError(ThreadContext context, RaiseException re) {
    Ruby runtime = context.runtime;

    return RubyKernel.raise(
        context,
        runtime.getKernel(),
        new IRubyObject[]{
          runtime.getClassFromPath("Timeout::Error"),
          re.getException().callMethod(context, "message"),
          re.getException().callMethod(context, "backtrace")},
        Block.NULL_BLOCK);
  }
}

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

private static RubyModule getModuleForAutoload(Ruby runtime, IRubyObject recv) {
  RubyModule module = recv instanceof RubyModule ? (RubyModule) recv : recv.getMetaClass().getRealClass();
  if (module == runtime.getKernel()) {
    // special behavior if calling Kernel.autoload directly
    if (runtime.is1_9()) {
      module = runtime.getObject().getSingletonClass();
    } else {
      module = runtime.getObject();
    }
  }
  return module;
}

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

private static IRubyObject raiseTimeoutError(ThreadContext context, RaiseException re) {
    Ruby runtime = context.runtime;

    return RubyKernel.raise(
        context,
        runtime.getKernel(),
        new IRubyObject[]{
          runtime.getClassFromPath("Timeout::Error"),
          re.getException().callMethod(context, "message"),
          re.getException().callMethod(context, "backtrace")},
        Block.NULL_BLOCK);
  }
}

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

public IRubyObject genericRaise(Ruby runtime, IRubyObject[] args, RubyThread currentThread) {
  if (!isAlive()) return runtime.getNil();
  if (currentThread == this) {
    RubyKernel.raise(runtime.getCurrentContext(), runtime.getKernel(), args, Block.NULL_BLOCK);
    // should not reach here
  }
  IRubyObject exception = prepareRaiseException(runtime, args, Block.NULL_BLOCK);
  pendingInterruptEnqueue(exception);
  interrupt();
  return runtime.getNil();
}

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

public IRubyObject genericRaise(Ruby runtime, IRubyObject[] args, RubyThread currentThread) {
  if (!isAlive()) return runtime.getNil();
  if (currentThread == this) {
    RubyKernel.raise(runtime.getCurrentContext(), runtime.getKernel(), args, Block.NULL_BLOCK);
    // should not reach here
  }
  IRubyObject exception = prepareRaiseException(runtime, args, Block.NULL_BLOCK);
  pendingInterruptEnqueue(exception);
  interrupt();
  return runtime.getNil();
}

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

public void load(Ruby runtime, boolean wrap) throws IOException {
    RubyKernel.require(runtime.getKernel(), runtime.newString("delegate"), Block.NULL_BLOCK);
    RubyClass delegatorClass = (RubyClass) runtime.getClassFromPath("Delegator");
    RubyClass weakrefClass = runtime.defineClass("WeakRef", delegatorClass, WeakRef.WEAKREF_ALLOCATOR);
    weakrefClass.defineAnnotatedMethods(WeakRef.class);
    weakrefClass.defineClassUnder("RefError", runtime.getStandardError(), runtime.getStandardError().getAllocator());
  }
}

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

public void load(Ruby runtime, boolean wrap) throws IOException {
    RubyKernel.require(runtime.getKernel(), runtime.newString("delegate"), Block.NULL_BLOCK);
    RubyClass delegatorClass = (RubyClass) runtime.getClassFromPath("Delegator");
    RubyClass weakrefClass = runtime.defineClass("WeakRef", delegatorClass, WeakRef.WEAKREF_ALLOCATOR);
    weakrefClass.defineAnnotatedMethods(WeakRef.class);
    weakrefClass.defineClassUnder("RefError", runtime.getStandardError(), runtime.getStandardError().getAllocator());
  }
}

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

static RubyModule createJavaPackageClass(final Ruby runtime, final RubyModule Java) {
  RubyClass superClass = new BlankSlateWrapper(runtime, runtime.getModule(), runtime.getKernel());
  RubyClass JavaPackage = RubyClass.newClass(runtime, superClass);
  JavaPackage.setMetaClass(runtime.getModule());
  JavaPackage.setAllocator(ObjectAllocator.NOT_ALLOCATABLE_ALLOCATOR);
  ((MetaClass) JavaPackage.makeMetaClass(superClass)).setAttached(JavaPackage);
  JavaPackage.setBaseName("JavaPackage");
  JavaPackage.setParent(Java);
  Java.setConstant("JavaPackage", JavaPackage); // Java::JavaPackage
  // JavaPackage.setReifiedClass(JavaPackage.class);
  JavaPackage.defineAnnotatedMethods(JavaPackage.class);
  return JavaPackage;
}

相关文章

Ruby类方法