Buggy code:
scanPIData ( target , fString ) ; } else { scanXMLDeclOrTextDecl ( false ) ; } } fCurrentEntity . mayReadChunks = true ; return true ; } catch ( EOFException e ) { reportFatalError ( "PrematureEOF" , null ) ; throw e ; } } } protected final class PrologDispatcher implements Dispatcher { public boolean dispatch ( boolean complete ) throws IOException , XNIException { try { boolean again ; do { again = false ; switch ( fScannerState ) { case XMLDocumentScannerImpl . SCANNER_STATE_PROLOG : { fEntityScanner . skipSpaces ( ) ; if ( fEntityScanner . skipChar ( '<' ) ) { setScannerState ( SCANNER_STATE_START_OF_MARKUP ) ; again = true ; } else if ( fEntityScanner . skipChar ( '&' ) ) { setScannerState ( SCANNER_STATE_REFERENCE ) ; again = true ; } else { setScannerState ( SCANNER_STATE_CONTENT ) ; again = true ; } break ; } case SCANNER_STATE_START_OF_MARKUP : { ( fMarkupDepth ) ++ ; if ( fEntityScanner . skipChar ( '?' ) ) { setScannerState ( SCANNER_STATE_PI ) ; again = true ; } else if ( fEntityScanner . skipChar ( '!' ) ) { if ( fEntityScanner . skipChar ( '-' ) ) { if ( ! ( fEntityScanner . skipChar ( '-' ) ) ) { reportFatalError ( "InvalidCommentStart" , null ) ; } setScannerState ( SCANNER_STATE_COMMENT ) ; again = true ; } else if ( fEntityScanner . skipString ( "DOCTYPE" ) ) { setScannerState ( SCANNER_STATE_DOCTYPE ) ; again = true ; } else { reportFatalError ( "MarkupNotRecognizedInProlog" , null ) ; } } else if ( XMLChar . isNameStart ( fEntityScanner . peekChar ( ) ) ) { setScannerState ( SCANNER_STATE_ROOT_ELEMENT ) ; setDispatcher ( fContentDispatcher ) ; return true ; } else { reportFatalError ( "MarkupNotRecognizedInProlog" , null ) ; } break ; } case SCANNER_STATE_COMMENT : { scanComment ( ) ; setScannerState ( XMLDocumentScannerImpl . SCANNER_STATE_PROLOG ) ; break ; } case SCANNER_STATE_PI : { scanPI ( ) ; setScannerState ( XMLDocumentScannerImpl . SCANNER_STATE_PROLOG ) ; break ; } case SCANNER_STATE_DOCTYPE : { if ( fSeenDoctypeDecl ) { reportFatalError ( "AlreadySeenDoctype" , null ) ; } fSeenDoctypeDecl = true ; if ( scanDoctypeDecl ( ) ) { setScannerState ( XMLDocumentScannerImpl . SCANNER_STATE_DTD_INTERNAL_DECLS ) ; setDispatcher ( fDTDDispatcher ) ; return true ; } if ( ( ( fDoctypeSystemId ) != null ) && ( ( ( fValidation ) || ( fLoadExternalDTD ) ) && ( ( ( fValidationManager ) == null ) || ( ! ( fValidationManager . isCachedDTD ( ) ) ) ) ) ) { setScannerState ( XMLDocumentScannerImpl . SCANNER_STATE_DTD_EXTERNAL ) ; setDispatcher ( fDTDDispatcher ) ; return true ; } setScannerState ( XMLDocumentScannerImpl . SCANNER_STATE_PROLOG ) ; break ; } case SCANNER_STATE_CONTENT : { reportFatalError ( "ContentIllegalInProlog" , null ) ; fEntityScanner . scanChar ( ) ; } case SCANNER_STATE_REFERENCE : { reportFatalError ( "ReferenceIllegalInProlog" , null ) ; } } } while ( complete || again ) ; if ( complete ) { if ( ( fEntityScanner . scanChar ( ) ) != '<' ) { reportFatalError ( "RootElementRequired" , null ) ; } setScannerState ( SCANNER_STATE_ROOT_ELEMENT ) ; setDispatcher ( fContentDispatcher ) ; } } catch ( EOFException e ) { reportFatalError ( "PrematureEOF" , null ) ; throw e ; } return true ; } } protected final class DTDDispatcher implements Dispatcher { public boolean dispatch ( boolean complete ) throws IOException , XNIException { fEntityManager . setEntityHandler ( null ) ; try { boolean again ; XMLResourceIdentifierImpl resourceIdentifier = new XMLResourceIdentifierImpl ( ) ; do { again = false ; switch ( fScannerState ) { case XMLDocumentScannerImpl . SCANNER_STATE_DTD_INTERNAL_DECLS : { boolean completeDTD = true ; <START_BUG> boolean moreToScan = fDTDScanner . scanDTDInternalSubset ( completeDTD , fStandalone , fHasExternalDTD ) ; <END_BUG> if ( ! moreToScan ) { if ( ! ( fEntityScanner . skipChar ( ']' ) ) ) { reportFatalError ( "EXPECTED_SQUARE_BRACKET_TO_CLOSE_INTERNAL_SUBSET" , null ) ; } fEntityScanner . skipSpaces ( ) ; if ( ! ( fEntityScanner . skipChar ( '>' ) ) ) { reportFatalError ( "DoctypedeclUnterminated" , new Object [ ] { fDoctypeName } ) ; } ( fMarkupDepth ) -- ; if ( ( ( ( fDoctypeSystemId ) != null ) && ( ( fValidation ) || ( fLoadExternalDTD ) ) ) && ( ( ( fValidationManager ) == null ) || ( ! ( fValidationManager . isCachedDTD ( ) ) ) ) ) { setScannerState ( XMLDocumentScannerImpl . SCANNER_STATE_DTD_EXTERNAL ) ; } else { setScannerState ( XMLDocumentScannerImpl . SCANNER_STATE_PROLOG ) ; setDispatcher ( fPrologDispatcher ) ; fEntityManager . setEntityHandler ( XMLDocumentScannerImpl . this ) ; return true ; } } break ; } case XMLDocumentScannerImpl . SCANNER_STATE_DTD_EXTERNAL : { resourceIdentifier . setValues ( fDoctypePublicId , fDoctypeSystemId , null , null ) ; XMLInputSource xmlInputSource = fEntityManager . resolveEntity ( resourceIdentifier ) ; fDTDScanner . setInputSource ( xmlInputSource ) ; setScannerState ( XMLDocumentScannerImpl . SCANNER_STATE_DTD_EXTERNAL_DECLS ) ; again = true ; break ; } case XMLDocumentScannerImpl . SCANNER_STATE_DTD_EXTERNAL_DECLS : { boolean completeDTD = true ; boolean moreToScan = fDTDScanner . scanDTDExternalSubset ( completeDTD ) ; if ( ! moreToScan ) { setScannerState ( XMLDocumentScannerImpl . SCANNER_STATE_PROLOG ) ; setDispatcher ( fPrologDispatcher ) ; fEntityManager . setEntityHandler ( XMLDocumentScannerImpl . this ) ; return true ; } break ; } default : { throw new XNIException ( ( ( ( ( "DTDDispatcher#dispatch:<seq2seq4repair_space>scanner<seq2seq4repair_space>state=" + ( fScannerState ) ) + "<seq2seq4repair_space>(" ) + ( getScannerStateName ( fScannerState ) ) ) + ')' ) ) ; } } } while ( complete || again ) ; } catch ( EOFException e ) { reportFatalError ( "PrematureEOF" , null ) ; throw e ; } finally { fEntityManager . setEntityHandler ( XMLDocumentScannerImpl . this ) ; } return true ; } } protected final class ContentDispatcher extends FragmentContentDispatcher { protected boolean scanForDoctypeHook ( ) throws IOException , XNIException { } protected boolean elementDepthIsZeroHook ( ) throws IOException , XNIException { }

Fix:
boolean moreToScan = fDTDScanner . scanDTDInternalSubset ( completeDTD , fStandalone , ( ( fHasExternalDTD ) && ( fLoadExternalDTD ) ) ) ;