8285726: [11u, 17u] Unify fix for JDK-8284548 with version from head

Reviewed-by: bae
This commit is contained in:
Yuri Nesterenko 2022-05-16 12:20:06 +00:00
parent ec0598f21c
commit c83eb83fcc

View File

@ -36,18 +36,26 @@ public class InvalidXPath {
public static void main(String... args) {
// define an invalid XPath expression
final String invalidXPath = ">>";
final String[] invalidXPath = {
// @bug JDK-8284548: expressions ending with relational operators
// throw StringIndexOutOfBoundsException instead of XPathExpressionException
"/a/b/c[@d >",
"/a/b/c[@d <",
"/a/b/c[@d >=",
">>"
};
// expect XPathExpressionException when the invalid XPath expression is compiled
try {
XPathFactory.newInstance().newXPath().compile(invalidXPath);
} catch (XPathExpressionException e) {
System.out.println("Caught expected exception: " + e.getClass().getName() +
"(" + e.getMessage() + ").");
} catch (Exception e) {
System.out.println("Caught unexpected exception: " + e.getClass().getName() +
"(" + e.getMessage() + ")!");
throw e;
for(String s: invalidXPath) {
try {
XPathFactory.newInstance().newXPath().compile(s);
} catch (XPathExpressionException e) {
System.out.println("Caught expected exception: " + e.getClass().getName() +
"(" + e.getMessage() + ").");
} catch (Exception e) {
System.out.println("Caught unexpected exception: " + e.getClass().getName() +
"(" + e.getMessage() + ")!");
throw e;
}
}
}
}