Buggy code:
public class CoreDocumentImpl extends ParentNode implements Document , DocumentLS { static final long serialVersionUID = 0 ; protected DocumentTypeImpl docType ; protected ElementImpl docElement ; transient NodeListCache fFreeNLCache ; protected String encoding ; protected String actualEncoding ; protected String version ; protected boolean standalone ; protected String fDocumentURI ; protected Hashtable userData ; protected Hashtable identifiers ; transient DOMNormalizer domNormalizer = null ; transient DOMConfigurationImpl fConfiguration = null ; transient Object fXPathEvaluator = null ; private static final int [ ] kidOK ; protected int changes = 0 ; protected boolean allowGrammarAccess ; protected boolean errorChecking = true ; private int documentNumber = 0 ; private int nodeCounter = 0 ; private Hashtable nodeTable ; public CoreDocumentImpl ( ) { } public CoreDocumentImpl ( boolean grammarAccess ) { } public CoreDocumentImpl ( DocumentType doctype ) { } public CoreDocumentImpl ( DocumentType doctype , boolean grammarAccess ) { } public final Document getOwnerDocument ( ) { } public short getNodeType ( ) { } public String getNodeName ( ) { } public Node cloneNode ( boolean deep ) { } protected void cloneNode ( CoreDocumentImpl newdoc , boolean deep ) { } public Node insertBefore ( Node newChild , Node refChild ) throws DOMException { } public Node removeChild ( Node oldChild ) throws DOMException { } public Node replaceChild ( Node newChild , Node oldChild ) throws DOMException { } public String getTextContent ( ) throws DOMException { } public void setTextContent ( String textContent ) throws DOMException { } public Object getFeature ( String feature , String version ) { } public Attr createAttribute ( String name ) throws DOMException { } public CDATASection createCDATASection ( String data ) throws DOMException { } public Comment createComment ( String data ) { } public DocumentFragment createDocumentFragment ( ) { } public Element createElement ( String tagName ) throws DOMException { } public EntityReference createEntityReference ( String name ) throws DOMException { } public ProcessingInstruction createProcessingInstruction ( String target , String data ) throws DOMException { } public Text createTextNode ( String data ) { } public DocumentType getDoctype ( ) { } public Element getDocumentElement ( ) { } public NodeList getElementsByTagName ( String tagname ) { } public DOMImplementation getImplementation ( ) { } public void setErrorChecking ( boolean check ) { } public void setStrictErrorChecking ( boolean check ) { } public boolean getErrorChecking ( ) { } public boolean getStrictErrorChecking ( ) { } public String getActualEncoding ( ) { } public void setActualEncoding ( String value ) { } public void setXmlEncoding ( String value ) { } public String getXmlEncoding ( ) { } public void setXmlVersion ( String value ) { } public String getXmlVersion ( ) { } public void setXmlStandalone ( boolean value ) { } public boolean getXmlStandalone ( ) { } public String getDocumentURI ( ) { } public Node renameNode ( Node n , String namespaceURI , String name ) throws DOMException { } public void normalizeDocument ( ) { } public DOMConfiguration getConfig ( ) { } public String getBaseURI ( ) { } public void setDocumentURI ( String documentURI ) { } public boolean getAsync ( ) { } public void setAsync ( boolean async ) { } public void abort ( ) { } public boolean load ( String uri ) { } public boolean loadXML ( String source ) { } public String saveXML ( Node node ) throws DOMException { <START_BUG> if ( ( node != null ) && ( ( getOwnerDocument ( ) ) != ( node . getOwnerDocument ( ) ) ) ) { <END_BUG> String msg = DOMMessageFormatter . formatMessage ( DOM_DOMAIN , "WRONG_DOCUMENT_ERR" , null ) ; throw new DOMException ( DOMException . WRONG_DOCUMENT_ERR , msg ) ; } DOMImplementationLS domImplLS = ( ( DOMImplementationLS ) ( DOMImplementationImpl . getDOMImplementation ( ) ) ) ; DOMSerializer xmlWriter = domImplLS . createDOMSerializer ( ) ; if ( node == null ) { node = this ; } return xmlWriter . writeToString ( node ) ; } void setMutationEvents ( boolean set ) { } boolean getMutationEvents ( ) { } public DocumentType createDocumentType ( String qualifiedName , String publicID , String systemID ) throws DOMException { } public Entity createEntity ( String name ) throws DOMException { } public Notation createNotation ( String name ) throws DOMException { } public ElementDefinitionImpl createElementDefinition ( String name ) throws DOMException { } protected int getNodeNumber ( ) { } protected int getNodeNumber ( Node node ) { } public Node importNode ( Node source , boolean deep ) throws DOMException { } private Node importNode ( Node source , boolean deep , boolean cloningDoc , Hashtable reversedIdentifiers ) throws DOMException { } public Node adoptNode ( Node source ) { } public Element getElementById ( String elementId ) { } protected final void clearIdentifiers ( ) { } public void putIdentifier ( String idName , Element element ) { } public Element getIdentifier ( String idName ) { } public void removeIdentifier ( String idName ) { } public Enumeration getIdentifiers ( ) { } public Element createElementNS ( String namespaceURI , String qualifiedName ) throws DOMException { } public Element createElementNS ( String namespaceURI , String qualifiedName , String localpart ) throws DOMException { } public Attr createAttributeNS ( String namespaceURI , String qualifiedName ) throws DOMException { } public Attr createAttributeNS ( String namespaceURI , String qualifiedName , String localpart ) throws DOMException { } public NodeList getElementsByTagNameNS ( String namespaceURI , String localName ) { } public Object clone ( ) throws CloneNotSupportedException { } public static boolean isXMLName ( String s ) { } protected boolean isKidOK ( Node parent , Node child ) { } protected void changed ( ) { } protected int changes ( ) { } NodeListCache getNodeListCache ( ParentNode owner ) { } void freeNodeListCache ( NodeListCache c ) { } class UserDataRecord implements Serializable { Object fData ; UserDataHandler fHandler ;

Fix:
if ( ( node != null ) && ( ( this ) != ( node . getOwnerDocument ( ) ) ) ) {