Message282

Author ianzsk
Recipients
Date 2001-02-15.03:27:18
SpamBayes Score
Marked as misclassified
Message-id
In-reply-to
Content
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. 
History
Date User Action Args
2008-02-20 17:16:48adminlinkissue232462 messages
2008-02-20 17:16:48admincreate