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

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

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

Ruby.newRuntimeError介绍

暂无

代码示例

代码示例来源:origin: bazelbuild/bazel

  1. protected DynamicMessage build(ThreadContext context, int depth) {
  2. if (depth > SINK_MAXIMUM_NESTING) {
  3. throw context.runtime.newRuntimeError("Maximum recursion depth exceeded during encoding.");
  4. }
  5. for (Descriptors.FieldDescriptor fieldDescriptor : maps.keySet()) {
  6. this.builder.clearField(fieldDescriptor);
  7. RubyDescriptor mapDescriptor = (RubyDescriptor) getDescriptorForField(context, fieldDescriptor);
  8. for (DynamicMessage kv : maps.get(fieldDescriptor).build(context, mapDescriptor)) {
  9. this.builder.addRepeatedField(fieldDescriptor, kv);
  10. }
  11. }
  12. for (Descriptors.FieldDescriptor fieldDescriptor : repeatedFields.keySet()) {
  13. RubyRepeatedField repeatedField = repeatedFields.get(fieldDescriptor);
  14. this.builder.clearField(fieldDescriptor);
  15. for (int i = 0; i < repeatedField.size(); i++) {
  16. Object item = convert(context, fieldDescriptor, repeatedField.get(i), depth);
  17. this.builder.addRepeatedField(fieldDescriptor, item);
  18. }
  19. }
  20. for (Descriptors.FieldDescriptor fieldDescriptor : fields.keySet()) {
  21. IRubyObject value = fields.get(fieldDescriptor);
  22. this.builder.setField(fieldDescriptor, convert(context, fieldDescriptor, value, depth));
  23. }
  24. return this.builder.build();
  25. }

代码示例来源:origin: bazelbuild/bazel

  1. @JRubyMethod(meta = true)
  2. public static IRubyObject decode(ThreadContext context, IRubyObject recv, IRubyObject data) {
  3. byte[] bin = data.convertToString().getBytes();
  4. RubyMessage ret = (RubyMessage) ((RubyClass) recv).newInstance(context, Block.NULL_BLOCK);
  5. try {
  6. ret.builder.mergeFrom(bin);
  7. } catch (InvalidProtocolBufferException e) {
  8. throw context.runtime.newRuntimeError(e.getMessage());
  9. }
  10. return ret;
  11. }

