Buggy code:
public class XMLDocumentScannerImpl extends XMLDocumentFragmentScannerImpl { protected static final int SCANNER_STATE_XML_DECL = 0 ; protected static final int SCANNER_STATE_PROLOG = 5 ; protected static final int SCANNER_STATE_TRAILING_MISC = 12 ; protected static final int SCANNER_STATE_DTD_INTERNAL_DECLS = 17 ; protected static final int SCANNER_STATE_DTD_EXTERNAL = 18 ; protected static final int SCANNER_STATE_DTD_EXTERNAL_DECLS = 19 ; protected static final String LOAD_EXTERNAL_DTD = ( Constants . XERCES_FEATURE_PREFIX ) + ( Constants . LOAD_EXTERNAL_DTD_FEATURE ) ; protected static final String DISALLOW_DOCTYPE_DECL_FEATURE = ( Constants . XERCES_FEATURE_PREFIX ) + ( Constants . DISALLOW_DOCTYPE_DECL_FEATURE ) ; protected static final String DTD_SCANNER = ( Constants . XERCES_PROPERTY_PREFIX ) + ( Constants . DTD_SCANNER_PROPERTY ) ; protected static final String VALIDATION_MANAGER = ( Constants . XERCES_PROPERTY_PREFIX ) + ( Constants . VALIDATION_MANAGER_PROPERTY ) ; protected static final String NAMESPACE_CONTEXT = ( Constants . XERCES_PROPERTY_PREFIX ) + ( Constants . NAMESPACE_CONTEXT_PROPERTY ) ; private static final String [ ] RECOGNIZED_FEATURES = new String [ ] { XMLDocumentScannerImpl . LOAD_EXTERNAL_DTD , XMLDocumentScannerImpl . DISALLOW_DOCTYPE_DECL_FEATURE } ; private static final Boolean [ ] FEATURE_DEFAULTS = new Boolean [ ] { Boolean . TRUE , Boolean . FALSE } ; private static final String [ ] RECOGNIZED_PROPERTIES = new String [ ] { XMLDocumentScannerImpl . DTD_SCANNER , XMLDocumentScannerImpl . VALIDATION_MANAGER , XMLDocumentScannerImpl . NAMESPACE_CONTEXT } ; private static final Object [ ] PROPERTY_DEFAULTS = new Object [ ] { null , null , null } ; protected XMLDTDScanner fDTDScanner ; protected ValidationManager fValidationManager ; protected boolean fScanningDTD ; protected String fDoctypeName ; protected String fDoctypePublicId ; protected String fDoctypeSystemId ; protected NamespaceContext fNamespaceContext = new NamespaceSupport ( ) ; protected boolean fLoadExternalDTD = true ; protected boolean fDisallowDoctype = false ; protected boolean fSeenDoctypeDecl ; protected Dispatcher fXMLDeclDispatcher = new XMLDocumentScannerImpl . XMLDeclDispatcher ( ) ; protected Dispatcher fPrologDispatcher = new XMLDocumentScannerImpl . PrologDispatcher ( ) ; protected Dispatcher fDTDDispatcher = new XMLDocumentScannerImpl . DTDDispatcher ( ) ; protected Dispatcher fTrailingMiscDispatcher = new XMLDocumentScannerImpl . TrailingMiscDispatcher ( ) ; private String [ ] fStrings = new String [ 3 ] ; private XMLString fString = new XMLString ( ) ; private XMLStringBuffer fStringBuffer = new XMLStringBuffer ( ) ; private XMLInputSource fExternalSubsetSource = null ; public XMLDocumentScannerImpl ( ) { } public void setInputSource ( XMLInputSource inputSource ) throws IOException { } public void reset ( XMLComponentManager componentManager ) throws XMLConfigurationException { } public String [ ] getRecognizedFeatures ( ) { } public void setFeature ( String featureId , boolean state ) throws XMLConfigurationException { } public String [ ] getRecognizedProperties ( ) { } public void setProperty ( String propertyId , Object value ) throws XMLConfigurationException { } public Boolean getFeatureDefault ( String featureId ) { } public Object getPropertyDefault ( String propertyId ) { } public void startEntity ( String name , XMLResourceIdentifier identifier , String encoding , Augmentations augs ) throws XNIException { } public void endEntity ( String name , Augmentations augs ) throws XNIException { } protected Dispatcher createContentDispatcher ( ) { } protected boolean scanDoctypeDecl ( ) throws IOException , XNIException { } protected String getScannerStateName ( int state ) { } protected final class XMLDeclDispatcher implements Dispatcher { public boolean dispatch ( boolean complete ) throws IOException , XNIException { } } protected final class PrologDispatcher implements Dispatcher { public boolean dispatch ( boolean complete ) throws IOException , XNIException { } } protected final class DTDDispatcher implements Dispatcher { public boolean dispatch ( boolean complete ) throws IOException , XNIException { } } protected class ContentDispatcher extends FragmentContentDispatcher { protected boolean scanForDoctypeHook ( ) throws IOException , XNIException { } protected boolean elementDepthIsZeroHook ( ) throws IOException , XNIException { } protected boolean scanRootElementHook ( ) throws IOException , XNIException { <START_BUG> if ( ( ( ( fExternalSubsetResolver ) != null ) && ( ! ( fSeenDoctypeDecl ) ) ) && ( ( fValidation ) || ( fLoadExternalDTD ) ) ) { <END_BUG> scanStartElementName ( ) ; resolveExternalSubsetAndRead ( ) ; if ( scanStartElementAfterName ( ) ) { setScannerState ( XMLDocumentScannerImpl . SCANNER_STATE_TRAILING_MISC ) ; setDispatcher ( fTrailingMiscDispatcher ) ; return true ; } } else if ( scanStartElement ( ) ) { setScannerState ( XMLDocumentScannerImpl . SCANNER_STATE_TRAILING_MISC ) ; setDispatcher ( fTrailingMiscDispatcher ) ; return true ; } return false ; } protected void endOfFileHook ( EOFException e ) throws IOException , XNIException { } protected void resolveExternalSubsetAndRead ( ) throws IOException , XNIException { } } protected final class TrailingMiscDispatcher implements Dispatcher { public boolean dispatch ( boolean complete ) throws IOException , XNIException { } } }

Fix:
if ( ( ( ( ( fExternalSubsetResolver ) != null ) && ( ! ( fSeenDoctypeDecl ) ) ) && ( ! ( fDisallowDoctype ) ) ) && ( ( fValidation ) || ( fLoadExternalDTD ) ) ) {