本文整理了Java中org.jruby.Ruby.getNativeException
方法的一些代码示例,展示了Ruby.getNativeException
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Ruby.getNativeException
方法的具体详情如下:
包路径:org.jruby.Ruby
类名称:Ruby
方法名:getNativeException
暂无
代码示例来源:origin: org.jruby/jruby-complete
@SuppressWarnings("deprecation")
private static IRubyObject wrapWithNativeException(ThreadContext context, Throwable throwable, Ruby runtime) {
// wrap Throwable in a NativeException object
org.jruby.NativeException exception = new org.jruby.NativeException(runtime, runtime.getNativeException(), throwable);
exception.prepareIntegratedBacktrace(context, throwable.getStackTrace());
return exception;
}
代码示例来源:origin: org.jruby/jruby-complete
@Deprecated
public static RaiseException createNativeRaiseException(Ruby runtime, Throwable cause, Member target) {
org.jruby.NativeException nativeException = new org.jruby.NativeException(runtime, runtime.getNativeException(), cause);
return new RaiseException(cause, nativeException);
}
代码示例来源:origin: org.jruby/jruby-core
@Deprecated
public static RaiseException createNativeRaiseException(Ruby runtime, Throwable cause, Member target) {
org.jruby.NativeException nativeException = new org.jruby.NativeException(runtime, runtime.getNativeException(), cause);
return new RaiseException(cause, nativeException);
}
代码示例来源:origin: org.jruby/jruby-core
@SuppressWarnings("deprecation")
private static IRubyObject wrapWithNativeException(ThreadContext context, Throwable throwable, Ruby runtime) {
// wrap Throwable in a NativeException object
org.jruby.NativeException exception = new org.jruby.NativeException(runtime, runtime.getNativeException(), throwable);
exception.prepareIntegratedBacktrace(context, throwable.getStackTrace());
return exception;
}
代码示例来源:origin: org.jruby/jruby-complete
private static IRubyObject wrapJavaException(final ThreadContext context, final IRubyObject excType, final Throwable throwable) {
final Ruby runtime = context.runtime;
if (excType == runtime.getNativeException()) {
return wrapWithNativeException(context, throwable, runtime);
}
return Helpers.wrapJavaException(runtime, throwable); // wrap as normal JI object
}
代码示例来源:origin: org.jruby/jruby-core
private static IRubyObject wrapJavaException(final ThreadContext context, final IRubyObject excType, final Throwable throwable) {
final Ruby runtime = context.runtime;
if (excType == runtime.getNativeException()) {
return wrapWithNativeException(context, throwable, runtime);
}
return Helpers.wrapJavaException(runtime, throwable); // wrap as normal JI object
}
代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby
public static RaiseException createNativeRaiseException(Ruby runtime, Throwable cause, Member target) {
NativeException nativeException = new NativeException(runtime, runtime.getNativeException(), cause);
// FIXME: someday, add back filtering of reflection/handle methods between JRuby and target
return new RaiseException(cause, nativeException);
}
代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby
public static RaiseException createNativeRaiseException(Ruby runtime, Throwable cause, Member target) {
NativeException nativeException = new NativeException(runtime, runtime.getNativeException(), cause);
// FIXME: someday, add back filtering of reflection/handle methods between JRuby and target
return new RaiseException(cause, nativeException);
}
代码示例来源:origin: org.jruby/jruby-complete
@Deprecated
public static void storeNativeExceptionInErrorInfo(Throwable currentThrowable, ThreadContext context) {
IRubyObject exception;
if (currentThrowable instanceof RaiseException) {
exception = ((RaiseException)currentThrowable).getException();
} else {
Ruby runtime = context.runtime;
// wrap Throwable in a NativeException object
exception = new NativeException(runtime, runtime.getNativeException(), currentThrowable);
((NativeException)exception).prepareIntegratedBacktrace(context, currentThrowable.getStackTrace());
}
context.setErrorInfo(exception);
}
代码示例来源:origin: org.jruby/jruby-core
@Deprecated
public static void storeNativeExceptionInErrorInfo(Throwable currentThrowable, ThreadContext context) {
IRubyObject exception;
if (currentThrowable instanceof RaiseException) {
exception = ((RaiseException)currentThrowable).getException();
} else {
Ruby runtime = context.runtime;
// wrap Throwable in a NativeException object
exception = new NativeException(runtime, runtime.getNativeException(), currentThrowable);
((NativeException)exception).prepareIntegratedBacktrace(context, currentThrowable.getStackTrace());
}
context.setErrorInfo(exception);
}
代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby
public static void storeNativeExceptionInErrorInfo(Throwable currentThrowable, ThreadContext context) {
IRubyObject exception = null;
if (currentThrowable instanceof RaiseException) {
exception = ((RaiseException)currentThrowable).getException();
} else {
Ruby runtime = context.runtime;
// wrap Throwable in a NativeException object
exception = new NativeException(runtime, runtime.getNativeException(), currentThrowable);
((NativeException)exception).prepareIntegratedBacktrace(context, currentThrowable.getStackTrace());
}
context.setErrorInfo(exception);
}
代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby
public static void storeNativeExceptionInErrorInfo(Throwable currentThrowable, ThreadContext context) {
IRubyObject exception = null;
if (currentThrowable instanceof RaiseException) {
exception = ((RaiseException)currentThrowable).getException();
} else {
Ruby runtime = context.runtime;
// wrap Throwable in a NativeException object
exception = new NativeException(runtime, runtime.getNativeException(), currentThrowable);
((NativeException)exception).prepareIntegratedBacktrace(context, currentThrowable.getStackTrace());
}
context.setErrorInfo(exception);
}
代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby
private IRubyObject handleJavaException(Ruby runtime, ThreadContext context, IRubyObject self, Block aBlock, Throwable throwable) {
RescueBodyNode cRescueNode = rescueNode;
while (cRescueNode != null) {
IRubyObject[] exceptions = getExceptions(cRescueNode, runtime, context, self, aBlock);
if (Helpers.isJavaExceptionHandled(throwable, exceptions, context).isTrue()) {
IRubyObject exceptionObj;
if (exceptions.length == 1 && exceptions[0] == runtime.getNativeException()) {
// wrap Throwable in a NativeException object
exceptionObj = new NativeException(runtime, runtime.getNativeException(), throwable);
((NativeException)exceptionObj).prepareIntegratedBacktrace(context, throwable.getStackTrace());
} else {
// wrap as normal JI object
exceptionObj = JavaUtil.convertJavaToUsableRubyObject(runtime, throwable);
}
runtime.getGlobalVariables().set("$!", exceptionObj);
return cRescueNode.interpret(runtime, context, self, aBlock);
}
cRescueNode = cRescueNode.getOptRescueNode();
}
// no takers; bubble up
Helpers.throwException(throwable);
throw new RuntimeException("Unsafe.throwException failed");
}
代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby
private IRubyObject handleJavaException(Ruby runtime, ThreadContext context, IRubyObject self, Block aBlock, Throwable throwable) {
RescueBodyNode cRescueNode = rescueNode;
while (cRescueNode != null) {
IRubyObject[] exceptions = getExceptions(cRescueNode, runtime, context, self, aBlock);
if (Helpers.isJavaExceptionHandled(throwable, exceptions, context).isTrue()) {
IRubyObject exceptionObj;
if (exceptions.length == 1 && exceptions[0] == runtime.getNativeException()) {
// wrap Throwable in a NativeException object
exceptionObj = new NativeException(runtime, runtime.getNativeException(), throwable);
((NativeException)exceptionObj).prepareIntegratedBacktrace(context, throwable.getStackTrace());
} else {
// wrap as normal JI object
exceptionObj = JavaUtil.convertJavaToUsableRubyObject(runtime, throwable);
}
runtime.getGlobalVariables().set("$!", exceptionObj);
return cRescueNode.interpret(runtime, context, self, aBlock);
}
cRescueNode = cRescueNode.getOptRescueNode();
}
// no takers; bubble up
Helpers.throwException(throwable);
throw new RuntimeException("Unsafe.throwException failed");
}
代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby
private static boolean checkJavaException(Throwable throwable, IRubyObject catchable, ThreadContext context) {
Ruby runtime = context.runtime;
if (
// rescue exception needs to catch Java exceptions
runtime.getException() == catchable ||
// rescue Object needs to catch Java exceptions
runtime.getObject() == catchable ||
// rescue StandardError needs t= catch Java exceptions
runtime.getStandardError() == catchable) {
if (throwable instanceof RaiseException) {
return isExceptionHandled(((RaiseException)throwable).getException(), catchable, context).isTrue();
}
// let Ruby exceptions decide if they handle it
return isExceptionHandled(JavaUtil.convertJavaToUsableRubyObject(runtime, throwable), catchable, context).isTrue();
} else if (runtime.getNativeException() == catchable) {
// NativeException catches Java exceptions, lazily creating the wrapper
return true;
} else if (catchable instanceof RubyClass && catchable.getInstanceVariables().hasInstanceVariable("@java_class")) {
RubyClass rubyClass = (RubyClass)catchable;
JavaClass javaClass = (JavaClass)rubyClass.getInstanceVariable("@java_class");
if (javaClass != null) {
Class cls = javaClass.javaClass();
if (cls.isInstance(throwable)) {
return true;
}
}
}
return false;
}
代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby
private static boolean checkJavaException(Throwable throwable, IRubyObject catchable, ThreadContext context) {
Ruby runtime = context.runtime;
if (
// rescue exception needs to catch Java exceptions
runtime.getException() == catchable ||
// rescue Object needs to catch Java exceptions
runtime.getObject() == catchable ||
// rescue StandardError needs t= catch Java exceptions
runtime.getStandardError() == catchable) {
if (throwable instanceof RaiseException) {
return isExceptionHandled(((RaiseException)throwable).getException(), catchable, context).isTrue();
}
// let Ruby exceptions decide if they handle it
return isExceptionHandled(JavaUtil.convertJavaToUsableRubyObject(runtime, throwable), catchable, context).isTrue();
} else if (runtime.getNativeException() == catchable) {
// NativeException catches Java exceptions, lazily creating the wrapper
return true;
} else if (catchable instanceof RubyClass && catchable.getInstanceVariables().hasInstanceVariable("@java_class")) {
RubyClass rubyClass = (RubyClass)catchable;
JavaClass javaClass = (JavaClass)rubyClass.getInstanceVariable("@java_class");
if (javaClass != null) {
Class cls = javaClass.javaClass();
if (cls.isInstance(throwable)) {
return true;
}
}
}
return false;
}
代码示例来源:origin: org.jruby/jruby-complete
if (runtime.getNativeException() == catchable) {
代码示例来源:origin: org.jruby/jruby-core
if (runtime.getNativeException() == catchable) {
内容来源于网络,如有侵权,请联系作者删除!