Andi Vajda <[email protected]> wrote:

> 
> On Jul 21, 2010, at 19:59, Bill Janssen <[email protected]> wrote:
> 
> > Bill Janssen <[email protected]> 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.
> 
> Not ridiculous, impossible, since java.lang.Iterable appeared in Java
> 1.5 and Lucene 2.x claims Java 1.4 compatibility.

No, I mean it's ridiculous that I can't subscript or iterate, in Python,
a value of java.util.List.  You need something in jcc to support Java
1.4 sequence types as well as the new code for 1.5 sequence types.  I
presume that there will be a 2.9.4 in the future, right?

I looked at the jcc code a bit.  In jcc/python.py, this bit

    if env.java_version >= '1.5':
        iterable = findClass('java/lang/Iterable')
        iterator = findClass('java/util/Iterator')
    else:
        iterable = iterator = None

could perhaps become

    if env.java_version >= '1.5':
        iterable = findClass('java/lang/Iterable')
        iterator = findClass('java/util/Iterator')
    else:
        iterable = findClass('java/lang/Object')
        iterator = findClass('java/lang/Iterator')

Not sure.  Probably more is required.

> > Certainly java.util.List should be a sequence of some sort.
> 
> It can be if declare it via the --sequence jcc command line flag.

So a change to the Makefile would be in order, for the 2.x branch.

Is there an auto-downcasting switch for jcc?  That is, it would be nice,
for sequences and mappings, if the "get" method would automatically cast
the retrieved value to the Pythonic representation of the most specific
type.

Bill

Reply via email to