Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/jdk/javax/xml/jaxp/common/8035437/AbstractMethodErrorTest.java
41154 views
1
/*
2
* Copyright (c) 2014, 2020, Oracle and/or its affiliates. All rights reserved.
3
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4
*
5
* This code is free software; you can redistribute it and/or modify it
6
* under the terms of the GNU General Public License version 2 only, as
7
* published by the Free Software Foundation.
8
*
9
* This code is distributed in the hope that it will be useful, but WITHOUT
10
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12
* version 2 for more details (a copy is included in the LICENSE file that
13
* accompanied this code).
14
*
15
* You should have received a copy of the GNU General Public License version
16
* 2 along with this work; if not, write to the Free Software Foundation,
17
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18
*
19
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20
* or visit www.oracle.com if you need additional information or have any
21
* questions.
22
*/
23
24
import javax.xml.parsers.DocumentBuilder;
25
import javax.xml.parsers.DocumentBuilderFactory;
26
import org.w3c.dom.DOMImplementation;
27
import org.w3c.dom.Document;
28
import org.w3c.dom.ls.DOMImplementationLS;
29
import org.w3c.dom.ls.LSSerializer;
30
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 {
51
52
public static void main(String[] args) throws Exception {
53
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
54
DocumentBuilder builder = factory.newDocumentBuilder();
55
Document document = builder.newDocument();
56
57
DOMImplementation impl = document.getImplementation();
58
DOMImplementationLS implLS = (DOMImplementationLS) impl.getFeature("LS", "3.0");
59
LSSerializer dsi = implLS.createLSSerializer();
60
61
// We should have here incorrect document without getXmlVersion() method
62
String result = dsi.writeToString(document);
63
System.out.println("Result:" + result);
64
}
65
66
}
67
68