Thanks very much to both of you for the help, but with the new copy.py I'm getting an error:
raise Error('un-deep-copyable object of type %s' % type(x))
copy.Error: un-deep-copyable object of type <class 'testClass.testClass'>
testClass in this case is a very simple class containing only a single integer. Any ideas why this might be happening? I can give my code if it will help.
Yes, there is an issue with the current version of copy.py that is being distributed with 2.5.1. You can read more about the issue on the bug tracker at http://bugs.jython.org/issue1551...but it specifically addresses issues while making copies of Java objects using copy() and deepcopy(). I am going to be checking in the attached version of copy.py which has been corrected to address the issues related to the bug report. There is also an effort taking place to convert the current version of copy.py into a Java implementation to help boost performance a bit. Please stay tuned for that version sometime in the future.If you have a moment, please drop the attached version of copy.py into your jython Lib directory and give it a try. Hopefully it will resolve your issues. If it does not, please submit another bug or add onto issue 1551.ThanksJosh Juneau
Twitter ID: javajuneau
On Mon, Mar 8, 2010 at 1:49 PM, Barbalute <Barbalute@gmail.com> wrote:
As the name suggests, it seems that copy and deepcopy aren't copying the
variables in my Java class.
I currently have a Python class extending an existing Java abstract class.
For various reasons, I've overwritten clone() in the Python class so that
when the Java class calls it, it returns a deepcopy() of itself.
This seems to properly copy the methods from the class, but the variables
from the abstract Java class are lost in the copy, and I have no idea why.
In the overwritten Python clone() method, I'm able to manually copy over the
variables, doing for example:
x = copy.deepcopy(self)
x.name = self.name
But this shouldn't be necessary and becomes increasingly unwieldy for
classes with lots of variables. If I don't do it, though, name is not set in
x and will return null in Java. Am I doing something wrong, or is something
broken with copy() and deepcopy()?
Thanks for your time.
View this message in context: http://old.nabble.com/copy-and-deepcopy-not-copying-Java-class-variables--tp27826254p27826254.html
Sent from the jython-users mailing list archive at Nabble.com.
Download Intel® Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
Jython-users mailing list