JDK-6756677 : [StAX] XMLInputFactory.newInstance(String factoryId, ...) treats property name as a property value
  • Type: Bug
  • Component: xml
  • Sub-Component: javax.xml.stream
  • Affected Version: javadb_10.0
  • Priority: P2
  • Status: Closed
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2008-10-07
  • Updated: 2013-06-04
  • Resolved: 2010-08-24
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other JDK 7
1.4.0 1.4Fixed 7Fixed
Related Reports
Relates :  
Description
I am referring to javax.xml.stream.XMLInputFactory.newInstance(String factoryId, ClassLoader loader). The javadocs [1] suggest that the first argument is a property name, where as the implementation available in Sun JDK 1.6.0_02 treats it as a property value. Interestingly, the implementation done by BEA and available at [2] differs significantly from that in Sun JDK 1.6.0_02. While [2] uses factoryId as a property name as specified by the javadocs, the latter one uses it as the concrete factory class name. What is the right behavior? If it is interpreted as a concrete class name, then there is indeed no point in having the API in the first place. User can as well do classloader.loadClass(classname).newInstance(), which is exactly what the implementation in JDK does. On the other hand, treating the string as a property name allows caller not to hard code the factory class name and there by allowing some kind of dynamic behavior. A look at [2] reveals that it attempts to read the value of the property as a system property else from jre/lib/jaxp.properties file. It uses the value as the concrete class name. If the property is not defined, then it falls back to a default implementation class name. So, [2] may be correct after all.

[1] http://java.sun.com/javase/6/docs/api/javax/xml/stream/XMLInputFactory.html#newInstance()
[2] http://download.java.net/maven/1/javax.xml.stream/jars/stax-api-1.0-2-sources.jar

Comments
EVALUATION Fixed in JAXP 1.4. Will integrate into the jdk6 update 23 and jdk7.
24-08-2010

EVALUATION I agree this is a violation to the spec. I will fix it in jaxp 1.4 first, and then request an integration into the jdk.
14-07-2010