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

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

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

Ruby.isObjectSpaceEnabled介绍

暂无

代码示例

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

/** used by MODULE_ALLOCATOR and RubyClass constructors
 *
 */
protected RubyModule(Ruby runtime, RubyClass metaClass) {
  this(runtime, metaClass, runtime.isObjectSpaceEnabled());
}

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

/** used by MODULE_ALLOCATOR and RubyClass constructors
 *
 */
protected RubyModule(Ruby runtime, RubyClass metaClass) {
  this(runtime, metaClass, runtime.isObjectSpaceEnabled());
}

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

/** used by MODULE_ALLOCATOR and RubyClass constructors
 * 
 */
protected RubyModule(Ruby runtime, RubyClass metaClass) {
  this(runtime, metaClass, runtime.isObjectSpaceEnabled());
}

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

/** used by MODULE_ALLOCATOR and RubyClass constructors
 * 
 */
protected RubyModule(Ruby runtime, RubyClass metaClass) {
  this(runtime, metaClass, runtime.isObjectSpaceEnabled());
}

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

@JRubyMethod(name = { "objectspace", "object_space?" }, alias = { "objectspace?" }, module = true)
public static IRubyObject getObjectSpaceEnabled(IRubyObject recv) {
  final Ruby runtime = recv.getRuntime();
  return RubyBoolean.newBoolean(runtime, runtime.isObjectSpaceEnabled());
}

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

@JRubyMethod(name = { "objectspace", "object_space?" }, alias = { "objectspace?" }, module = true)
public static IRubyObject getObjectSpaceEnabled(IRubyObject recv) {
  final Ruby runtime = recv.getRuntime();
  return RubyBoolean.newBoolean(runtime, runtime.isObjectSpaceEnabled());
}

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

@JRubyMethod(name = "objectspace", module = true)
public static IRubyObject getObjectSpaceEnabled(IRubyObject recv) {
  Ruby runtime = recv.getRuntime();
  return RubyBoolean.newBoolean(runtime, runtime.isObjectSpaceEnabled());
}

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

@JRubyMethod(name = "objectspace", module = true)
public static IRubyObject getObjectSpaceEnabled(IRubyObject recv) {
  Ruby runtime = recv.getRuntime();
  return RubyBoolean.newBoolean(runtime, runtime.isObjectSpaceEnabled());
}

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

/** rb_ary_to_a
 *
 */
@JRubyMethod(name = "to_a")
@Override
public RubyArray to_a() {
  if(getMetaClass() != getRuntime().getArray()) {
    RubyArray dup = new RubyArray(getRuntime(), getRuntime().isObjectSpaceEnabled());
    isShared = true;
    dup.isShared = true;
    dup.values = values;
    dup.realLength = realLength; 
    dup.begin = begin;
    
    return dup;
  }        
  return this;
}

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

/**
 * We lazily stand up the object ID since it forces us to stand up
 * per-object state for a given object. We also check for ObjectSpace here,
 * and normally we do not register a given object ID into ObjectSpace due
 * to the high cost associated with constructing the related weakref. Most
 * uses of id/object_id will only ever need it to be a unique identifier,
 * and the id2ref behavior provided by ObjectSpace is considered internal
 * and not generally supported.
 * 
 * @param objectIdAccessor The variable accessor to use for storing the
 * generated object ID
 * @return The generated object ID
 */
protected synchronized long initObjectId(RubyBasicObject self, VariableAccessor objectIdAccessor) {
  Ruby runtime = self.getRuntime();
  long id;
  
  if (runtime.isObjectSpaceEnabled()) {
    id = runtime.getObjectSpace().createAndRegisterObjectId(self);
  } else {
    id = ObjectSpace.calculateObjectId(self);
  }
  
  // we use a direct path here to avoid frozen checks
  setObjectId(realClass, self, objectIdAccessor.getIndex(), id);
  return id;
}

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

/** rb_ary_to_a
 *
 */
