Project

Profile

Help

Bug #3525

closed

Reflexive extension function returning byte[]

Added by Michael Kay over 6 years ago. Updated over 6 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
Saxon extensions
Sprint/Milestone:
-
Start date:
2017-11-14
Due date:
% Done:

100%

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

Description

When a reflexive extension function has a return type of byte[], the values are converted to XPath xs:integer instances in the range 0-255: that is, the bytes are treated as unsigned. This is not the case if the return type is simply byte or Byte. Moreover, the return values are annotated as instances of xs:byte, which is incorrect in the case of values such as 255, because these are outside the range of an xs:byte.

The problem is exposed by the extension functions saxon:hexBinary-to-octets and saxon:base64Binary-to-octets, which are implemented as reflexive extension functions with a declared return type of byte[], yet are documented to return a sequence of integers in the range 0-255. These integers are incorrectly annotated as xs:byte instances; moreover it seems the static type inferencing assumes a static type of xs:byte*.

Note there is a danger that changing the behaviour here could break existing applications.


Related issues

Related to Saxon - Bug #3818: Reflexive java functions vs byte arraysClosedMichael Kay2018-06-12

Actions
Actions #1

Updated by Michael Kay over 6 years ago

  • Status changed from New to In Progress

I think that in the interests of avoiding disruption to existing applications, we should make the rule that a value of byte[] returned from Java maps to a sequence of xs:unsignedByte in XPath, that is, a sequence of integers in the range 0-255 labelled as instances of xs:unsignedByte. For a return type of byte or Byte we retain the mapping to a singleton (signed) xs:byte.

Actions #2

Updated by Michael Kay over 6 years ago

  • Applies to branch 9.8, trunk added
  • Fix Committed on Branch 9.8, trunk added

I have fixed JPConverter.FromByteArray() on the 9.8 and trunk branches to annotate the result items as xs:unsignedByte rather than xs:byte.

Changes to the documentation remain to be made.

Actions #3

Updated by Michael Kay over 6 years ago

  • Status changed from In Progress to Resolved

I have committed changes to the 9.8 and trunk documentation to describe how results of type byte[] are handled.

I have added test cases for hexBinaryToOctets to the xslt30extra test suite.

Actions #4

Updated by Debbie Lockett over 6 years ago

Documentation updated online (XML and HTML versions).

Actions #5

Updated by O'Neil Delpratt over 6 years ago

  • % Done changed from 0 to 100

Bug fix applied in the Saxon 9.8.0.7 maintenance release.

Actions #6

Updated by O'Neil Delpratt over 6 years ago

  • Status changed from Resolved to Closed
  • Fixed in Maintenance Release 9.8.0.7 added
Actions #7

Updated by Michael Kay almost 6 years ago

  • Related to Bug #3818: Reflexive java functions vs byte arrays added

Please register to edit this issue

Also available in: Atom PDF