Buggy code:
public class Writer extends XMLDocumentParser implements XMLErrorHandler { protected static final String NAMESPACES_FEATURE_ID = "http:////xml.org//sax//features//namespaces" ; protected static final String VALIDATION_FEATURE_ID = "http:////xml.org//sax//features//validation" ; protected static final String SCHEMA_VALIDATION_FEATURE_ID = "http:////apache.org//xml//features//validation//schema" ; protected static final String SCHEMA_FULL_CHECKING_FEATURE_ID = "http:////apache.org//xml//features//validation//schema-full-checking" ; protected static final String DEFAULT_PARSER_CONFIG = "org.apache.xerces.parsers.StandardParserConfiguration" ; protected static final boolean DEFAULT_NAMESPACES = true ; protected static final boolean DEFAULT_VALIDATION = false ; protected static final boolean DEFAULT_SCHEMA_VALIDATION = false ; protected static final boolean DEFAULT_SCHEMA_FULL_CHECKING = false ; protected static final boolean DEFAULT_CANONICAL = false ; protected static final boolean DEFAULT_INCREMENTAL = false ; protected PrintWriter fOut ; protected boolean fCanonical ; protected int fElementDepth ; protected boolean fSeenRootElement ; public Writer ( XMLParserConfiguration configuration ) { } public void setCanonical ( boolean canonical ) { } public void setOutput ( OutputStream stream , String encoding ) throws UnsupportedEncodingException { } public void setOutput ( java . io . Writer writer ) { } public void startDocument ( XMLLocator locator , String encoding , Augmentations augs ) throws XNIException { } public void startElement ( QName element , XMLAttributes attrs , Augmentations augs ) throws XNIException { } public void emptyElement ( QName element , XMLAttributes attrs , Augmentations augs ) throws XNIException { } public void processingInstruction ( String target , XMLString data , Augmentations augs ) throws XNIException { } public void comment ( XMLString text , Augmentations augs ) throws XNIException { if ( ! ( fCanonical ) ) { if ( ( fSeenRootElement ) && ( ( fElementDepth ) == 0 ) ) { fOut . print ( '\n' ) ; } fOut . print ( "<!--" ) ; <START_BUG> normalizeAndPrint ( text ) ; <END_BUG> fOut . print ( "-->" ) ; if ( ! ( fSeenRootElement ) ) { fOut . print ( '\n' ) ; } fOut . flush ( ) ; } } public void characters ( XMLString text , Augmentations augs ) throws XNIException { } public void ignorableWhitespace ( XMLString text , Augmentations augs ) throws XNIException { } public void endElement ( QName element , Augmentations augs ) throws XNIException { } public void startCDATA ( Augmentations augs ) throws XNIException { } public void endCDATA ( Augmentations augs ) throws XNIException { } public void processingInstruction ( String target , XMLString data ) throws XNIException { } public void comment ( XMLString text ) throws XNIException { } public void warning ( String domain , String key , XMLParseException ex ) throws XNIException { } public void error ( String domain , String key , XMLParseException ex ) throws XNIException { } public void fatalError ( String domain , String key , XMLParseException ex ) throws XNIException { } protected void normalizeAndPrint ( String s ) { } protected void normalizeAndPrint ( XMLString text ) { } protected void normalizeAndPrint ( char c ) { } protected void printError ( String type , XMLParseException ex ) { } public static void main ( String [ ] argv ) { } private static void printUsage ( ) { } }

Fix:
fOut . print ( text . toString ( ) ) ;