This content has been marked as final.
Show 4 replies
-
1. Re: dispatch algorithm limitation
tar Oct 27, 2004 5:49 AM (in response to tar)Sorry the layout may be a little confussing... here is the right layout.
We can read this at the end of the tutorial :The compiler does not correctly implement the Java method dispatch algorithm. The compiler may confuse if methods defined in a class have the same name but take different parameter lists.
what it really mean ?
I construct (with javassist) a new class with a new method which call a method 'foo(...)'. Two methods 'foo' are implemented in a other class which i defined in a classic way (with my IDE). One accept a Java.lang.Object as argument and the other accept a java.lang.String as argument.
I understand that javassist might produce bytecode that call foo(String) instead of foo(Object) or foo(Object) instead of foo(String).
Is it correct ? How can i recognize such case ? This limitation still exist in javassist v3 ?
Thanks in advance. -
2. Re: dispatch algorithm limitation
chiba Nov 1, 2004 2:31 AM (in response to tar)There still exits that bug. The compiler may produce a wrong call in
the following case:
class A {}
class B extends A {}
class C extends C {}
class X {
void foo(A a) { .. }
void foo(B b) { .. }
}
If you call foo(new C()) on an instance of X, the compiler may produce
a call to foo(A). But the compiler correctly compile foo((B)new C()).
I haven't implemented a correct type inferencing algorithm yet. -
3. Re: dispatch algorithm limitation
tar Nov 3, 2004 7:46 AM (in response to tar)Thanks!
I think you should include those few lines into the tutorial. It may help users. -
4. Re: dispatch algorithm limitation
chiba Nov 3, 2004 10:04 AM (in response to tar)Thanks, you're right.