Possible bug in JDom2

Craig Noah <[email protected]> Thu, 15 Mar 2012 14:59:11 -0500
Newsgroups gmane.comp.java.jdom.general
Message-ID <CALi3K=Lkod5FdEZ2TCX7jj36AN_R5TYrgxUqco6GFNfxCt9LdQ@mail.gmail.com>
I've downloaded the latest JDom2 beta today and am working to incorporate
it into some new code.  I am developing against Java6, so I would expect
iterators to work.  However, the following code fails to compile (with
JDom2 includes):

SAXBuilder sax = new SAXBuilder();
Document xml = sax.build (source);    // source is a File object
Element root = xml.getRootElement();
ElementFilter tableFilter = new ElementFilter ("Table");
int tableCount = 0;
for (Element table : root.getDescendants(
tableFilter)) {
    tableCount++;
}

The compile-time error that I get states, "Can only iterate over an array
or an instance of java.lang.Iterable".  Since Element.getDescendants
(Filter<F>) returns a java.util.Iterator<F>, I would expect my code to
compile and work.  What am I missing?

Sincerely,
Craig

_______________________________________________
To control your jdom-interest membership:
http://www.jdom.org/mailman/options/jdom-interest/[email protected]