public MethodDescriptor(T methodObject) { anno = getAnnotation(methodObject, JRubyMethod.class); modifiers = getModifiers(methodObject); declaringClassName = getDeclaringClassName(methodObject); declaringClassPath = declaringClassName.replace('.', '/'); name = getSimpleName(methodObject); final String[] names = anno.name(); rubyName = (names != null && names.length > 0) ? names[0] : name; isStatic = Modifier.isStatic(modifiers); hasContext = hasContext(methodObject); hasBlock = hasBlock(methodObject); final int parameterCount = parameterCount(methodObject); if (hasContext) { if (isStatic && (parameterCount < 2 || !parameterAsString(methodObject, 1).equals("org.jruby.runtime.builtin.IRubyObject"))) { throw new RuntimeException("static method without self argument: " + methodObject); hasVarArgs = parameterAsString(methodObject, parameterCount - 2).equals(IRUBYOBJECT_ARRAY_CLASS_NAME); } else { hasVarArgs = parameterAsString(methodObject, parameterCount - 1).equals(IRUBYOBJECT_ARRAY_CLASS_NAME); if (isStatic && (parameterCount < 1 || !parameterAsString(methodObject, 0).equals("org.jruby.runtime.builtin.IRubyObject"))) { throw new RuntimeException("static method without self argument: " + methodObject); hasVarArgs = parameterCount > 1 && parameterAsString(methodObject, parameterCount - 2).equals(IRUBYOBJECT_ARRAY_CLASS_NAME); } else { hasVarArgs = parameterCount > 0 && parameterAsString(methodObject, parameterCount - 1).equals(IRUBYOBJECT_ARRAY_CLASS_NAME);
public MethodDescriptor(T methodObject) { anno = getAnnotation(methodObject, JRubyMethod.class); modifiers = getModifiers(methodObject); declaringClassName = getDeclaringClassName(methodObject); declaringClassPath = declaringClassName.replace('.', '/'); name = getSimpleName(methodObject); final String[] names = anno.name(); rubyName = (names != null && names.length > 0) ? names[0] : name; isStatic = Modifier.isStatic(modifiers); hasContext = hasContext(methodObject); hasBlock = hasBlock(methodObject); final int parameterCount = parameterCount(methodObject); if (hasContext) { if (isStatic && (parameterCount < 2 || !parameterAsString(methodObject, 1).equals("org.jruby.runtime.builtin.IRubyObject"))) { throw new RuntimeException("static method without self argument: " + methodObject); hasVarArgs = parameterAsString(methodObject, parameterCount - 2).equals(IRUBYOBJECT_ARRAY_CLASS_NAME); } else { hasVarArgs = parameterAsString(methodObject, parameterCount - 1).equals(IRUBYOBJECT_ARRAY_CLASS_NAME); if (isStatic && (parameterCount < 1 || !parameterAsString(methodObject, 0).equals("org.jruby.runtime.builtin.IRubyObject"))) { throw new RuntimeException("static method without self argument: " + methodObject); hasVarArgs = parameterCount > 1 && parameterAsString(methodObject, parameterCount - 2).equals(IRUBYOBJECT_ARRAY_CLASS_NAME); } else { hasVarArgs = parameterCount > 0 && parameterAsString(methodObject, parameterCount - 1).equals(IRUBYOBJECT_ARRAY_CLASS_NAME);