-
Bug
-
Resolution: Fixed
-
P3
-
7
-
b06
-
generic
-
generic
-
Verified
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-2228631 | 8 | Joe Wang | P3 | Closed | Fixed | b55 |
JDK-8017788 | 7u45 | Joe Wang | P3 | Closed | Fixed | b01 |
It looks XMLEventFactory.newFactory(String factoryId, ClassLoader classLoader) does not work as expected.
As java doc, factoryId should be "Name of the factory to find, same as a property name".
But actually it is treated as "property value". See below test code. I believe the bug is similar with CR 6756677, which treat factoryId as property value for XMLInputFactory.
It happens for latest build of 7u4, 7u6 and 8.
Simple test code:
=========================
package javax.xml.stream;
import javax.xml.stream.* ;
public class Test{
public static void main(String[] args){
System.setProperty("inputFac", "javax.xml.stream.MyInputFactory") ;
System.setProperty("outputFac", "javax.xml.stream.MyOutputFactory") ;
System.setProperty("eventFac", "javax.xml.stream.MyEventFactory") ;
XMLInputFactory xif = XMLInputFactory.newFactory("inputFac", null);
System.out.println(xif.getClass().getName()) ;
XMLOutputFactory xof = XMLOutputFactory.newFactory("outputFac", null);
System.out.println(xof.getClass().getName()) ;
//work
XMLEventFactory xef1 = XMLEventFactory.newFactory("javax.xml.stream.MyEventFactory", null);
System.out.println(xef1.getClass().getName()) ;
//do not work
XMLEventFactory xef2 = XMLEventFactory.newFactory("eventFac", null);
System.out.println(xef2.getClass().getName()) ;
}
}
==============
Output:
=============
javax.xml.stream.MyInputFactory
javax.xml.stream.MyOutputFactory
javax.xml.stream.MyEventFactory
Exception in thread "main" javax.xml.stream.FactoryConfigurationError: Provider eventFac not found
at javax.xml.stream.XMLEventFactory.newFactory(XMLEventFactory.java:147)
at javax.xml.stream.Test.main(Test.java:23)
Caused by: java.lang.ClassNotFoundException: eventFac
at java.net.URLClassLoader$1.run(URLClassLoader.java:359)
at java.net.URLClassLoader$1.run(URLClassLoader.java:348)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:347)
at java.lang.ClassLoader.loadClass(ClassLoader.java:423)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
at javax.xml.stream.FactoryFinder.getProviderClass(FactoryFinder.java:108)
at javax.xml.stream.FactoryFinder.newInstance(FactoryFinder.java:143)
at javax.xml.stream.XMLEventFactory.newFactory(XMLEventFactory.java:144)
... 1 more
=============
As java doc, factoryId should be "Name of the factory to find, same as a property name".
But actually it is treated as "property value". See below test code. I believe the bug is similar with CR 6756677, which treat factoryId as property value for XMLInputFactory.
It happens for latest build of 7u4, 7u6 and 8.
Simple test code:
=========================
package javax.xml.stream;
import javax.xml.stream.* ;
public class Test{
public static void main(String[] args){
System.setProperty("inputFac", "javax.xml.stream.MyInputFactory") ;
System.setProperty("outputFac", "javax.xml.stream.MyOutputFactory") ;
System.setProperty("eventFac", "javax.xml.stream.MyEventFactory") ;
XMLInputFactory xif = XMLInputFactory.newFactory("inputFac", null);
System.out.println(xif.getClass().getName()) ;
XMLOutputFactory xof = XMLOutputFactory.newFactory("outputFac", null);
System.out.println(xof.getClass().getName()) ;
//work
XMLEventFactory xef1 = XMLEventFactory.newFactory("javax.xml.stream.MyEventFactory", null);
System.out.println(xef1.getClass().getName()) ;
//do not work
XMLEventFactory xef2 = XMLEventFactory.newFactory("eventFac", null);
System.out.println(xef2.getClass().getName()) ;
}
}
==============
Output:
=============
javax.xml.stream.MyInputFactory
javax.xml.stream.MyOutputFactory
javax.xml.stream.MyEventFactory
Exception in thread "main" javax.xml.stream.FactoryConfigurationError: Provider eventFac not found
at javax.xml.stream.XMLEventFactory.newFactory(XMLEventFactory.java:147)
at javax.xml.stream.Test.main(Test.java:23)
Caused by: java.lang.ClassNotFoundException: eventFac
at java.net.URLClassLoader$1.run(URLClassLoader.java:359)
at java.net.URLClassLoader$1.run(URLClassLoader.java:348)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:347)
at java.lang.ClassLoader.loadClass(ClassLoader.java:423)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
at javax.xml.stream.FactoryFinder.getProviderClass(FactoryFinder.java:108)
at javax.xml.stream.FactoryFinder.newInstance(FactoryFinder.java:143)
at javax.xml.stream.XMLEventFactory.newFactory(XMLEventFactory.java:144)
... 1 more
=============
- backported by
-
JDK-2228631 XMLEventFactory.newFactory(String factoryId, ClassLoader loader) does not work as expected
-
- Closed
-
-
JDK-8017788 XMLEventFactory.newFactory(String factoryId, ClassLoader loader) does not work as expected
-
- Closed
-
- relates to
-
JDK-6756677 [StAX] XMLInputFactory.newInstance(String factoryId, ...) treats property name as a property value
-
- Closed
-