--- /dev/null 2013-05-22 15:30:23.360375610 +0400 +++ new/jdk/test/com/sun/org/apache/xpath/XPathExceptionInitCause.java 2013-05-24 20:30:00.914389110 +0400 @@ -0,0 +1,25 @@ +/* + * @test + * @bug 8009579 + * @summary The initCause() incorrectly initialise the cause in + * XPathException class when used with XPathException(String) + * constructor. + * @run main XPathExceptionInitCause + * @author aleksej.efimov@oracle.com + */ + +import javax.xml.xpath.XPathException; + +public class XPathExceptionInitCause { + + public static void main(String[] args) throws Exception { + Throwable cause = new Throwable("message 1"); + XPathException xpathexcep = new XPathException("message 2"); + xpathexcep.initCause(cause); + System.out.println("getCause() result: '" + xpathexcep.getCause() + + "' Cause itself: '" + cause + "'"); + if (!xpathexcep.getCause().toString().equals(cause.toString())) { + throw new Exception("Incorrect cause is set by initCause()"); + } + } +}