if (method.getName().equals("writeReplace") && method.getParameterTypes().length == 0) { declaresWriteReplace = true; }
    protected void generate() throws Exception {        Class type = getSuperclass();        List constructors = new ArrayList(Arrays.asList(type.getDeclaredConstructors()));        filterMembers(constructors, new VisibilityFilter(type));        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);        }        filterMembers(methods, new VisibilityFilter(getSuperclass()));        filterMembers(methods, new DuplicatesFilter());        filterMembers(methods, new ModifierFilter(Modifier.FINAL, 0));        boolean declaresWriteReplace = false;        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 == null) ? Callbacks.INTERCEPT : filter.accept(method);            if (ctype > Callbacks.MAX_VALUE) {                // TODO: error            }            if (group[ctype] == null) {                group[ctype] = new ArrayList(methods.size());                generators[ctype] = Callbacks.getGenerator(ctype);            }            group[ctype].add(method);            if (method.getName().equals("writeReplace") &&                method.getParameterTypes().length == 0) {                declaresWriteReplace = true;            }        }        if (!declaresWriteReplace) {            generateWriteReplace();        }        // the order of these methods is important        generateConstructors(constructors); // #1        generateMethods(generators, group, forcePublic); // #2        // #3 .. N        generateLegacyFactory();        generateFactory();        generateStatic(constructors, generators, group);        generateSetThreadCallbacks();    }