private boolean matchClass(String name, ClassPool pool) {
        if (classname.equals(name))
            return true;

        try {
            CtClass clazz = pool.get(name);
            CtClass declClazz = pool.get(classname);
            if (clazz.subtypeOf(declClazz))
                try {
                    CtMethod m = clazz.getMethod(methodname, methodDescriptor);
                    return m.getDeclaringClass().getName().equals(classname);
                }
                catch (NotFoundException e) {
                    // maybe the original method has been removed.
                    return true;
                }
        }
        catch (NotFoundException e) {
            return false;
        }

        return false;
    }