public void addMethod(CtMethod m) throws CannotCompileException {
        checkModify();
        if (m.getDeclaringClass() != this)
            throw new CannotCompileException("bad declaring class");

        int mod = m.getModifiers();
        if ((getModifiers() & Modifier.INTERFACE) != 0) {
            m.setModifiers(mod | Modifier.PUBLIC);
            if ((mod & Modifier.ABSTRACT) == 0)
                throw new CannotCompileException(
                        "an interface method must be abstract: " + m.toString());
        }

        getMembers().addMethod(m);
        getClassFile2().addMethod(m.getMethodInfo2());
        if ((mod & Modifier.ABSTRACT) != 0)
            setModifiers(getModifiers() | Modifier.ABSTRACT);
    }