[rfc][icedtea-web] LiveConnect Method Overload Resolver Fix

Jie Kang jkang at redhat.com
Mon Jun 23 15:51:18 UTC 2014



----- Original Message -----
> On Mon, Jun 23, 2014 at 10:44 AM, Jiri Vanek <jvanek at redhat.com> wrote:
> > CC Adam as original author. Also he accidentaly proved he is still "Alive
> > out there" So W ecanhope to catch him :)
> 
> Well, original refactorer :-)
> 
> > On 06/20/2014 04:22 PM, Jie Kang wrote:
> >>
> >> Hello,
> >>
> >> When refactoring the LiveConnect tests I discovered a bug in the
> >> MethodOverloadResolver implementation where choosing the correct
> >> superclass
> >> did not take into account the hierarchy distance. This was causing
> >> JSToJFuncResolTest - AppletJSToJFuncResol_inheritedClassToParent1_Test to
> >> fail intermittently.
> >>
> >> E.g.
> >>
> >> A extends B extends C : Object of Type C is passed as argument to function
> >> that accepts either Type A or Type B objects. As per LiveConnect and Java
> >> specification, the correct resolution of this is to use the function that
> >> accepts Type B. However, the implementation of MethodOverloadResolver did
> >> not comply with this and nearly always used the Type A function (both Type
> >> A
> >> and Type B functions were scored equally and the choice of use depended on
> >> the order of comparison, which is not always the same).
> >>
> >> The patch resolves this issue by following LiveConnect specification
> >> located here:
> >> https://jdk6.java.net/plugin2/liveconnect/#OVERLOADED_METHODS
> >> where a distance calculation for class hierarchy is used to resolve the
> >> issue. It also removes the Known to Fail annotation for the test case
> >> which
> >> should no longer fail.
> 
> I just skimmed it, but it looks good to me. Only small nit is that
> lowestDistance is not always strictly true since lowestCost is the
> first criteria.

You are right about this but I can't think of a better name for it. Any suggestions?;;


I've also made a small fix to the function: classDistance
The while loop is no longer while(true) and is better code.

Changelog below:

2014-06-20  Jie Kang  <jkang at redhat.com>

    Made adjustments to the MethodOverloadResolver to follow LiveConnect
    specification when dealing with superclasses.
    * tests/reproducers/simple/JSToJFuncResol/testcases/JSToJFuncResolTest.java:
    Removed Known to Fail annotation on test case that is now fixed.
    * plugin/icedteanp/java/sun/applet/MethodOverloadResolver.java
    Added distance calculation for comparing superclass resolutions.


Thanks for the review.


> 
> Thanks for the fix,
> -Adam
> 
> >>
> >>
> >> Regards,
> >>
> >> --
> >> Jie Kang
> >>
> >
> 

-- 
--
Jie Kang
-------------- next part --------------
A non-text attachment was scrubbed...
Name: liveconnect-methodoverload-2.patch
Type: text/x-patch
Size: 4051 bytes
Desc: not available
URL: <http://mail.openjdk.java.net/pipermail/distro-pkg-dev/attachments/20140623/48e11019/liveconnect-methodoverload-2.patch>


More information about the distro-pkg-dev mailing list