# HG changeset patch # User aefimov # Date 1396278279 -14400 # Node ID a44bb551d0173b7defd0410428be10b0e22e2ca1 # Parent 5c29c65ae465ca958c75a56c7ff9a64989dbfb3d 8035437: Xerces Update: xml/serialize/DOMSerializerImpl Reviewed-by: lancea diff -r 5c29c65ae465 -r a44bb551d017 jdk/test/javax/xml/jaxp/common/8035437/AbstractMethodErrorTest.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jdk/test/javax/xml/jaxp/common/8035437/AbstractMethodErrorTest.java Mon Mar 31 19:04:39 2014 +0400 @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import javax.xml.parsers.DocumentBuilder; +import javax.xml.parsers.DocumentBuilderFactory; +import org.w3c.dom.DOMImplementation; +import org.w3c.dom.Document; +import org.w3c.dom.ls.DOMImplementationLS; +import org.w3c.dom.ls.LSSerializer; + +class AbstractMethodErrorTest { + + public static void main(String[] args) throws Exception { + DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); + DocumentBuilder builder = factory.newDocumentBuilder(); + Document document = builder.newDocument(); + + DOMImplementation impl = document.getImplementation(); + DOMImplementationLS implLS = (DOMImplementationLS) impl.getFeature("LS", "3.0"); + LSSerializer dsi = implLS.createLSSerializer(); + + /* We should have here incorrect document without getXmlVersion() method: + * Such Document is generated by replacing the JDK bootclasses with it's + * own Node,Document and DocumentImpl classes (see run.sh). According to + * XERCESJ-1007 the AbstractMethodError should be thrown in such case. + */ + String result = dsi.writeToString(document); + System.out.println("Result:" + result); + } + +} diff -r 5c29c65ae465 -r a44bb551d017 jdk/test/javax/xml/jaxp/common/8035437/Document.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jdk/test/javax/xml/jaxp/common/8035437/Document.java Mon Mar 31 19:04:39 2014 +0400 @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package org.w3c.dom; + +public interface Document { + + public org.w3c.dom.DocumentType getDoctype(); +} diff -r 5c29c65ae465 -r a44bb551d017 jdk/test/javax/xml/jaxp/common/8035437/DocumentImpl.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jdk/test/javax/xml/jaxp/common/8035437/DocumentImpl.java Mon Mar 31 19:04:39 2014 +0400 @@ -0,0 +1,67 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.sun.org.apache.xerces.internal.dom; + +import org.w3c.dom.Document; +import org.w3c.dom.Node; +import org.w3c.dom.DOMImplementation; + +public class DocumentImpl implements Document, Node { + + public short getNodeType() { + return 9; //DOCUMENT_NODE = 9 + } + + public org.w3c.dom.Document getOwnerDocument() { + return null; + } + + public Node getFirstChild() { + return null; + } + + public String getPrefix() { + return "TestPrefix"; + } + + public String getLocalName() { + return "LocalName"; + } + + public boolean hasAttributes() { + return false; + } + + public Node renameNode(Node n, String namespaceURI, String name) { + return n; + } + + public org.w3c.dom.DocumentType getDoctype() { + return null; + } + + public DOMImplementation getImplementation() { + return DOMImplementationImpl.getDOMImplementation(); + } + +} diff -r 5c29c65ae465 -r a44bb551d017 jdk/test/javax/xml/jaxp/common/8035437/Node.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jdk/test/javax/xml/jaxp/common/8035437/Node.java Mon Mar 31 19:04:39 2014 +0400 @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package org.w3c.dom; + +public interface Node { + + public short getNodeType(); + + public org.w3c.dom.Document getOwnerDocument(); + + public Node getFirstChild(); + + public String getPrefix(); + + public String getLocalName(); + + public boolean hasAttributes(); +} diff -r 5c29c65ae465 -r a44bb551d017 jdk/test/javax/xml/jaxp/common/8035437/run.sh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jdk/test/javax/xml/jaxp/common/8035437/run.sh Mon Mar 31 19:04:39 2014 +0400 @@ -0,0 +1,44 @@ +#!/bin/sh + +## +# Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# This code is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License version 2 only, as +# published by the Free Software Foundation. +# +# This code is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +# version 2 for more details (a copy is included in the LICENSE file that +# accompanied this code). +# +# You should have received a copy of the GNU General Public License version +# 2 along with this work; if not, write to the Free Software Foundation, +# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. +# +# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA +# or visit www.oracle.com if you need additional information or have any +# questions. +## + +# @test +# @bug 8035437 +# @summary Tests that java.lang.AbstractMethodError is not thrown when +# serializing improper version of DocumentImpl class. + +mkdir -p exec compile + +$COMPILEJAVA/bin/javac ${TESTJAVACOPTS} ${TESTTOOLVMOPTS} \ + -d compile $TESTSRC/Document.java $TESTSRC/Node.java || exit 1 + +$COMPILEJAVA/bin/javac ${TESTJAVACOPTS} ${TESTTOOLVMOPTS} \ + -Xbootclasspath/p:compile -d exec $TESTSRC/DocumentImpl.java || exit 1 + +$COMPILEJAVA/bin/javac ${TESTJAVACOPTS} ${TESTTOOLVMOPTS} \ + $TESTSRC/AbstractMethodErrorTest.java -d exec || exit 1 + +$TESTJAVA/bin/java ${TESTVMOPTS} -Xbootclasspath/p:exec -cp exec AbstractMethodErrorTest || exit 1 + +exit 0