private void checkInstanceof(Object javaInvokee) throws RaiseException { if (!method.getDeclaringClass().isInstance(javaInvokee)) { throw getRuntime().newTypeError("invokee not instance of method's class (" + "got" + javaInvokee.getClass().getName() + " wanted " + method.getDeclaringClass().getName() + ")"); } }
private void checkInstanceof(Object javaInvokee) throws RaiseException { if (!method.getDeclaringClass().isInstance(javaInvokee)) { throw getRuntime().newTypeError("invokee not instance of method's class (" + "got" + javaInvokee.getClass().getName() + " wanted " + method.getDeclaringClass().getName() + ")"); } }
private IRubyObject convertReturn(Object result) { if (result != null && result.getClass() != boxedReturnType) { // actual type does not exactly match method return type, re-get converter // FIXME: when the only autoconversions are primitives, this won't be needed return JavaUtil.convertJavaToUsableRubyObject(getRuntime(), result); } return JavaUtil.convertJavaToUsableRubyObjectWithConverter(getRuntime(), result, returnConverter); }
private IRubyObject convertReturn(Object result) { if (result != null && result.getClass() != boxedReturnType) { // actual type does not exactly match method return type, re-get converter // FIXME: when the only autoconversions are primitives, this won't be needed return JavaUtil.convertJavaToUsableRubyObject(getRuntime(), result); } return JavaUtil.convertJavaToUsableRubyObjectWithConverter(getRuntime(), result, returnConverter); }
private IRubyObject convertReturn(Object result) { if (result != null && result.getClass() != boxedReturnType) { // actual type does not exactly match method return type, re-get converter // FIXME: when the only autoconversions are primitives, this won't be needed return JavaUtil.convertJavaToUsableRubyObject(getRuntime(), result); } return JavaUtil.convertJavaToUsableRubyObjectWithConverter(getRuntime(), result, returnConverter); }
private IRubyObject convertReturn(Object result) { if (result != null && result.getClass() != boxedReturnType) { // actual type does not exactly match method return type, re-get converter // FIXME: when the only autoconversions are primitives, this won't be needed return JavaUtil.convertJavaToUsableRubyObject(getRuntime(), result); } return JavaUtil.convertJavaToUsableRubyObjectWithConverter(getRuntime(), result, returnConverter); }
@JRubyMethod public IRubyObject return_type() { Class<?> klass = method.getReturnType(); if (klass.equals(void.class)) { return getRuntime().getNil(); } return JavaClass.get(getRuntime(), klass); }
@JRubyMethod public IRubyObject return_type() { Class<?> klass = method.getReturnType(); if (klass.equals(void.class)) { return getRuntime().getNil(); } return JavaClass.get(getRuntime(), klass); }
@JRubyMethod public IRubyObject return_type() { Class<?> klass = method.getReturnType(); if (klass.equals(void.class)) { return getRuntime().getNil(); } return JavaClass.get(getRuntime(), klass); }
@JRubyMethod(name = "public?") @Override public RubyBoolean public_p() { return getRuntime().newBoolean(Modifier.isPublic(method.getModifiers())); }
@JRubyMethod(name = "public?") @Override public RubyBoolean public_p() { return getRuntime().newBoolean(Modifier.isPublic(method.getModifiers())); }
@JRubyMethod(name = "public?") @Override public RubyBoolean public_p() { return getRuntime().newBoolean(Modifier.isPublic(method.getModifiers())); }
@JRubyMethod(name = "public?") @Override public RubyBoolean public_p() { return getRuntime().newBoolean(Modifier.isPublic(method.getModifiers())); }
@JRubyMethod(name = "final?") public RubyBoolean final_p() { return getRuntime().newBoolean(Modifier.isFinal(method.getModifiers())); }
@JRubyMethod @Override public RubyString name() { return getRuntime().newString(method.getName()); }
@JRubyMethod @Override public RubyString name() { return getRuntime().newString(method.getName()); }
@JRubyMethod public RubyString inspect() { StringBuilder str = new StringBuilder(); str.append("#<"); str.append( getType().toString() ).append('/').append(method.getName()); inspectParameterTypes(str, this); str.append('>'); return RubyString.newString(getRuntime(), str); }
@JRubyMethod public RubyString inspect() { StringBuilder str = new StringBuilder(); str.append("#<"); str.append( getType().toString() ).append('/').append(method.getName()); inspectParameterTypes(str, this); str.append('>'); return RubyString.newString(getRuntime(), str); }
@JRubyMethod(name = "static?") public RubyBoolean static_p() { return getRuntime().newBoolean(isStatic()); }
private IRubyObject invokeWithExceptionHandling(ThreadContext context, Method method, Object javaInvokee, Object[] arguments) { try { Object result = method.invoke(javaInvokee, arguments); return returnConverter.convert(getRuntime(), result); } catch (IllegalArgumentException iae) { return handlelIllegalArgumentEx(iae, method, arguments); } catch (IllegalAccessException iae) { return handleIllegalAccessEx(iae, method); } catch (InvocationTargetException ite) { return handleInvocationTargetEx(context, ite); } catch (Throwable t) { return handleThrowable(context, t); } }