jetty.project
jetty.project copied to clipboard
XmlConfiguration should prefer exact class match rather than interface match
trafficstars
jetty-12
When matching xml to class methods to satisfy a <Call> clause, the code currently prefers matching an argument that is an interface rather than an exact class type match.
In other words, given the following java code:
public class Example
{
interfact TestInterface {}
public class TestImpl implements TestInterface {}
public static void callStaticWithVarArgs(TestInterface i, String... strings)
{
}
public static void callStaticWithVarArgs(TestImpl i, String... strings)
{
}
}
And given the following xml:
<Call class="Example" name="callStaticWithVarArgs">
<Arg>
<New class="Example$TestImpl"/>
</Arg>
<Arg>
<Array type="java.lang.String">
<Item>A</Item>
<Item>B</Item>
<Item>C</Item>
</Array>
</Arg>
</Call>
The method callStaticWithVarArgs(TestInterface i, String... strings) is ranked higher than the alternative method - which is actually an exact match - and thus selected.
I think this fix probably introduced the behaviour where interface args are preferenced: https://github.com/jetty/jetty.project/issues/10143
Fixed via #11901