1
1
/*
2
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
2
+ * Copyright (c) 2014, 2020, Oracle and/or its affiliates. All rights reserved.
3
3
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4
4
*
5
5
* This code is free software; you can redistribute it and/or modify it
28
28
import org .w3c .dom .ls .DOMImplementationLS ;
29
29
import org .w3c .dom .ls .LSSerializer ;
30
30
31
- class AbstractMethodErrorTest {
31
+ /*
32
+ * @test
33
+ * @bug 8035437
34
+ * @summary Verifies that java.lang.AbstractMethodError is not thrown when
35
+ * serializing improper version of DocumentImpl class as reported in XERCESJ-1007.
36
+ * Test preconditions and steps:
37
+ * - Compiles test version of org.w3c.dom.Node and org.w3c.dom.Document
38
+ * - Compiles DocumentImpl overriding java.xml module with Node and Document
39
+ * - Runs AbstractMethodErrorTest overriding java.xml only with DocumentImpl class
40
+ * Hence, the interfaces compiled in the first step need to be removed
41
+ * from the test folder in order to reproduce the bug scenario. At the time of writing,
42
+ * the clean command was not able to resolve paths generated by compile/module
43
+ * @library /test/lib
44
+ * @compile --patch-module java.xml=${test.src} org/w3c/dom/Document.java
45
+ * org/w3c/dom/Node.java com/sun/org/apache/xerces/internal/dom/DocumentImpl.java
46
+ * @clean org.w3c.dom.*
47
+ * @run main/othervm --patch-module java.xml=${test.class.path} AbstractMethodErrorTest
48
+ */
49
+
50
+ public class AbstractMethodErrorTest {
32
51
33
52
public static void main (String [] args ) throws Exception {
34
53
DocumentBuilderFactory factory = DocumentBuilderFactory .newInstance ();
@@ -39,11 +58,7 @@ public static void main(String[] args) throws Exception {
39
58
DOMImplementationLS implLS = (DOMImplementationLS ) impl .getFeature ("LS" , "3.0" );
40
59
LSSerializer dsi = implLS .createLSSerializer ();
41
60
42
- /* We should have here incorrect document without getXmlVersion() method:
43
- * Such Document is generated by replacing the JDK bootclasses with it's
44
- * own Node,Document and DocumentImpl classes (see run.sh). According to
45
- * XERCESJ-1007 the AbstractMethodError should be thrown in such case.
46
- */
61
+ // We should have here incorrect document without getXmlVersion() method
47
62
String result = dsi .writeToString (document );
48
63
System .out .println ("Result:" + result );
49
64
}
0 commit comments