private static RaiseException argumentError( ThreadContext context, ParameterTypes[] methods, IRubyObject receiver, Class[] argTypes) { boolean constructor = methods[0] instanceof JavaConstructor || methods[0] instanceof JavaProxyConstructor; StringBuffer fullError = new StringBuffer(); fullError.append("no "); if (constructor) { fullError.append("constructor"); } else { fullError.append("method '").append(((JavaMethod) methods[0]).name().toString()).append("' "); } fullError.append("for arguments ").append(CodegenUtils.prettyParams(argTypes)).append(" on "); if (receiver instanceof RubyModule) { fullError.append(((RubyModule) receiver).getName()); } else { fullError.append(receiver.getMetaClass().getRealClass().getName()); } if (methods.length > 1) { fullError.append("\n available overloads:"); for (ParameterTypes method : methods) { fullError.append("\n " + CodegenUtils.prettyParams(method.getParameterTypes())); } } return context.runtime.newNameError(fullError.toString(), null); }
private Method getMethod(String name, Class... argTypes) { try { return getObject().getClass().getMethod(name, argTypes); } catch (NoSuchMethodException nsme) { throw JavaMethod.newMethodNotFoundError( getRuntime(), getObject().getClass(), name + CodegenUtils.prettyParams(argTypes), name); } }
private RubyMethod getRubyMethod(String name, Class... argTypes) { Method jmethod = getMethod(name, argTypes); if (Modifier.isStatic(jmethod.getModifiers())) { return RubyMethod.newMethod( metaClass.getSingletonClass(), CodegenUtils.prettyParams(argTypes), metaClass.getSingletonClass(), name, getMethodInvoker(jmethod), getMetaClass()); } else { return RubyMethod.newMethod( metaClass, CodegenUtils.prettyParams(argTypes), metaClass, name, getMethodInvoker(jmethod), this); } }
@Override public String toString() { return "" + (statik ? "static " : "") + nativeReturn.getSimpleName() + " " + nativeTarget.getSimpleName() + "." + nativeName + CodegenUtils.prettyShortParams(nativeSignature); }
public boolean match(Class type, IRubyObject arg) { return type.equals(argClass(arg)) || (type.isPrimitive() && CodegenUtils.getBoxType(type) == argClass(arg)); }