-
Bug
-
Resolution: Fixed
-
P3
-
5.0
-
tiger
-
generic
-
generic
-
Verified
Name: eaR10174 Date: 08/26/2003
The following methods of XMLReader implementation incorrectly throw NullPointerException
(see test.java below) in case when a parameter is null
public void setContentHandler(ContentHandler handler)
public void setDTDHandler(DTDHandler handler)
public void setEntityResolver(EntityResolver resolver)
public void setErrorHandler(ErrorHandler handler)
In jdk1.5.0-beta-b16 the version of javadoc of the methods has been changed from SAX 2.0
to SAX 2.0.1 . The javadoc reads that the methods do not throw NullPointerException. So
according to the document "Requirements for Writing Java API Specifications"
(http://java.sun.com/j2se/javadoc/writingapispecs/index.html) in such a case the parameter
null is valid value.
The bug appears in jdk1.5.0beta-b16 and affects JCK1.5 tests that have been adapted for
the new javadoc:
api/org_xml/sax/XMLReader/index.html#Handler[Handler103]
api/org_xml/sax/XMLReader/index.html#Handler[Handler305]
api/org_xml/sax/XMLReader/index.html#Handler[Handler507]
api/org_xml/sax/XMLReader/index.html#Handler[Handler709]
------------------------------------test.java-----------------------------
import javax.xml.parsers.SAXParserFactory;
import org.xml.sax.XMLReader;
import org.xml.sax.helpers.DefaultHandler;
public class test {
public static void main(String argv[]) {
new test().run();
}
public void run() {
XMLReader parser = null;
try {
parser = SAXParserFactory.newInstance().newSAXParser().getXMLReader();
} catch (Exception e) {
e.printStackTrace();
System.exit(1);
}
DefaultHandler handler = null;
try {
parser.setContentHandler(handler);
} catch (NullPointerException e) {
System.out.println("");
e.printStackTrace();
}
try {
parser.setDTDHandler(handler);
} catch (NullPointerException e) {
System.out.println("");
e.printStackTrace();
}
try {
parser.setEntityResolver(handler);
} catch (NullPointerException e) {
System.out.println("");
e.printStackTrace();
}
try {
parser.setErrorHandler(handler);
} catch (NullPointerException e) {
System.out.println("");
e.printStackTrace();
}
}
}
--------------------------------------------------------------------------
% java -showversion test
java version "1.5.0-beta"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-beta-b16)
Java HotSpot(TM) Client VM (build 1.5.0-beta-b16, mixed mode)
java.lang.NullPointerException
at
com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.setContentHandler(AbstractSAX
Parser.java:1422)
at test.run(test.java:23)
at test.main(test.java:8)
java.lang.NullPointerException
at
com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.setDTDHandler(AbstractSAXPars
er.java:1370)
at test.run(test.java:30)
at test.main(test.java:8)
java.lang.NullPointerException
at
com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.setEntityResolver(AbstractSAX
Parser.java:1232)
at test.run(test.java:37)
at test.main(test.java:8)
java.lang.NullPointerException
at
com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.setErrorHandler(AbstractSAXPa
rser.java:1291)
at test.run(test.java:44)
at test.main(test.java:8)
--------------------------------------------------------------------------
======================================================================
The following methods of XMLReader implementation incorrectly throw NullPointerException
(see test.java below) in case when a parameter is null
public void setContentHandler(ContentHandler handler)
public void setDTDHandler(DTDHandler handler)
public void setEntityResolver(EntityResolver resolver)
public void setErrorHandler(ErrorHandler handler)
In jdk1.5.0-beta-b16 the version of javadoc of the methods has been changed from SAX 2.0
to SAX 2.0.1 . The javadoc reads that the methods do not throw NullPointerException. So
according to the document "Requirements for Writing Java API Specifications"
(http://java.sun.com/j2se/javadoc/writingapispecs/index.html) in such a case the parameter
null is valid value.
The bug appears in jdk1.5.0beta-b16 and affects JCK1.5 tests that have been adapted for
the new javadoc:
api/org_xml/sax/XMLReader/index.html#Handler[Handler103]
api/org_xml/sax/XMLReader/index.html#Handler[Handler305]
api/org_xml/sax/XMLReader/index.html#Handler[Handler507]
api/org_xml/sax/XMLReader/index.html#Handler[Handler709]
------------------------------------test.java-----------------------------
import javax.xml.parsers.SAXParserFactory;
import org.xml.sax.XMLReader;
import org.xml.sax.helpers.DefaultHandler;
public class test {
public static void main(String argv[]) {
new test().run();
}
public void run() {
XMLReader parser = null;
try {
parser = SAXParserFactory.newInstance().newSAXParser().getXMLReader();
} catch (Exception e) {
e.printStackTrace();
System.exit(1);
}
DefaultHandler handler = null;
try {
parser.setContentHandler(handler);
} catch (NullPointerException e) {
System.out.println("");
e.printStackTrace();
}
try {
parser.setDTDHandler(handler);
} catch (NullPointerException e) {
System.out.println("");
e.printStackTrace();
}
try {
parser.setEntityResolver(handler);
} catch (NullPointerException e) {
System.out.println("");
e.printStackTrace();
}
try {
parser.setErrorHandler(handler);
} catch (NullPointerException e) {
System.out.println("");
e.printStackTrace();
}
}
}
--------------------------------------------------------------------------
% java -showversion test
java version "1.5.0-beta"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-beta-b16)
Java HotSpot(TM) Client VM (build 1.5.0-beta-b16, mixed mode)
java.lang.NullPointerException
at
com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.setContentHandler(AbstractSAX
Parser.java:1422)
at test.run(test.java:23)
at test.main(test.java:8)
java.lang.NullPointerException
at
com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.setDTDHandler(AbstractSAXPars
er.java:1370)
at test.run(test.java:30)
at test.main(test.java:8)
java.lang.NullPointerException
at
com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.setEntityResolver(AbstractSAX
Parser.java:1232)
at test.run(test.java:37)
at test.main(test.java:8)
java.lang.NullPointerException
at
com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.setErrorHandler(AbstractSAXPa
rser.java:1291)
at test.run(test.java:44)
at test.main(test.java:8)
--------------------------------------------------------------------------
======================================================================
- relates to
-
JDK-4905104 jaxp13,sax2.0.1 feature broken, Null ptr exception when trying to set ErrorHandl
- Resolved