I have a simple method to check if input string is valid xpath
private boolean isXpath(String value) {
boolean isXpath = true;
try {
XPath xpath = XPathFactory.newInstance().newXPath();
xpath.compile(value);
} catch (XPathExpressionException e) {
isXpath = false;
}
return isXpath;
}
Can I be sure that JIT compiler won't remove code inside try
block, because of it has no side effects? Or it has (possible exception)?