Project

Profile

Help

Bug #4730

closed

ClassCastException: net.sf.saxon.expr.instruct.CopyOf cannot be cast to net.sf.saxon.expr.AxisExpression

Added by Michael Kay about 4 years ago. Updated about 4 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
Internals
Sprint/Milestone:
-
Start date:
2020-09-11
Due date:
% Done:

100%

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

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

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.

Actions #2

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

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.

Actions #4

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.

Actions #5

Updated by O'Neil Delpratt about 4 years ago

Bug fix applied in the Saxon 10.3 maintenance release

Actions #6

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

Also available in: Atom PDF