Issue222817

classification
Title: In subclassing, Java 'long' is converted to python integer n
Type: Severity: normal
Components: Core Versions:
Milestone:
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: bckfnn
Priority: low Keywords:

Created on 2000-11-18.19:10:25 by bckfnn, last changed 2000-11-18.22:31:27 by bckfnn.

Messages
msg74 (view) Author: Finn Bock (bckfnn) Date: 2000-11-18.19:10:25
In Java:

public interface NotifHandler {
	public void handleRemove(long start);
}

In JPython:
class MyHandler(NotifHandler):
	def handleRemove(start):
		print "Start: "+`start`

When the handleRemove method is called on a JPython object from Java for 
a long value of 4294967295, JPython object printed -1

Here is the fix suggested by Hugunin, Jim:

This is a bug in the proxy class implementation.  It should be fixed for the
next release (though you might want to file an official bug report to be sure it
doesn't slip through the cracks).

Here are a few pointers to anyone who wants to fix this bug.  If you're willing
to recompile from source, you can fix by making the following change to
compiler\ProxyMaker.java:

In method:    public void getArgs(Code code, Class[] parameters)
around line 366:

                case tLong:
                    code.lload(local_index);
                    local_index += 2;

                    int newInteger1 = code.pool.Methodref(
                        "org/python/core/Py",
                        "newInteger", "(J)Lorg/python/core/PyInteger;");
                    code.invokestatic(newInteger1);
                    break;

Change the middle line to:

                        "newInteger", "(J)Lorg/python/core/PyObject;");

And then go into core\Py.java and edit the newInteger(long l) method to have the
correct signature and to do a range check on it's argument and return a PyLong
if it's too bug to fit in an int.  An alternative would be to have that function
always return a PyLong, but I'm afraid that might break some reasonable existing
code.

You should probably also grep through the code looking for newInteger to make
sure that this change doesn't break anything else.

-Jim
msg75 (view) Author: Finn Bock (bckfnn) Date: 2000-11-18.22:31:27
The suggested fix is implemented.
History
Date User Action Args
2000-11-18 19:10:25bckfnncreate