jaxp/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/dom/MultiDOM.java
--- a/jaxp/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/dom/MultiDOM.java Wed Jul 05 21:25:35 2017 +0200
+++ b/jaxp/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/dom/MultiDOM.java Wed Mar 09 16:09:55 2016 -0800
@@ -1,7 +1,6 @@
/*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
*/
-
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
@@ -30,8 +29,8 @@
import com.sun.org.apache.xml.internal.dtm.DTMAxisIterator;
import com.sun.org.apache.xml.internal.dtm.DTMManager;
import com.sun.org.apache.xml.internal.dtm.ref.DTMAxisIteratorBase;
+import com.sun.org.apache.xml.internal.dtm.ref.DTMAxisIterNodeList;
import com.sun.org.apache.xml.internal.dtm.ref.DTMDefaultBase;
-import com.sun.org.apache.xml.internal.dtm.ref.DTMAxisIterNodeList;
import com.sun.org.apache.xml.internal.serializer.SerializationHandler;
import com.sun.org.apache.xml.internal.utils.SuballocatedIntVector;
import java.util.HashMap;
@@ -671,4 +670,51 @@
public Map<String, Integer> getElementsWithIDs() {
return _main.getElementsWithIDs();
}
+
+ public void release() {
+ _main.release();
+ }
+
+ private boolean isMatchingAdapterEntry(DOM entry, DOMAdapter adapter) {
+ DOM dom = adapter.getDOMImpl();
+
+ return (entry == adapter) || (
+ /*
+ * Method addDOMAdapter overwrites for AdaptiveResultTreeImpl
+ * objects the usual entry with an adapter to the nested
+ * DOM, so we must check this here. See last 'if' statement
+ * of addDOMAdapter.
+ */
+ (dom instanceof AdaptiveResultTreeImpl) &&
+ (entry instanceof DOMAdapter) &&
+ (((AdaptiveResultTreeImpl)dom).getNestedDOM() == ((DOMAdapter)entry).getDOMImpl())
+ );
+ }
+
+ public void removeDOMAdapter(DOMAdapter adapter) {
+ _documents.remove(adapter.getDocumentURI(0));
+ DOM dom = adapter.getDOMImpl();
+
+ if (dom instanceof DTMDefaultBase) {
+ SuballocatedIntVector ids = ((DTMDefaultBase) dom).getDTMIDs();
+ int idsSize = ids.size();
+ for (int i = 0; i < idsSize; i++) {
+ _adapters[ids.elementAt(i) >>> DTMManager.IDENT_DTM_NODE_BITS] = null;
+ }
+ } else {
+ int id = dom.getDocument() >>> DTMManager.IDENT_DTM_NODE_BITS;
+ if ((id > 0) && (id < _adapters.length) && isMatchingAdapterEntry(_adapters[id], adapter)) {
+ _adapters[id] = null;
+ } else {
+ boolean found = false;
+ for (int i = 0; i < _adapters.length; i++) {
+ if (isMatchingAdapterEntry(_adapters[id], adapter)) {
+ _adapters[i] = null;
+ found = true;
+ break;
+ }
+ }
+ }
+ }
+ }
}