Skip to content

Commit 343aa84

Browse files
committed
another Xerces detection fix for JDK 17 (issue #541)
1 parent 62a2386 commit 343aa84

File tree

4 files changed

+17
-2
lines changed

4 files changed

+17
-2
lines changed

src/changes/changes.xml

+3
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88

99
<body>
1010
<release version="2.70.0" date="xx, 2023" description="Chrome/Edge 109, Firefox 108, Bugfixes">
11+
<action type="fix" dev="rbri" issue="541">"
12+
Another Xerces detection fix for JDK 17.
13+
</action>
1114
<action type="add" dev="rbri">
1215
Missing properties addedNodes, removedNodes, previousSibling, and nextSibling added to MutationRecord.
1316
</action>

src/main/java/com/gargoylesoftware/htmlunit/platform/Platform.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public final class Platform {
5151
HelperSunXerces_ = (XmlUtilsHelperAPI)
5252
Class.forName("com.gargoylesoftware.htmlunit.platform.util.XmlUtilsSunXercesHelper").newInstance();
5353
}
54-
catch (final Exception e) {
54+
catch (final Exception | LinkageError e) {
5555
// ignore
5656
}
5757

@@ -60,7 +60,7 @@ public final class Platform {
6060
HelperXerces_ = (XmlUtilsHelperAPI)
6161
Class.forName("com.gargoylesoftware.htmlunit.platform.util.XmlUtilsXercesHelper").newInstance();
6262
}
63-
catch (final Exception e2) {
63+
catch (final Exception | LinkageError e2) {
6464
// ignore
6565
}
6666
}

src/main/java/com/gargoylesoftware/htmlunit/platform/util/XmlUtilsSunXercesHelper.java

+6
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import java.util.HashMap;
1919
import java.util.List;
2020
import java.util.Map;
21+
import java.util.Objects;
2122

2223
import org.w3c.dom.Document;
2324
import org.w3c.dom.NamedNodeMap;
@@ -38,6 +39,11 @@ public final class XmlUtilsSunXercesHelper implements XmlUtilsHelperAPI {
3839

3940
// private static final Log LOG = LogFactory.getLog(XmlUtilsXerces.class);
4041

42+
public XmlUtilsSunXercesHelper() {
43+
// Force eager loading of classes in order to flush out any linkage errors early
44+
Objects.hash(DeferredDocumentImpl.class, DeferredNode.class);
45+
}
46+
4147
/**
4248
* {@inheritDoc}
4349
*/

src/main/java/com/gargoylesoftware/htmlunit/platform/util/XmlUtilsXercesHelper.java

+6
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import java.util.HashMap;
1919
import java.util.List;
2020
import java.util.Map;
21+
import java.util.Objects;
2122

2223
import org.apache.xerces.dom.DeferredDocumentImpl;
2324
import org.apache.xerces.dom.DeferredNode;
@@ -38,6 +39,11 @@ public final class XmlUtilsXercesHelper implements XmlUtilsHelperAPI {
3839

3940
// private static final Log LOG = LogFactory.getLog(XmlUtilsXerces.class);
4041

42+
public XmlUtilsXercesHelper() {
43+
// Force eager loading of classes in order to flush out any linkage errors early
44+
Objects.hash(DeferredDocumentImpl.class, DeferredNode.class);
45+
}
46+
4147
/**
4248
* {@inheritDoc}
4349
*/

0 commit comments

Comments
 (0)