Project

Profile

Help

Bug #2531

closed

Reflexive extension functions: synthetic methods

Added by Michael Kay over 8 years ago. Updated about 8 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
Saxon extensions
Sprint/Milestone:
-
Start date:
2015-12-07
Due date:
% Done:

100%

Estimated time:
Legacy ID:
Applies to branch:
9.7
Fix Committed on Branch:
9.7
Fixed in Maintenance Release:
Platforms:

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> 
Actions #1

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.

Actions #2

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()) {
Actions #3

Updated by O'Neil Delpratt over 8 years ago

  • Applies to branch 9.7 added
  • Fix Committed on Branch 9.7 added
Actions #4

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

Actions #5

Updated by O'Neil Delpratt about 8 years ago

  • Status changed from Resolved to Closed

Please register to edit this issue

Also available in: Atom PDF