Documentation for XPathFactory.newInstance(String uri) is here.
I am trying to make this fail like this:
println(System.getProperty("DEFAULT_PROPERTY_NAME"));
System.setProperty("DEFAULT_PROPERTY_NAME", "dummy");
println(System.getProperty("DEFAULT_PROPERTY_NAME"));
XPathFactory xPathFactory = XPathFactory.newInstance();
println(xPathFactory.getClass());
The output I am getting is :
null
dummy
class org.apache.xpath.jaxp.XPathFactoryImpl
I am expecting that the ClassLoader will fail due to the bullet point:
If the system property DEFAULT_PROPERTY_NAME + ":uri" is present, where uri is the parameter to this method, then its value is read as a class name. The method will try to create a new instance of this class by using the class loader, and returns it if it is successfully created.
but that is not the case and I am obviously missing something.
What am I doing wrong?
I am expecting that the ClassLoader will fail due to the bullet point:
This bullet point refers to method:
public static final XPathFactory newInstance(String uri)
But you are calling:
public static final XPathFactory newInstance()
which states:
This method is functionally equivalent to:
newInstance(DEFAULT_OBJECT_MODEL_URI)
Since the implementation for the W3C DOM is always available, this method will never fail.