[Neo] Issues with overloaded methods

Tobias Ivarsson thobes at gmail.com
Tue Apr 10 17:01:17 CEST 2007


I dug a bit deeper into this using reflection, and found a method called
nextNode that I worked instead. But then I ran into the same problem with
the currentPosition metod as well. So It couldn't have been a wrapper
problem. Armed with the java reflection api in an interactive python shell
(a rather powerful weapon I must say) I dug even further into this matter
and found that AbstractTraverser has two methods (reported by
getDeclaredMethods() ) named "next" and two methods named "currentPosition",
with different signatures. They all take no parameters, which is why JPype
cannot know which method to invoke when I try to call next(). However the
return types vary:
The first next() returns org.neo4j.api.Node and the second java.lang.Object
The first currentPosition() returns
org.neo4j.traversal.TraversalPositionand the second
org.neo4j.api.TraversalPosition
I tried to build a workaround useing the invoke() method of these method
objects but received an InternalError from the JVM.
However I find it strange that there are two different methods like this.
Are they there in the code or is this some strange artifact caused by the
Generics system?
If they are there in the actual code, I assume that this will be cleaned up
by the time the migration to the new api is completed. Perhaps even with the
next beta release?

!EDIT!
When I wrote that last line I got to thinking that you might have released a
new beta since I downloaded it. And you had, I was using beta2, and beta 3
was available now... sadly the api seems to have changed a bit in beta3, so
there are some things I have to change. I will get back later about this.
However I still think the stuff above could be interesting.

/Tobias

On 4/9/07, Tobias Ivarsson <thobes at gmail.com> wrote:
>
>
>
> On 4/9/07, Johan Svensson <johan at neopersistence.com> wrote:
> >
> > On 4/9/07, Tobias Ivarsson <thobes at gmail.com> wrote:
> > >
> > > Hi!
> > >
> > > I am working on a Python frontend for Neo4J, which I call Neo4J.py,
> > that
> > > can
> > > be used with either Jython [1] or a Python (CPython [3]) extension
> > called
> > > JPype [2].
> >
> >
> > Excellent!
> >
> > However I am experiencing some strange problems when using JPype. When I
> > try
> > > to iterate over the result of a traverser I get an error message
> > saying
> > > that
> > > JPype could not determine which, of more than one overloaded, next()
> > > methods
> > > it should choose. I have never had this problem with any other
> > Iterator /
> > > Iterable and JPype before, so I am trying to figure out what could be
> > > causing this behavior.
> > > My current theory is that some where in the type hierarchy of the
> > actual
> > > implementation of the Traverser there are two (or more) classes that
> > > implement the Iterable interface, which would mean that there are
> > several
> > > next() methods.
> > > Could anyone with access to the source please tell me whether this is
> > the
> > > case or not. Or send me some sort of preview version of the source so
> > that
> > > I
> > > could investigate the matter on my own.
> >
> >
> > In org.neo4j.impl.traversal package we have:
> >
> > public interface Traverser extends org.neo4j.api.core.Traverser
> >
> > abstract class AbstractTraverser implements Traverser,Iterator<Node>
>
>
>
> Ah! this is probably the source of the problem. JPype implements ways of
> iterating over both Iterator and Iterable via wrapping code. I am guessing
> that since the Traverser Iterable is itself its own Iterator the object will
> get wrapped twice which leads to the confusion. Now all I have to do is to
> find a way to avoid that. Preferably without needing to patch neither JPype
> nor Neo...
>
> Thanks!
> /Tobias
>
> class BreadthFirstTraverser extends AbstractTraverser
> >
> > class DepthFirstTraverser extends AbstractTraverser
> >
> > The first interface (Traverser that extends api.core.Traverser) is just
> > old
> > stuff that hasn't been removed yet since the recent update of the Neo
> > API.
> > Implementation of Iterator interface lies in AbstractTraverser, the two
> > concrete classes (that gets instantiated depending on
> > BREADTH_FIRST/DEPTH_FIRST traverser) don't override any of the Iterator
> > interface methods.
> >
> > I will submit a link to the source code of my project on this list as
> > soon
> > > as a have added some license notes to my files and perhaps written
> > some
> > > documentation.
> > >
> > > best regards
> > > Tobias Ivarsson
> > >
> > > [1] http://www.jython.org/
> > > [2] http://jpype.sourceforge.net/
> > > [3] http://www.python.org/
> > >
> >
> > Great, as you probably already know we are waiting for the GPLv3 to be
> > released before we release the source for Neo. If my description above
> > wasn't enough I can send you the source code under a proprietary
> > license.
> >
> > --
> > Johan
> > _______________________________________________
> > Neo mailing list
> > User at lists.neo4j.org
> > https://lists.neo4j.org/mailman/listinfo/user
> >
>
>


More information about the User mailing list