On Fri, 27 Dec 2002 14:32:09 +0100 Benja Fallenstein <[EMAIL PROTECTED]> wrote:
Hi Benja, > a few months ago, Vesa Kaihlavirta wrote you about a problem with Kaffe > and Jython (in both the CVS and 1.0.7 versions). Unfortunately, nobody > was able to work out what the bug really was. It still exists in the > current CVS version (updated today). Fortunately, I think I may have > succeeded in making it shallow. > > Vesa's original mail is at: > http://www.kaffe.org/pipermail/kaffe/2002-September/008910.html thanks that you took the time to have a look at this. > It seems that the bug is with kaffe's handling of reflected virtual > methods. The following code: > > > import java.lang.reflect.Method; > > interface KaffeBugInterface { > void sayHi(); > } > > public class KaffeBug implements KaffeBugInterface { > public void sayHi() { > System.out.println("Hi"); > } > > public static void main(String[] argv) throws Exception { > KaffeBug kb = new KaffeBug(); > kb.sayHi(); > > Method m = KaffeBugInterface.class.getMethod("sayHi", > new Class[0]); > m.invoke(kb, new Object[0]); > } > } > > gives the expected output on IBM's Java 1.3.1, > > benja@joy:~/gzz/bug$ /home/benja/IBMJava2-131/bin/java KaffeBug > Hi > Hi > > but fails with Kaffe: > > benja@joy:~/gzz/bug$ /usr/local/kaffe/bin/kaffe KaffeBug > Hi > java.lang.reflect.InvocationTargetException: > java.lang.CloneNotSupportedException: KaffeBug > at java.lang.Object.clone(Object.java:native) > at java.lang.reflect.Method.invoke0(Method.java:native) > at java.lang.reflect.Method.invoke(Method.java:256) > at KaffeBug.main(KaffeBug.java:18) > > It seems like Kaffe calls the wrong method in cases like this, here > 'clone()' instead of 'sayHi()'. It doesn't always seem to be 'clone()', > though; using the Jython interpreter, it seems that calling 'length()' > on a java.lang.String object invokes 'equals()' instead: With that nice test case of yours, I was able to track this bug down and hopefully also fix it. The problem was that kaffe did not choose the correct entry in the dispatch table of the object when calling interface methods via reflection or jni. With the attached patch applied to kaffe CVS, your test case works fine, but would you be so kind to check whether it fixes your problems with jython, too? Greetings, Helmer
interface-call-patch
Description: Binary data
