From: <pj...@us...> - 2009-06-04 02:22:35
|
Revision: 6444 http://jython.svn.sourceforge.net/jython/?rev=6444&view=rev Author: pjenvey Date: 2009-06-04 01:41:03 +0000 (Thu, 04 Jun 2009) Log Message: ----------- fix subclasses getter properties being disabled when it has a setter and the parent only has a setter thanks doublep fixes #1333 Modified Paths: -------------- trunk/jython/Lib/test/test_java_integration.py trunk/jython/src/org/python/core/PyJavaType.java Added Paths: ----------- trunk/jython/tests/java/org/python/tests/Child2.java Modified: trunk/jython/Lib/test/test_java_integration.py =================================================================== --- trunk/jython/Lib/test/test_java_integration.py 2009-06-04 01:35:46 UTC (rev 6443) +++ trunk/jython/Lib/test/test_java_integration.py 2009-06-04 01:41:03 UTC (rev 6444) @@ -20,7 +20,7 @@ from javax.swing.tree import TreePath from org.python.core.util import FileUtil -from org.python.tests import BeanImplementation, Child, Listenable, CustomizableMapHolder +from org.python.tests import BeanImplementation, Child, Child2, Listenable, CustomizableMapHolder from org.python.tests.mro import (ConfusedOnGetitemAdd, FirstPredefinedGetitem, GetitemAdder) class InstantiationTest(unittest.TestCase): @@ -75,6 +75,13 @@ c.id = 16 self.assertEquals(16, c.id) + def test_inheriting_half_bean_issue1333(self): + # http://bugs.jython.org/issue1333 + c = Child2() + self.assertEquals("blah", c.value) + c.value = "bleh" + self.assertEquals("Child2 bleh", c.value) + def test_awt_hack(self): # We ignore several deprecated methods in java.awt.* in favor of bean properties that were # addded in Java 1.1. This tests that one of those bean properties is visible. Modified: trunk/jython/src/org/python/core/PyJavaType.java =================================================================== --- trunk/jython/src/org/python/core/PyJavaType.java 2009-06-04 01:35:46 UTC (rev 6443) +++ trunk/jython/src/org/python/core/PyJavaType.java 2009-06-04 01:41:03 UTC (rev 6444) @@ -420,10 +420,11 @@ // up, it'll be rejected below if (prop.setMethod == null) { prop.setMethod = superProp.setMethod; - } else if (superProp.myType == prop.setMethod.getParameterTypes()[0]) { - // Otherwise, we must not have a get method. Only take a get method if the type - // on it agrees with the set method we already have. The bean on this type - // overrides a conflicting one o the parent + } else if (prop.getMethod == null + && superProp.myType == prop.setMethod.getParameterTypes()[0]) { + // Only take a get method if the type on it agrees with the set method + // we already have. The bean on this type overrides a conflicting one + // of the parent prop.getMethod = superProp.getMethod; prop.myType = superProp.myType; } Added: trunk/jython/tests/java/org/python/tests/Child2.java =================================================================== --- trunk/jython/tests/java/org/python/tests/Child2.java (rev 0) +++ trunk/jython/tests/java/org/python/tests/Child2.java 2009-06-04 01:41:03 UTC (rev 6444) @@ -0,0 +1,13 @@ +package org.python.tests; + +public class Child2 extends Parent { + + public String getValue() { + return value; + } + + @Override + public void setValue(String value) { + this.value = "Child2 " + value; + } +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |