#392 IllegalStateException: variable not fixed up

Michael Kay

An exception can occur reporting

java.lang.IllegalStateException: Variable $zz:NNNNNN
has not been fixed up

Source code fix: in net.sf.saxon.VariableReference,
line 189, delete the line that reads:

binding = null;


Under certain circumstances, Saxon decides to replace
variable references by the expressions to which they
refer. This happens most commonly where the expression
in question is another variable reference, for example
the construct

let $x := $y return $x * $x

is replaced by

return $y * $y

In this situation an expression can appear at more than
one node in an expression tree (in fact, the expression
tree is no longer a tree, it is an acyclic graph).

The code affected by this patch is executed when the
variable reference $x is replaced (here, by $y). Saxon
is setting binding to null here solely to help the
garbage collector get rid of unused expression objects:
the thinking is that $x is no longer used so it can
safely be tidied up. However, this ignores the fact
that the two references to $x might actually be the
same VariableReference object, and that setting the
binding to null will cause an error (the
IllegalStateException described above) when this
VariableReference is later reached by another route.

Test case: qxmp291

Michael Kay


Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.

No, thanks