@JRubyMethod(name = "to_a")
@Override
public RubyArray to_a() {
  if(getMetaClass() != getRuntime().getArray()) {
    RubyArray dup = new RubyArray(getRuntime(), getRuntime().isObjectSpaceEnabled());
    isShared = true;
    dup.isShared = true;
    dup.values = values;
    dup.realLength = realLength; 
    dup.begin = begin;
    
    return dup;
  }        
  return this;
}

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

long id;
if (runtime.isObjectSpaceEnabled()) {
  id = runtime.getObjectSpace().createAndRegisterObjectId(self);
} else {

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

long id;
if (runtime.isObjectSpaceEnabled()) {
  id = runtime.getObjectSpace().createAndRegisterObjectId(self);
} else {

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

long id;
if (runtime.isObjectSpaceEnabled()) {
  id = runtime.getObjectSpace().createAndRegisterObjectId(self);
} else {

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

if (!runtime.isObjectSpaceEnabled()) {
  throw runtime.newRuntimeError("ObjectSpace is disabled; each_object will only work with Class, pass -X+O to enable");

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

if (!runtime.isObjectSpaceEnabled()) {
  throw runtime.newRuntimeError("ObjectSpace is disabled; each_object will only work with Class, pass -X+O to enable");

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

@JRubyMethod(name = "_id2ref", required = 1, module = true, visibility = PRIVATE)
public static IRubyObject id2ref(IRubyObject recv, IRubyObject id) {
  final Ruby runtime = id.getRuntime();
  if (!(id instanceof RubyFixnum)) {
    throw runtime.newTypeError(id, runtime.getFixnum());
  }
  long longId = ((RubyFixnum) id).getLongValue();
  if (longId == 0) {
    return runtime.getFalse();
  } else if (longId == 20) {
    return runtime.getTrue();
  } else if (longId == 8) {
    return runtime.getNil();
  } else if (longId % 2 != 0) {
    // odd
    return runtime.newFixnum((longId - 1) / 2);
  } else {
    if (runtime.isObjectSpaceEnabled()) {
      IRubyObject object = runtime.getObjectSpace().id2ref(longId);
      if (object == null) {
        return runtime.getNil();
      }
      return object;
    } else {
      runtime.getWarnings().warn("ObjectSpace is disabled; _id2ref only supports immediates, pass -X+O to enable");
      throw runtime.newRangeError(String.format("0x%016x is not id value", longId));
    }
  }
}

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

@JRubyMethod(name = "_id2ref", required = 1, module = true, visibility = PRIVATE)
public static IRubyObject id2ref(IRubyObject recv, IRubyObject id) {
  final Ruby runtime = id.getRuntime();
  if (!(id instanceof RubyFixnum)) {
    throw runtime.newTypeError(id, runtime.getFixnum());
  }
  long longId = ((RubyFixnum) id).getLongValue();
  if (longId == 0) {
    return runtime.getFalse();
  } else if (longId == 20) {
    return runtime.getTrue();
  } else if (longId == 8) {
    return runtime.getNil();
  } else if (longId % 2 != 0) {
    // odd
    return runtime.newFixnum((longId - 1) / 2);
  } else {
    if (runtime.isObjectSpaceEnabled()) {
      IRubyObject object = runtime.getObjectSpace().id2ref(longId);
      if (object == null) {
        return runtime.getNil();
      }
      return object;
    } else {
      runtime.getWarnings().warn("ObjectSpace is disabled; _id2ref only supports immediates, pass -X+O to enable");
      throw runtime.newRangeError(String.format("0x%016x is not id value", longId));
    }
  }
}

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

if (runtime.isObjectSpaceEnabled()) {
  IRubyObject object = runtime.getObjectSpace().id2ref(longId);
  if (object == null) {

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

if (runtime.isObjectSpaceEnabled()) {
  IRubyObject object = runtime.getObjectSpace().id2ref(longId);
  if (object == null) {

相关文章

Ruby类方法