A ClassCastException may occur at compile time (during type checking) when a comparison or arithmetic operator is applied to the result of an external (Java or .NET) function call.
The problem occurs when the declared result type of the underlying method is not a type that can be converted to an XPath atomic value.
The problem is compounded in .NET because the static type inferencing for external function calls does not correctly identify cases where the underlying method returns a value that can be converted to an XPath atomic value. The problem will therefore occur with an expression such as (f:f() = 2) or (f:f() eq 2) or (f:f() + 2) even in cases where f:f() returns an integer.
Patches affecting modules ValueComparison, GeneralComparison, ArithmeticExpression, and DotNetExtensionFunctionCall are being placed in Subversion.