Message991
Obviously, the jikes compiler outputs different byte code
than javac. I was using jikes 1.21 to build jython 2.2a2 as
of 2005-06-18, and noticed that isinstance(2.0, float)
returned 0. This only happens with jikes and could
indicate a bug in the project (or in jikes, but that is more
unlikely).
After some debugging I found out where things differ. In
Py.isInstance..
if (cls instanceof PyType) {
PyType objtype = obj.getType();
=> if (objtype == cls)
return true;
return objtype.isSubType((PyType) cls);
} else if (cls instanceof PyClass) {
.. the identity check fails with jikes, while it passes with
javac. So somehow, with jikes, there are two instances of
PyType for PyFloat.
Looking in PyFloat one see it caches its PyType..
private static final PyType FLOATTYPE = PyType.
fromClass(PyFloat.class);
.. and submits it to the PyObject constructor..
public PyFloat(double v) {
super(FLOATTYPE);
value = v;
}
.. so that the default constructor in PyObject doesn't
have to look it up on each instantiation. If I comment out
super(FLOATTYPE) above, everything works again. But
since I find the caching sound I don't want to do that.
What's even more strange is that PyInteger does the
exact same caching, but isinstance(2, int) works just
fine.
The real bug it seems to me, is that PyType.
fromClass(PyFloat.class) can return different objects
when it is supposed not to. After looking at it though, I
can't figure out what might go wrong.
...johahn |
|
Date |
User |
Action |
Args |
2008-02-20 17:17:23 | admin | link | issue1230210 messages |
2008-02-20 17:17:23 | admin | create | |
|