Another reflection bug; compatibility results
Stuart Ballard
sballard at netreach.net
Thu Jun 15 11:00:41 PDT 2000
Godmar Back wrote:
>
> Okay, try it again now.
>
> We now also search superinterfaces if you invoke Class.getMethod() on
> an interface class.
Excellent. Kaffe now gives exactly 0 "M" (the NoSuchMethodException) and
only about 7 or 8 "!" (the non-equality) on the whole of its class
libraries. As you point out, it's probably impossible to avoid all "!"s.
Thanks for explaining why I was getting these in the JDK :)
> Also, since there no ordering of superinterfaces, there's also no notion
> of "overriding" - hence both Kaffe and JDK report methods in all
> superinterfaces. However, getMethod will stop looking at the first
> match. This leads (in both JDK and Kaffe) to what you call "Non-equality"
> in your test.
Hmm, okay. That doesn't seem to be a problem for what I'm doing. Since I
only want each distinct method reported once, and I don't care which
class it's defined on (I don't even report that information), I'll
continue to use the inequality test as a way to ensure I don't see any
methods twice. It is safe to assume that two calls to getMethod() with
the same arguments *in the same run of Kaffe* (and without the
possibility of any classes being gc'd) will always return the same
method, right?
> However, I believe that none of this should have an adverse impact
> on the interface compatibility checking you're doing. For instance,
> you should be able to easily figure out what's what by checking whether
> a class inherits a method or not - one way to find that out is to
> check whether getClass().getMethod().getClass() != getClass().
Actually, I don't even care whether it's inherited or not - I just
didn't want the same method showing up twice. I only bothered to put the
check in at all as a workaround for the fact that Kaffe was reporting
overridden methods all the way up, and I wanted to make sure I only got
the "definitive" one. I'm glad I did or I'd never have realized that the
same method could *legitimately* show up twice if it's inherited from
two superinterfaces.
Thanks for your time :)
Stuart.
More information about the kaffe
mailing list