Predicate p = new VisibilityPredicate(type, false); final Method[] methods = (Method[])ReflectUtils.filter(type.getDeclaredMethods(), p); final Constructor[] constructors = (Constructor[])ReflectUtils.filter(type.getDeclaredConstructors(), p);
VisibilityPredicate vp = new VisibilityPredicate(type, false); List methodList = ReflectUtils.addAllMethods(type, new ArrayList()); CollectionUtils.filter(methodList, vp); CollectionUtils.filter(methodList, new DuplicatesPredicate()); final Method[] methods = (Method[])methodList.toArray(new Method[methodList.size()]); final Constructor[] constructors = (Constructor[])CollectionUtils.filter(type.getDeclaredConstructors(), vp);   begin_method(SIGNATURE_GET_INDEX); final List signatures = CollectionUtils.transform(Arrays.asList(methods), new Transformer() { public Object transform(Object obj) { Method m = (Method)obj; return m.getName() + ReflectUtils.getMethodDescriptor((Method)obj); } }); load_arg(0); string_switch((String[])signatures.toArray(new String[0]), SWITCH_STYLE_HASH, new ObjectSwitchCallback() { public void processCase(Object key, Label end) {  push(signatures.indexOf(key)); return_value(); } public void processDefault() { push(-1); return_value(); } }); end_method();
    public void generate() throws Exception {        // constructor        begin_constructor(CONSTRUCTOR_TYPES);        load_this();        load_args();        super_invoke_constructor(CONSTRUCTOR_TYPES);        return_value();        end_method();        Predicate p = new VisibilityPredicate(type, false);        final Method[] methods = (Method[])ReflectUtils.filter(type.getDeclaredMethods(), p);        final Constructor[] constructors = (Constructor[])ReflectUtils.filter(type.getDeclaredConstructors(), p);        // getIndex(String, Class[])        begin_method(METHOD_GET_INDEX);        load_args();        method_switch(methods, new GetIndexCallback(methods));        end_method();        // getIndex(Class[])        begin_method(CONSTRUCTOR_GET_INDEX);        load_args();        constructor_switch(constructors, new GetIndexCallback(constructors));        end_method();        // invoke(int, Object, Object[])        begin_method(INVOKE);        load_arg(1);        checkcast(type);        load_arg(0);        process_switch(getIntRange(methods.length), new ProcessSwitchCallback() {            public void processCase(int key, Label end) {                Method method = methods[key];                // checkcast(method.getDeclaringClass());                Class[] types = method.getParameterTypes();                for (int i = 0; i < types.length; i++) {                    load_arg(2);                    aaload(i);                    unbox(types[i]);                }                invoke(method);                box(method.getReturnType());                // goTo(end);                                return_value();            }            public void processDefault() {                throw_exception(NoSuchMethodError.class, "Cannot find matching method/constructor");            }        });        // return_value();        end_method();        // newInstance(int, Object[])        begin_method(NEW_INSTANCE);        new_instance(type);        dup();        load_arg(0);        process_switch(getIntRange(constructors.length), new ProcessSwitchCallback() {            public void processCase(int key, Label end) {                Constructor constructor = constructors[key];                Class[] types = constructor.getParameterTypes();                for (int i = 0; i < types.length; i++) {                    load_arg(1);                    aaload(i);                    unbox(types[i]);                }                invoke(constructor);                return_value();            }            public void processDefault() {                throw_exception(NoSuchMethodError.class, "Cannot find matching method/constructor");            }        });        end_method();    }