Buggy code:
protected transient int fNodeCount = 0 ; protected transient int [ ] [ ] fNodeType ; protected transient int [ ] [ ] fNodeName ; protected transient int [ ] [ ] fNodeValue ; protected transient int [ ] [ ] fNodeParent ; protected transient int [ ] [ ] fNodeFirstChild ; protected transient int [ ] [ ] fNodeNextSib ; protected transient int fIdCount ; protected transient int [ ] fIdName ; protected transient int [ ] fIdElement ; protected transient StringPool fStringPool ; protected boolean fNamespacesEnabled = false ; public DeferredDocumentImpl ( StringPool stringPool ) { } public DeferredDocumentImpl ( StringPool stringPool , boolean namespacesEnabled ) { } public DeferredDocumentImpl ( StringPool stringPool , boolean namespaces , boolean grammarAccess ) { } boolean getNamespacesEnabled ( ) { } public int createDocument ( ) { } public int createDocumentType ( int rootElementNameIndex , int publicId , int systemId ) { } public void setInternalSubset ( int doctypeIndex , int subsetIndex ) { } public int createNotation ( int notationName , int publicId , int systemId ) throws Exception { } public int createEntity ( int entityName , int publicId , int systemId , int notationName ) throws Exception { } public int createEntityReference ( int nameIndex ) throws Exception { } public int createElement ( int elementNameIndex , XMLAttrList attrList , int attrListIndex ) { } public int createAttribute ( int attrNameIndex , int attrValueIndex , boolean specified ) { } public int createElementDefinition ( int elementNameIndex ) { } public int createTextNode ( int dataIndex , boolean ignorableWhitespace ) { } public int createCDATASection ( int dataIndex , boolean ignorableWhitespace ) { } public int createProcessingInstruction ( int targetIndex , int dataIndex ) { } public int createComment ( int dataIndex ) { } public void appendChild ( int parentIndex , int childIndex ) { } public int setAttributeNode ( int elemIndex , int attrIndex ) { } public int insertBefore ( int parentIndex , int newChildIndex , int refChildIndex ) { } public void setAsFirstChild ( int parentIndex , int childIndex ) { } public int getParentNode ( int nodeIndex ) { } public int getParentNode ( int nodeIndex , boolean free ) { } public int getFirstChild ( int nodeIndex ) { } public int getFirstChild ( int nodeIndex , boolean free ) { } public int getNextSibling ( int nodeIndex ) { } public int getNextSibling ( int nodeIndex , boolean free ) { } public int getRealNextSibling ( int nodeIndex ) { } public int getRealNextSibling ( int nodeIndex , boolean free ) { } public int lookupElementDefinition ( int elementNameIndex ) { } public DeferredNode getNodeObject ( int nodeIndex ) { } public String getNodeNameString ( int nodeIndex ) { } public String getNodeNameString ( int nodeIndex , boolean free ) { } public String getNodeValueString ( int nodeIndex ) { } public String getNodeValueString ( int nodeIndex , boolean free ) { } public int getNodeName ( int nodeIndex ) { } public int getNodeName ( int nodeIndex , boolean free ) { } public int getNodeValue ( int nodeIndex ) { } public int getNodeValue ( int nodeIndex , boolean free ) { } public short getNodeType ( int nodeIndex ) { } public short getNodeType ( int nodeIndex , boolean free ) { } public void putIdentifier ( int nameIndex , int elementNodeIndex ) { } public void print ( ) { } public int getNodeIndex ( ) { } protected StringPool getStringPool ( ) { } protected void synchronizeData ( ) { } protected void synchronizeChildren ( ) { if ( syncData ) { synchronizeData ( ) ; } syncChildren = false ; getNodeType ( 0 ) ; NodeImpl last = null ; for ( int index = getFirstChild ( 0 ) ; index != ( - 1 ) ; index = getNextSibling ( index ) ) { NodeImpl node = ( ( NodeImpl ) ( getNodeObject ( index ) ) ) ; if ( last == null ) { firstChild = node ; } else { last . nextSibling = node ; } <START_BUG> node . parentNode = this ; <END_BUG> node . previousSibling = last ; last = node ; int type = node . getNodeType ( ) ; if ( type == ( Node . ELEMENT_NODE ) ) { docElement = ( ( ElementImpl ) ( node ) ) ; } else if ( type == ( Node . DOCUMENT_TYPE_NODE ) ) { docType = ( ( DocumentTypeImpl ) ( node ) ) ; } } if ( last != null ) { lastChild = last ; } } protected boolean ensureCapacity ( int chunk , int index ) { } protected int createNode ( short nodeType ) { } protected static int binarySearch ( final int [ ] values , int start , int end , int target ) { } private final void createChunk ( int [ ] [ ] data , int chunk ) { } private final int setChunkIndex ( int [ ] [ ] data , int value , int chunk , int index ) { } private final int getChunkIndex ( int [ ] [ ] data , int chunk , int index ) { } private final int clearChunkIndex ( int [ ] [ ] data , int chunk , int index ) { } private final void putIdentifier0 ( String idName , Element element ) { } private static void print ( int [ ] values , int start , int end , int middle , int target ) { } static class IntVector { private int [ ] data ; private int size ; public int size ( ) { } public int elementAt ( int index ) { } public void addElement ( int element ) { } public void removeAllElements ( ) { } private void ensureCapacity ( int newsize ) { } } }

Fix:
node . ownerNode = this ;