Bill Janssen <jans...@parc.com> wrote:

> Bill Janssen <jans...@parc.com> wrote:
> 
> > What's crashing with PyLucene 2.9.3 is this code:
> > 
> >      for field in x.getFields():
> > 
> > where "x" is an instance of org.apache.lucene.document.Document.  I can
> > print x and it looks OK, but an attempt to iterate over the list of
> > fields seems broken.  Is this another iterator change?
> 
> I see that I also can't iterate over x.getFields().listIterator(),
> presumably because, in the Java 1.4 that Lucene 2.9.x uses,
> java.util.Iterator doesn't "implement" java.lang.Iterable.  A tad
> ridiculous.  Certainly java.util.List should be a sequence of some sort.

I looked into this a bit further.  The common-build.xml file for Lucene
2.9.x specifies

  <property name="javac.source" value="1.4"/>
  <property name="javac.target" value="1.4"/>

and in 1.4 the java.util.Iterable class from Java 1.5 doesn't exist.

The docs for JCC still say this:

``When generating wrappers for Python, JCC attempts to detect which
classes can be made iterable:

  * When a class declares to implement java.util.Iterator or something
    compatible with it, JCC makes it iterable from Python.

  * When a Java class declares a method called iterator() with no
    arguments returning a type compatible with java.util.Iterator, this
    class is made iterable from Python.

  * When a Java class declares a method called next() with no arguments
    returning an object type, this class is made iterable. Its next()
    method is assumed to terminate iteration by returning null.''

Presumably that's no longer the case with JCC 2.6.  Probably should be
updated to whatever the current version does.  Or perhaps versioned and
checked into the source tree.

Bill

Reply via email to