java.lang.IllegalArgumentException: Unknown kind of CharSequence
Reported by Gerrit Imsieke on the saxon-help list.
Internally, the problem occurs when appending a java.lang.StringBuffer to a net.sf.saxon.tree.tiny.LargeStringBuffer.
In the particular instance, the StringBuffer was constructed by the Unicode normalization library as a result of a call to normalize-unicode(). The problem in this case can be suppressed by disabling byte code generation, but that's accidental; in principle, it could occur on many other paths.
The primary solution is to allow LargeStringBuffer.append() to accept any kind of CharSequence, which is easily achieved by converting the supplied CharSequence (if of an unrecognized class) to a String.
Better performance can be obtained by converting the Unicode normalization library to use Saxon's FastStringBuffer in place of the standard Java StringBuffer.
A patch for 9.4 is being raised which will make the first change only. The second change will be made in the development branch.