Re: MRO theory



On Apr 11, 3:26 pm, "Clarence" <clarence1...@xxxxxxxxx> wrote:
No, there is no circularity. The problem is coming about in the JPype
application. It creates a Python class to proxy any Java class or Java
interface that the program uses (directly or indirectly). As far as
the
Java proxies go, when it creates a class it can have at most one
superclass
that is a proxy of a Java class, and arbitrarily many superclasses
which
are proxies of Java interfaces.

The problem basically comes about because interfaces are not classes,
but a class is being created to stand in for each one.

Yes. In Java, because there's no possibility of conflicting methods,
interfaces can be listed in any order. But when proxying Java classes
with Python, the order of interfaces becomes important.

There is real Java code that is causing a class construction failure
because of an inability to construct a consistent mro. I've tried
several
approaches to make it work, and by accident, sorting the list of
interface
proxy classes, using the default comparison, make it work.

It *might* not be an accident.

Because Java interfaces can be listed in any order, it's quite
possible that some interface hierarchies in Java violate Python's MRO
restrictions right out of the box. I would guess that JPype deals
with this situation by applying a consistent ordering to of bases when
it creates a proxy class. And it just might turn out that "order of
creation" is the sort key. Or something else could be the key
(alphabetical by name?). Regardless, sorted order just *might* be the
proper order to list bases to ensure MRO consistency.

Or I could be way off base.

I'd suggest that this is probably a question better answered on the
JPype mailing list, since they would have answers and not just
speculations.


That made
me
wonder if the theory had something to say. Obviously, if class A is
created
before class B, then B cannot be a base class of A, hence the
chronological
order of class creation _might_ have something to do with creating
acceptable
or unacceptable mro's.

I doubt it "happens" to work that way. If sorting the bases works in
general, it's probably deliberate.


Carl Banks

.



Relevant Pages

  • Re: dynamic type checking - a pauline conversion?
    ... to actually write the code in Java. ... Is the query handled ... One of the problems with Java typing is small differences in interfaces ... array iteration, List iteration, and database query result iteration all ...
    (comp.object)
  • Re: CLOS Properties Question
    ... In interfaces, you can declare methods, but you ... This mess was the result of the fact that interfaces ... > is even an OOPSLA or ECOOP paper published before the advent of Java ... > Back to the question what this all has to do with multiple inheritance: ...
    (comp.lang.lisp)
  • Re: Python vs C for a mail server
    ... that is mostly unnecessary with Python. ... > I don't have enough experience with languages that provide interfaces, ... > such as Java, to understand how useful they are, but it's my impression ... I can't comment on "most Java APIs", but if you look at established ...
    (comp.lang.python)
  • Re: Java "interface" vs. OO interface
    ... > I think Java uses interfaces instead of classes because the designers ... To think that the designers of Java and .NET couldn't figure out a good ... Enough for a language to adopt a new keyword ...
    (comp.object)
  • Re: what to do with java.lang.reflect.Proxy ???
    ... > The main drawback I see with Proxy, is that I should re-engineer alot ... implementing MouseWheelListener can be used to support the ... mouse wheel on Java 1.4, for code that must also run on Java 1.3. ... I've seen stubs that ...
    (comp.lang.java.programmer)