addDeclaredMethods(interfaceMethods, interfaces[i]);
ReflectUtils.addAllMethods(interfaces[i], interfaceMethods);
    protected void generate() throws Exception {        Class type = getSuperclass();        List constructors = new ArrayList(Arrays.asList(type.getDeclaredConstructors()));        ReflectUtils.filter(constructors, new VisibilityPredicate(type, true));        if (constructors.size() == 0) {            throw new IllegalArgumentException("No visible constructors in " + type);        }        ensureLoadable(type);        ensureLoadable(interfaces);                // Order is very important: must add superclass, then        // its superclass chain, then each interface and        // its superinterfaces.        List methods = new ArrayList();        addDeclaredMethods(methods, getSuperclass());        Set forcePublic = Collections.EMPTY_SET;        if (interfaces != null) {            List interfaceMethods = new ArrayList();            for (int i = 0; i < interfaces.length; i++) {                addDeclaredMethods(interfaceMethods, interfaces[i]);            }            forcePublic = MethodWrapper.createSet(interfaceMethods);            methods.addAll(interfaceMethods);        }        ReflectUtils.filter(methods, new VisibilityPredicate(getSuperclass(), true));        removeDuplicates(methods);        removeFinal(methods);        int len = Callbacks.MAX_VALUE + 1;        CallbackGenerator[] generators = new CallbackGenerator[len];        List[] group = new List[len];        for (Iterator it = methods.iterator(); it.hasNext();) {            Method method = (Method)it.next();            int ctype = filter.accept(method);            if (ctype > Callbacks.MAX_VALUE) {                // TODO: error            }            if (group[ctype] == null) {                group[ctype] = new ArrayList(methods.size());                generators[ctype] = CallbackUtils.getGenerator(ctype);            }            group[ctype].add(method);        }        declare_field(Modifier.PRIVATE, Boolean.TYPE, CONSTRUCTED_FIELD);        generateConstructors(constructors);        CallbackGenerator.Context[] contexts = createContexts(generators, group, forcePublic);        generateMethods(generators, contexts);        generateStatic(generators, contexts);        generateFactory(constructors);        generateSetThreadCallbacks();    }