From: <no...@so...> - 2001-02-15 03:26:41
|
Bug #132462, was updated on 2001-Feb-14 19:27 Here is a current snapshot of the bug. Project: Jython Category: Core Status: Open Resolution: None Bug Group: None Priority: 5 Submitted by: ianzsk Assigned to : nobody Summary: jython invokes interface "method" instead actual method Details: This bug seems similar to(but not the same as) bug #122847 Given the following Java code: //----------------------------- package aa; interface Named { String getName(); } public class bug implements Named { public bug() {} public String getName() { return "name"; } } //-------- The following jython (Jython 2.0 on java1.3.0 (JIT: null)) script invokes an IllegalAccessException #!/usr/bin/env jython from aa import bug b=bug() b.getName() # same problem with bean property : b.name Possible resolution: ---------------------------- Assuming that creating PyJavaClass Objects for interfaces is a requirement for jython to work properly (!), the short circuit in PyJavaClass.addPropery() method viz: // If this adds nothing over old property, do nothing if ((prop.getMethod == null || oldProp.getMethod != null) && (prop.setMethod == null || oldProp.setMethod != null)) should be replace with: boolean nogetOverride=(oldProp.getMethod != null && !Modifier.isAbstract(oldProp.getMethod.getModifiers()) ); boolean nosetOverride =(oldProp.setMethod != null && !Modifier.isAbstract(oldProp.setMethod.getModifiers()) ); if ((prop.getMethod == null || nogetOverride ) && (prop.setMethod == null || nogetOverride ) ) { set = false; } // Add old get/set methods to current prop // Handles issues with private classes if (nogetOverride) { prop.getMethod = oldProp.getMethod; } if (nosetOverride) { prop.setMethod = oldProp.setMethod; } i.e. override if it is abstract. I also changed the code at the bottom of ReflectedArgs.compareTo() method to: // For static methods, use the child's version // For instance methods, use the parent's version if (!isStatic && ( other.declaringClass.getModifiers() & (Modifier.INTERFACE))==0 ) replace = !replace; These two changes at least fix the problem above, but are not maybe the most general solution. For detailed info, follow this link: http://sourceforge.net/bugs/?func=detailbug&bug_id=132462&group_id=12867 |