本文整理了Java中org.jruby.Ruby.newRuntimeError
方法的一些代码示例,展示了Ruby.newRuntimeError
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Ruby.newRuntimeError
方法的具体详情如下:
包路径:org.jruby.Ruby
类名称:Ruby
方法名:newRuntimeError
暂无
代码示例来源:origin: bazelbuild/bazel
protected DynamicMessage build(ThreadContext context, int depth) {
if (depth > SINK_MAXIMUM_NESTING) {
throw context.runtime.newRuntimeError("Maximum recursion depth exceeded during encoding.");
}
for (Descriptors.FieldDescriptor fieldDescriptor : maps.keySet()) {
this.builder.clearField(fieldDescriptor);
RubyDescriptor mapDescriptor = (RubyDescriptor) getDescriptorForField(context, fieldDescriptor);
for (DynamicMessage kv : maps.get(fieldDescriptor).build(context, mapDescriptor)) {
this.builder.addRepeatedField(fieldDescriptor, kv);
}
}
for (Descriptors.FieldDescriptor fieldDescriptor : repeatedFields.keySet()) {
RubyRepeatedField repeatedField = repeatedFields.get(fieldDescriptor);
this.builder.clearField(fieldDescriptor);
for (int i = 0; i < repeatedField.size(); i++) {
Object item = convert(context, fieldDescriptor, repeatedField.get(i), depth);
this.builder.addRepeatedField(fieldDescriptor, item);
}
}
for (Descriptors.FieldDescriptor fieldDescriptor : fields.keySet()) {
IRubyObject value = fields.get(fieldDescriptor);
this.builder.setField(fieldDescriptor, convert(context, fieldDescriptor, value, depth));
}
return this.builder.build();
}
代码示例来源:origin: bazelbuild/bazel
@JRubyMethod(meta = true)
public static IRubyObject decode(ThreadContext context, IRubyObject recv, IRubyObject data) {
byte[] bin = data.convertToString().getBytes();
RubyMessage ret = (RubyMessage) ((RubyClass) recv).newInstance(context, Block.NULL_BLOCK);
try {
ret.builder.mergeFrom(bin);
} catch (InvalidProtocolBufferException e) {
throw context.runtime.newRuntimeError(e.getMessage());
}
return ret;
}
代码示例来源:origin: bazelbuild/bazel
throw runtime.newRuntimeError(e.getMessage());
代码示例来源:origin: org.jruby/jruby-complete
public boolean hasScanEvent() {
if (lex_p < tokp) {
throw parser.getRuntime().newRuntimeError("lex_p < tokp");
}
return lex_p > tokp;
}
代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby
public IRubyObject op_pow(ThreadContext context, long other) {
// FIXME this needs to do the right thing for 1.9 mode before we can use it
if (context.is19) throw context.runtime.newRuntimeError("bug: using direct op_pow(long) in 1.8 mode");
return powerFixnum(context, other);
}
代码示例来源:origin: org.jruby/jruby-complete
protected final void checkIterating() {
if (iteratorCount > 0) {
throw getRuntime().newRuntimeError("can't add a new key into hash during iteration");
}
}
代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby
private void emit(ThreadContext context, Event event) {
try {
if (emitter == null) throw context.runtime.newRuntimeError("uninitialized emitter");
emitter.emit(event);
} catch (IOException ioe) {
throw context.runtime.newIOErrorFromException(ioe);
} catch (EmitterException ee) {
throw context.runtime.newRuntimeError(ee.toString());
}
}
代码示例来源:origin: org.jruby/jruby-core
public void free() {
if (allocation.released) {
throw getRuntime().newRuntimeError("memory already freed");
}
allocation.free();
}
代码示例来源:origin: org.jruby/jruby-complete
public void free() {
if (allocation.released) {
throw getRuntime().newRuntimeError("memory already freed");
}
allocation.free();
}
代码示例来源:origin: org.jruby/jruby-complete
private static void generateFieldAccessors(ThreadContext context, final RubyClass klass, final Class<?> javaClass) {
for ( String name : getJavaFieldNames(klass) ) {
Field field;
try {
field = javaClass.getDeclaredField(name);
}
catch (NoSuchFieldException e) {
throw context.runtime.newRuntimeError("no field: '" + name + "' in reified class for " + klass.getName());
}
JavaProxy.installField(context, name, field, klass);
}
}
代码示例来源:origin: org.jruby/jruby-complete
public void free() {
if (allocation.isReleased()) {
throw getRuntime().newRuntimeError("memory already freed");
}
allocation.free();
sentinel = null;
}
代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby
public void free() {
if (allocation.isReleased()) {
throw getRuntime().newRuntimeError("memory already freed");
}
allocation.free();
sentinel = null;
}
代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby
@JRubyMethod(name = "autorelease=")
public final IRubyObject autorelease(ThreadContext context, IRubyObject autorelease) {
Reaper r = reaper;
if (r == null || r.released) {
throw context.runtime.newRuntimeError("pointer already freed");
}
r.autorelease(autorelease.isTrue());
return context.runtime.getNil();
}
代码示例来源:origin: org.jruby/jruby-complete
@JRubyMethod()
public IRubyObject block_length() {
if (blockLength == 0) {
throw getRuntime().newRuntimeError(
this.getMetaClass() + " doesn't implement block_length()");
}
return RubyFixnum.newFixnum(getRuntime(), blockLength);
}
代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby
private void initEmitter(ThreadContext context, IRubyObject _encoding) {
if (emitter != null) throw context.runtime.newRuntimeError("already initialized emitter");
Encoding encoding = PsychLibrary.YAMLEncoding.values()[(int)_encoding.convertToInteger().getLongValue()].encoding;
Charset charset = context.runtime.getEncodingService().charsetForEncoding(encoding);
emitter = new Emitter(new OutputStreamWriter(new IOOutputStream(io, encoding), charset), options);
}
代码示例来源:origin: org.jruby/jruby-complete
@JRubyMethod(module = true)
public static IRubyObject peek_result(ThreadContext context, IRubyObject self) {
Ruby runtime = context.runtime;
if (!runtime.getCoverageData().isCoverageEnabled()) {
throw runtime.newRuntimeError("coverage measurement is not enabled");
}
return convertCoverageToRuby(context, runtime, runtime.getCoverageData().getCoverage());
}
代码示例来源:origin: org.jruby/jruby-core
@JRubyMethod(name = "free")
public final IRubyObject free(ThreadContext context) {
if (getMemoryIO() instanceof AllocatedDirectMemoryIO) {
((AllocatedDirectMemoryIO) getMemoryIO()).free();
} else {
throw context.runtime.newRuntimeError("cannot free non-allocated function");
}
// Replace memory object with one that throws an exception on any access
setMemoryIO(new FreedMemoryIO(context.runtime));
return context.nil;
}
代码示例来源:origin: org.jruby/jruby-core
@JRubyMethod(module = true)
public static IRubyObject peek_result(ThreadContext context, IRubyObject self) {
Ruby runtime = context.runtime;
if (!runtime.getCoverageData().isCoverageEnabled()) {
throw runtime.newRuntimeError("coverage measurement is not enabled");
}
return convertCoverageToRuby(context, runtime, runtime.getCoverageData().getCoverage());
}
代码示例来源:origin: org.jruby/jruby-complete
public RubyIO(Ruby runtime, InputStream inputStream) {
super(runtime, runtime.getIO());
if (inputStream == null) {
throw runtime.newRuntimeError("Opening null stream");
}
openFile = MakeOpenFile();
openFile.setFD(new ChannelFD(readableChannel(inputStream), runtime.getPosix(), runtime.getFilenoUtil()));
openFile.setMode(OpenFile.READABLE);
}
代码示例来源:origin: org.jruby/jruby-complete
public RubyIO(Ruby runtime, OutputStream outputStream, boolean autoclose) {
super(runtime, runtime.getIO());
// We only want IO objects with valid streams (better to error now).
if (outputStream == null) {
throw runtime.newRuntimeError("Opening null stream");
}
openFile = MakeOpenFile();
openFile.setFD(new ChannelFD(writableChannel(outputStream), runtime.getPosix(), runtime.getFilenoUtil()));
openFile.setMode(OpenFile.WRITABLE | OpenFile.APPEND);
openFile.setAutoclose(autoclose);
}
内容来源于网络,如有侵权,请联系作者删除!