FieldDoc[] getAllFields(ClassDoc subclazz)
                throws ClassNotFoundException {
        Vector fields = new Vector();
        ClassDoc cd = null;
        Stack s = new Stack();

        cd = subclazz;
        while (true) {
            s.push(cd);
            ClassDoc c = cd.superclass();
            if (c == null)
                break;
            cd = c;
        }

        while (!s.empty()) {
            cd = (ClassDoc)s.pop();
            fields.addAll(Arrays.asList(cd.fields()));
        }

        return (FieldDoc[]) fields.toArray(new FieldDoc[fields.size()]);
    }