String packageName = getSuperclass().getPackage().getName();
Package packageName = getSuperclass().getPackage();
    protected void generate() throws NoSuchMethodException {        if (wreplace == null) {            wreplace = Enhancer.InternalReplace.class.getMethod("writeReplace", OBJECT_CLASS_ARRAY);        }                declare_interface(Factory.class);        declare_field(Modifier.PRIVATE, MethodInterceptor.class, INTERCEPTOR_FIELD);        if (delegating) {            declare_field(Modifier.PRIVATE, getSuperclass(), DELEGATE_FIELD);        }        generateConstructor();        generateFactory();        generateFindClass();        // Order is very important: must add superclass, then        // its superclass chain, then each interface and        // its superinterfaces.        List allMethods = new LinkedList();        addDeclaredMethods(allMethods, getSuperclass());        if (interfaces != null) {            declare_interfaces(interfaces);            for (int i = 0; i < interfaces.length; i++) {                addDeclaredMethods(allMethods, interfaces[i]);            }        }        boolean declaresWriteReplace = false;        String packageName = getSuperclass().getPackage().getName();        Map methodMap = new HashMap();        for (Iterator it = allMethods.iterator(); it.hasNext();) {            Method method = (Method)it.next();            int mod = method.getModifiers();            if (!Modifier.isStatic(mod) && !Modifier.isFinal(mod) &&                (!delegating || !Modifier.isProtected(mod)) &&                isVisible(method, packageName)) {                if (method.getName().equals("writeReplace") &&                    method.getParameterTypes().length == 0) {                    declaresWriteReplace = true;                }                Object methodKey = MethodWrapper.newInstance(method);                Method other = (Method)methodMap.get(methodKey);                if (other != null) {                    checkReturnTypesEqual(method, other);                }                methodMap.put(methodKey, method);            }        }        Method invokeSuper = getInvokeSuper();        Method afterReturn = getAfterReturn();        Map methodTable = new HashMap();        int cntr = 0;        for (Iterator it = methodMap.values().iterator(); it.hasNext();) {            Method method = (Method)it.next();            String fieldName = "METHOD_" + cntr++;            declare_field(Modifier.PRIVATE | Modifier.FINAL | Modifier.STATIC, Method.class, fieldName);            generateMethod(fieldName, method, invokeSuper, afterReturn);            methodTable.put(fieldName, method);        }        generateClInit(methodTable);        if (!declaresWriteReplace) {            generateWriteReplace();        }    }