Skip to content

Commit

Permalink
fix DOM2DTM to work in J9
Browse files Browse the repository at this point in the history
J9 wasn't coping with hot-patching standard library packages with a user
class.  This was done to work around a package private constructor.
This is fixed by moving into a local package and copying the class with
the package private constructor into a local copy.
  • Loading branch information
Taylor C. Richberger authored and flavorjones committed Dec 4, 2018
1 parent bf42407 commit d33a9f6
Show file tree
Hide file tree
Showing 4 changed files with 702 additions and 14 deletions.
3 changes: 2 additions & 1 deletion Manifest.txt
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ ext/java/nokogiri/internals/XalanDTMManagerPatch.java
ext/java/nokogiri/internals/XmlDeclHandler.java
ext/java/nokogiri/internals/XmlDomParserContext.java
ext/java/nokogiri/internals/XmlSaxParser.java
ext/java/nokogiri/internals/dom2dtm/DOM2DTM.java
ext/java/nokogiri/internals/dom2dtm/DOM2DTMdefaultNamespaceDeclarationNode.java
ext/java/nokogiri/internals/c14n/AttrCompare.java
ext/java/nokogiri/internals/c14n/C14nHelper.java
ext/java/nokogiri/internals/c14n/CanonicalFilter.java
Expand Down Expand Up @@ -108,7 +110,6 @@ ext/java/nokogiri/internals/c14n/NameSpaceSymbTable.java
ext/java/nokogiri/internals/c14n/NodeFilter.java
ext/java/nokogiri/internals/c14n/UtfHelpper.java
ext/java/nokogiri/internals/c14n/XMLUtils.java
ext/java/org/apache/xml/dtm/ref/dom2dtm/DOM2DTMExt.java
ext/nokogiri/depend
ext/nokogiri/extconf.rb
ext/nokogiri/html_document.c
Expand Down
18 changes: 12 additions & 6 deletions ext/java/nokogiri/internals/XalanDTMManagerPatch.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@
import javax.xml.transform.dom.DOMSource;

import org.apache.xml.dtm.DTM;
import nokogiri.internals.dom2dtm.DOM2DTM;
import nokogiri.internals.dom2dtm.DOM2DTMdefaultNamespaceDeclarationNode;
import org.apache.xml.dtm.DTMWSFilter;
import org.apache.xml.dtm.ref.dom2dtm.DOM2DTMExt;
import org.apache.xml.res.XMLErrorResources;
import org.apache.xml.res.XMLMessages;
import org.w3c.dom.Node;
Expand Down Expand Up @@ -80,6 +81,11 @@ public final class XalanDTMManagerPatch extends org.apache.xml.dtm.ref.DTMManage
if (handle != DTM.NULL) {
return handle;
}
} else if (thisDTM instanceof DOM2DTM) {
int handle = ((DOM2DTM) thisDTM).getHandleOfNode(node);
if (handle != DTM.NULL) {
return handle;
}
}
}

Expand Down Expand Up @@ -107,11 +113,12 @@ public final class XalanDTMManagerPatch extends org.apache.xml.dtm.ref.DTMManage
for (; p != null; p = p.getParentNode()) root = p;

// DOM2DTM dtm = (DOM2DTM) getDTM(new DOMSource(root), false, null);
DOM2DTMExt dtm = getDTMExt(new DOMSource(root), false, null/*, true, true*/);
DOM2DTM dtm = getDTM(new DOMSource(root), false, null/*, true, true*/);

int handle;

if (node instanceof org.apache.xml.dtm.ref.dom2dtm.DOM2DTMdefaultNamespaceDeclarationNode) {
if (node instanceof org.apache.xml.dtm.ref.dom2dtm.DOM2DTMdefaultNamespaceDeclarationNode
|| node instanceof DOM2DTMdefaultNamespaceDeclarationNode) {
// Can't return the same node since it's unique to a specific DTM,
// but can return the equivalent node -- find the corresponding
// Document Element, then ask it for the xml: namespace decl.
Expand Down Expand Up @@ -153,12 +160,11 @@ public final class XalanDTMManagerPatch extends org.apache.xml.dtm.ref.DTMManage
return handle;
}

private DOM2DTMExt getDTMExt(DOMSource source, boolean unique, DTMWSFilter whiteSpaceFilter/*, boolean incremental, boolean doIndexing*/) {
private DOM2DTM getDTM(DOMSource source, boolean unique, DTMWSFilter whiteSpaceFilter/*, boolean incremental, boolean doIndexing*/) {
int dtmPos = getFirstFreeDTMID();
int documentID = dtmPos << IDENT_DTM_NODE_BITS;

//DOM2DTM dtm = new DOM2DTM(this, source, documentID, whiteSpaceFilter, m_xsf, true);
DOM2DTMExt dtm = new DOM2DTMExt(this, source, documentID, whiteSpaceFilter, m_xsf, true);
DOM2DTM dtm = new DOM2DTM(this, source, documentID, whiteSpaceFilter, m_xsf, true);

addDTM(dtm, dtmPos, 0);
return dtm;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*
* $Id: DOM2DTM.java 478671 2006-11-23 21:00:31Z minchau $
*/
package org.apache.xml.dtm.ref.dom2dtm;
package nokogiri.internals.dom2dtm;

import javax.xml.transform.SourceLocator;
import javax.xml.transform.dom.DOMSource;
Expand All @@ -30,7 +27,6 @@
import org.apache.xml.dtm.ref.DTMManagerDefault;
import org.apache.xml.dtm.ref.ExpandedNameTable;
import org.apache.xml.dtm.ref.IncrementalSAXSource;
//import org.apache.xml.dtm.ref.dom2dtm.DOM2DTMdefaultNamespaceDeclarationNode;
import org.apache.xml.res.XMLErrorResources;
import org.apache.xml.res.XMLMessages;
import org.apache.xml.utils.FastStringBuffer;
Expand Down Expand Up @@ -62,7 +58,7 @@
* mutation. If you alter the DOM after wrapping DOM2DTM around it,
* all bets are off.
* */
public class DOM2DTMExt extends DTMDefaultBaseIterators
public class DOM2DTM extends DTMDefaultBaseIterators
{
// static final boolean JJK_DEBUG=false;
// static final boolean JJK_NEWCODE=true;
Expand Down Expand Up @@ -114,7 +110,7 @@ public class DOM2DTMExt extends DTMDefaultBaseIterators
* @param doIndexing true if the caller considers it worth it to use
* indexing schemes.
*/
public DOM2DTMExt(DTMManager mgr, DOMSource domSource,
public DOM2DTM(DTMManager mgr, DOMSource domSource,
int dtmIdentity, DTMWSFilter whiteSpaceFilter,
XMLStringFactory xstringfactory,
boolean doIndexing)
Expand Down
Loading

0 comments on commit d33a9f6

Please sign in to comment.