代码示例来源:origin: bazelbuild/bazel

  1. throw runtime.newRuntimeError(e.getMessage());

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

  1. public boolean hasScanEvent() {
  2. if (lex_p < tokp) {
  3. throw parser.getRuntime().newRuntimeError("lex_p < tokp");
  4. }
  5. return lex_p > tokp;
  6. }

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

  1. public IRubyObject op_pow(ThreadContext context, long other) {
  2. // FIXME this needs to do the right thing for 1.9 mode before we can use it
  3. if (context.is19) throw context.runtime.newRuntimeError("bug: using direct op_pow(long) in 1.8 mode");
  4. return powerFixnum(context, other);
  5. }

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

  1. protected final void checkIterating() {
  2. if (iteratorCount > 0) {
  3. throw getRuntime().newRuntimeError("can't add a new key into hash during iteration");
  4. }
  5. }

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

  1. private void emit(ThreadContext context, Event event) {
  2. try {
  3. if (emitter == null) throw context.runtime.newRuntimeError("uninitialized emitter");
  4. emitter.emit(event);
  5. } catch (IOException ioe) {
  6. throw context.runtime.newIOErrorFromException(ioe);
  7. } catch (EmitterException ee) {
  8. throw context.runtime.newRuntimeError(ee.toString());
  9. }
  10. }

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

  1. public void free() {
  2. if (allocation.released) {
  3. throw getRuntime().newRuntimeError("memory already freed");
  4. }
  5. allocation.free();
  6. }

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

  1. public void free() {
  2. if (allocation.released) {
  3. throw getRuntime().newRuntimeError("memory already freed");
  4. }
  5. allocation.free();
  6. }

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

  1. private static void generateFieldAccessors(ThreadContext context, final RubyClass klass, final Class<?> javaClass) {
  2. for ( String name : getJavaFieldNames(klass) ) {
  3. Field field;
  4. try {
  5. field = javaClass.getDeclaredField(name);
  6. }
  7. catch (NoSuchFieldException e) {
  8. throw context.runtime.newRuntimeError("no field: '" + name + "' in reified class for " + klass.getName());
  9. }
  10. JavaProxy.installField(context, name, field, klass);
  11. }
  12. }

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

  1. public void free() {
  2. if (allocation.isReleased()) {
  3. throw getRuntime().newRuntimeError("memory already freed");
  4. }
  5. allocation.free();
  6. sentinel = null;
  7. }

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

  1. public void free() {
  2. if (allocation.isReleased()) {
  3. throw getRuntime().newRuntimeError("memory already freed");
  4. }
  5. allocation.free();
  6. sentinel = null;
  7. }

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

  1. @JRubyMethod(name = "autorelease=")
  2. public final IRubyObject autorelease(ThreadContext context, IRubyObject autorelease) {
  3. Reaper r = reaper;
  4. if (r == null || r.released) {
  5. throw context.runtime.newRuntimeError("pointer already freed");
  6. }
  7. r.autorelease(autorelease.isTrue());
  8. return context.runtime.getNil();
  9. }

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

  1. @JRubyMethod()
  2. public IRubyObject block_length() {
  3. if (blockLength == 0) {
  4. throw getRuntime().newRuntimeError(
  5. this.getMetaClass() + " doesn't implement block_length()");
  6. }
  7. return RubyFixnum.newFixnum(getRuntime(), blockLength);
  8. }

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

  1. private void initEmitter(ThreadContext context, IRubyObject _encoding) {
  2. if (emitter != null) throw context.runtime.newRuntimeError("already initialized emitter");
  3. Encoding encoding = PsychLibrary.YAMLEncoding.values()[(int)_encoding.convertToInteger().getLongValue()].encoding;
  4. Charset charset = context.runtime.getEncodingService().charsetForEncoding(encoding);
  5. emitter = new Emitter(new OutputStreamWriter(new IOOutputStream(io, encoding), charset), options);
  6. }

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

  1. @JRubyMethod(module = true)
  2. public static IRubyObject peek_result(ThreadContext context, IRubyObject self) {
  3. Ruby runtime = context.runtime;
  4. if (!runtime.getCoverageData().isCoverageEnabled()) {
  5. throw runtime.newRuntimeError("coverage measurement is not enabled");
  6. }
  7. return convertCoverageToRuby(context, runtime, runtime.getCoverageData().getCoverage());
  8. }

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

  1. @JRubyMethod(name = "free")
  2. public final IRubyObject free(ThreadContext context) {
  3. if (getMemoryIO() instanceof AllocatedDirectMemoryIO) {
  4. ((AllocatedDirectMemoryIO) getMemoryIO()).free();
  5. } else {
  6. throw context.runtime.newRuntimeError("cannot free non-allocated function");
  7. }
  8. // Replace memory object with one that throws an exception on any access
  9. setMemoryIO(new FreedMemoryIO(context.runtime));
  10. return context.nil;
  11. }

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

  1. @JRubyMethod(module = true)
  2. public static IRubyObject peek_result(ThreadContext context, IRubyObject self) {
  3. Ruby runtime = context.runtime;
  4. if (!runtime.getCoverageData().isCoverageEnabled()) {
  5. throw runtime.newRuntimeError("coverage measurement is not enabled");
  6. }
  7. return convertCoverageToRuby(context, runtime, runtime.getCoverageData().getCoverage());
  8. }

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

  1. public RubyIO(Ruby runtime, InputStream inputStream) {
  2. super(runtime, runtime.getIO());
  3. if (inputStream == null) {
  4. throw runtime.newRuntimeError("Opening null stream");
  5. }
  6. openFile = MakeOpenFile();
  7. openFile.setFD(new ChannelFD(readableChannel(inputStream), runtime.getPosix(), runtime.getFilenoUtil()));
  8. openFile.setMode(OpenFile.READABLE);
  9. }

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

  1. public RubyIO(Ruby runtime, OutputStream outputStream, boolean autoclose) {
  2. super(runtime, runtime.getIO());
  3. // We only want IO objects with valid streams (better to error now).
  4. if (outputStream == null) {
  5. throw runtime.newRuntimeError("Opening null stream");
  6. }
  7. openFile = MakeOpenFile();
  8. openFile.setFD(new ChannelFD(writableChannel(outputStream), runtime.getPosix(), runtime.getFilenoUtil()));
  9. openFile.setMode(OpenFile.WRITABLE | OpenFile.APPEND);
  10. openFile.setAutoclose(autoclose);
  11. }

相关文章

Ruby类方法