Bug #4730
closedClassCastException: net.sf.saxon.expr.instruct.CopyOf cannot be cast to net.sf.saxon.expr.AxisExpression
100%
Description
See https://saxonica.plan.io/boards/3/topics/7998
In a rather complicated setup of using XSLT to transform a Schematron schema to streamable XSLT and then run that against an input document to be validated against the Schematron schema I run into a java.lang.ClassCastException: net.sf.saxon.expr.instruct.CopyOf cannot be cast to net.sf.saxon.expr.AxisExpression
with both Saxon 10.2 EE and 9.9.1.7 EE.
The stack trace is
java.lang.ClassCastException: net.sf.saxon.expr.instruct.CopyOf cannot be cast to net.sf.saxon.expr.AxisExpression
at net.sf.saxon.expr.SlashExpression.lambda$iterate$0(SlashExpression.java:948)
at net.sf.saxon.expr.MappingIterator.next(MappingIterator.java:60)
at net.sf.saxon.om.SequenceIterator.forEachOrFail(SequenceIterator.java:135)
at net.sf.saxon.expr.Expression.process(Expression.java:949)
.....
Updated by Michael Kay about 4 years ago
Problem reproduced.
In the path expression on line 33, the .../node()
has been rewritten as .../copy-of(node())
, as part of the process of generating a streamable execution plan. The node will be copied because it's being transferred to a new parent at line 37, and so this makes the copy explicit because that makes the streamability analysis work. But the path expression has a flag contextFree
set; this is set when it's possible to evaluate the rhs of the path expression without creating a new context, but it assumes the rhs will be an AxisStep
.
Updated by Michael Kay about 4 years ago
- Status changed from New to In Progress
The simplest fix seems to be to change SlashExpression line 946 from
if (contextFree) {
to
if (contextFree && step instanceof AxisExpression) {
Updated by Michael Kay about 4 years ago
I haven't been able to trigger a failure in the bytecode compilation path, but it's making the same assumption that if contextFree
is set, the rhs will be an AxisExpression, so I'm applying the same fix on that path.
Updated by Michael Kay about 4 years ago
- Status changed from In Progress to Resolved
- Fix Committed on Branch 10, trunk added
Patched on 10 and development branches.
Bytecode change is regression-tested only.
Updated by O'Neil Delpratt about 4 years ago
Bug fix applied in the Saxon 10.3 maintenance release
Updated by O'Neil Delpratt about 4 years ago
- Status changed from Resolved to Closed
- % Done changed from 0 to 100
- Fixed in Maintenance Release 10.3 added
Please register to edit this issue