-
Bug
-
Resolution: Duplicate
-
P2
-
None
-
5.0
-
generic
-
generic
Name: erR10175 Date: 02/03/2004
The method
public Schema newSchema(File schema) throws SAXException
in the class javax.xml.validation.SchemaFactory throws NullPointerException for
a non-null File instance. It does not depend on whether the file exist or not.
And it does not depend on the content of the file.
The javadoc of the method allows NPE only if the schema parameter is null.
That is not the case, so it is a bug.
Many (more than a thousand) new JCK 1.5 beta2 tests in
api/xml_schema/msxsdtest
use this newly introduced SchemaFactory class to check whether a JAXP 1.3 implementation
determines validness of test schemas correctly.
The bug is found in jdk1.5.0/beta/b36 and is not reproducible with jdk1.5.0/beta/b35.
To reproduce the bug compile and run the following code as shown in the logs below.
------------------------------------------- test.xsd
<?xml version="1.0"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:element name="test"/>
</xsd:schema>
----------------------------------------------------
------------------------------------------ test.java
import java.io.File;
import javax.xml.validation.SchemaFactory;
public class test {
public static void main(String [] args) throws Exception {
SchemaFactory schemaFactory =
SchemaFactory.newInstance("http://www.w3.org/2001/XMLSchema");
schemaFactory.newSchema(new File(args[0]));
System.out.println("Passed.");
}
}
----------------------------------------------------
------------------------------------------------ log1
$javac test.java && java -showversion test test.xsd
java version "1.5.0-beta2"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-beta2-b35)
Java HotSpot(TM) Client VM (build 1.5.0-beta2-b35, mixed mode)
Passed.
----------------------------------------------------
------------------------------------------------ log2
$javac test.java && java -showversion test test.xsd java version "1.5.0-beta2"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-beta2-b36)
Java HotSpot(TM) Client VM (build 1.5.0-beta2-b36, mixed mode)
Exception in thread "main" java.lang.NullPointerException
at com.sun.org.apache.xerces.internal.impl.xs.traversers.XSDHandler.reset(XSDHandler.java:1674)
at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaLoader.reset(XMLSchemaLoader.java:505)
at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaLoader.loadGrammar(XMLSchemaLoader.java:538)
at com.sun.org.apache.xerces.internal.jaxp.validation.xs.SchemaFactoryImpl.newSchema(SchemaFactoryImpl.java:152)
at javax.xml.validation.SchemaFactory.newSchema(SchemaFactory.java:414)
at javax.xml.validation.SchemaFactory.newSchema(SchemaFactory.java:430)
at test.main(test.java:10)
----------------------------------------------------
======================================================================
The method
public Schema newSchema(File schema) throws SAXException
in the class javax.xml.validation.SchemaFactory throws NullPointerException for
a non-null File instance. It does not depend on whether the file exist or not.
And it does not depend on the content of the file.
The javadoc of the method allows NPE only if the schema parameter is null.
That is not the case, so it is a bug.
Many (more than a thousand) new JCK 1.5 beta2 tests in
api/xml_schema/msxsdtest
use this newly introduced SchemaFactory class to check whether a JAXP 1.3 implementation
determines validness of test schemas correctly.
The bug is found in jdk1.5.0/beta/b36 and is not reproducible with jdk1.5.0/beta/b35.
To reproduce the bug compile and run the following code as shown in the logs below.
------------------------------------------- test.xsd
<?xml version="1.0"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:element name="test"/>
</xsd:schema>
----------------------------------------------------
------------------------------------------ test.java
import java.io.File;
import javax.xml.validation.SchemaFactory;
public class test {
public static void main(String [] args) throws Exception {
SchemaFactory schemaFactory =
SchemaFactory.newInstance("http://www.w3.org/2001/XMLSchema");
schemaFactory.newSchema(new File(args[0]));
System.out.println("Passed.");
}
}
----------------------------------------------------
------------------------------------------------ log1
$javac test.java && java -showversion test test.xsd
java version "1.5.0-beta2"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-beta2-b35)
Java HotSpot(TM) Client VM (build 1.5.0-beta2-b35, mixed mode)
Passed.
----------------------------------------------------
------------------------------------------------ log2
$javac test.java && java -showversion test test.xsd java version "1.5.0-beta2"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-beta2-b36)
Java HotSpot(TM) Client VM (build 1.5.0-beta2-b36, mixed mode)
Exception in thread "main" java.lang.NullPointerException
at com.sun.org.apache.xerces.internal.impl.xs.traversers.XSDHandler.reset(XSDHandler.java:1674)
at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaLoader.reset(XMLSchemaLoader.java:505)
at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaLoader.loadGrammar(XMLSchemaLoader.java:538)
at com.sun.org.apache.xerces.internal.jaxp.validation.xs.SchemaFactoryImpl.newSchema(SchemaFactoryImpl.java:152)
at javax.xml.validation.SchemaFactory.newSchema(SchemaFactory.java:414)
at javax.xml.validation.SchemaFactory.newSchema(SchemaFactory.java:430)
at test.main(test.java:10)
----------------------------------------------------
======================================================================
- duplicates
-
JDK-4984072 SchemaFactory.newSchema() throws NPE for all sources
- Closed