From: <cg...@us...> - 2009-06-03 07:53:06
|
Revision: 6440 http://jython.svn.sourceforge.net/jython/?rev=6440&view=rev Author: cgroves Date: 2009-06-03 07:53:04 +0000 (Wed, 03 Jun 2009) Log Message: ----------- Only add the proxy class for a PyJavaType to the mro once. Fixes issue1363 Modified Paths: -------------- trunk/jython/Lib/test/test_java_subclasses.py trunk/jython/src/org/python/core/PyType.java Modified: trunk/jython/Lib/test/test_java_subclasses.py =================================================================== --- trunk/jython/Lib/test/test_java_subclasses.py 2009-06-02 08:23:27 UTC (rev 6439) +++ trunk/jython/Lib/test/test_java_subclasses.py 2009-06-03 07:53:04 UTC (rev 6440) @@ -225,6 +225,17 @@ self.assertEquals(10, SecondSubclass().callGetValue()) + def test_deep_subclasses(self): + '''Checks for http://bugs.jython.org/issue1363. + + Inheriting several classes deep from a Java class caused inconsistent MROs.''' + from java.lang import Object + class A(Object): pass + class B(A): pass + class C(B): pass + class D(C): pass + d = D() + """ public abstract class Abstract { public Abstract() { Modified: trunk/jython/src/org/python/core/PyType.java =================================================================== --- trunk/jython/src/org/python/core/PyType.java 2009-06-02 08:23:27 UTC (rev 6439) +++ trunk/jython/src/org/python/core/PyType.java 2009-06-03 07:53:04 UTC (rev 6440) @@ -869,6 +869,7 @@ } PyObject[] computeMro(MROMergeState[] toMerge, List<PyObject> mro) { + boolean addedProxy = false; scan : for (int i = 0; i < toMerge.length; i++) { if (toMerge[i].isMerged()) { continue scan; @@ -880,7 +881,7 @@ continue scan; } } - if (!(this instanceof PyJavaType) && candidate instanceof PyJavaType + if (!addedProxy && !(this instanceof PyJavaType) && candidate instanceof PyJavaType && candidate.javaProxy != null && PyProxy.class.isAssignableFrom(((Class<?>)candidate.javaProxy)) && candidate.javaProxy != javaProxy) { @@ -889,6 +890,7 @@ // This exposes the methods from the proxy generated for this class in addition to // those generated for the superclass while allowing methods from the superclass to // remain visible from the proxies. + addedProxy = true; mro.add(PyType.fromClass(((Class<?>)javaProxy))); } mro.add(candidate); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |