Bug #2531
closedReflexive extension functions: synthetic methods
100%
Description
When resolving reflexive extension functions, Saxon makes no attempt to exclude Java synthetic methods from its search. Since a synthetic method can have the same name and argument types as a "real" method on the same class, this can cause the search for a method to fail saying that there is more than one candidate, and insufficient type information to disambiguate them. To demonstrate the problem:
package z;
public interface Foo<T> {
T foo();
}
package z;
public class MyFoo implements Foo<String> {
String foo() { return "foo"; }
}
XSLT:
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:z="java:z.MyFoo"
version="2.0">
<xsl:variable name="my" select="z:new()" />
<xsl:value-of select="z:foo($my)" />
</xsl:stylesheet>
Updated by Michael Kay over 8 years ago
- Status changed from New to Resolved
I have committed a patch to exclude synthetic methods from the search.
Although the problem applies to all previous releases, it has not come up before, and it is hard to be 100% confident that the patch will not cause any regression. I am therefore confining the patch to the 9.7 branch, at least for the time being.
Updated by Michael Kay over 8 years ago
For future reference: the patch is at line 339 of JavaExtensionLibrary, to change:
if (theMethod.getName().equals(methodName) &&
Modifier.isPublic(theMethod.getModifiers())) {
to
if (theMethod.getName().equals(methodName) &&
Modifier.isPublic(theMethod.getModifiers()) &&
!theMethod.isSynthetic()) {
Updated by O'Neil Delpratt over 8 years ago
- Applies to branch 9.7 added
- Fix Committed on Branch 9.7 added
Updated by O'Neil Delpratt about 8 years ago
- % Done changed from 0 to 100
- Fixed in Maintenance Release 9.7.0.2 added
Bug fix applied in the Saxon 9.7.0.2 maintenance release
Updated by O'Neil Delpratt about 8 years ago
- Status changed from Resolved to Closed
Please register to edit this issue