If the intention was to spare some XMLInputFactory instances,
the XMLInputFactory implementation may need to be thread-safe.
I haven't read the spec, however the JavaDoc doesn't guarantee that.
On the other hand, option 2 promotes SPI while API is available, people
sometimes do that for
There are a couple of places where we need to create an
XMLStreamReader and to do this we are doing
XMLInputFactory.newInstance(javax.xml.stream.XMLInputFactory,
classLoader)
to obtain the factory (the classloader is the runtime classloader and
this form avoids messing with the TCCL).
I