Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-5011499

Exceptions: NPE not thrown in case of null message

XMLWordPrintable

    • b44
    • generic
    • generic
    • Verified



      Name: eaR10174 Date: 03/10/2004


      NullPointerException is not thrown in cases when XPath exceptions are created by the
      constructor with the null message. According to the javadoc NullPointerException
      should be thrown.

      The bug affects the new JCK1.5-beta1 tests:

        api/javax_xml/xpath/XPathException/index.html#Ctor[Ctor004]
        api/javax_xml/xpath/XPathExpressionException/index.html#Ctor[Ctor004]
        api/javax_xml/xpath/XPathFactoryConfigurationException/index.html#Ctor[Ctor004]
        api/javax_xml/xpath/XPathFunctionException/index.html#Ctor[Ctor004]

      The sample is provided below; it fails on JDK 1.5.0-beta-b41.
      ------------------------------------test.java-----------------------------
      import javax.xml.xpath.XPathException;
      import javax.xml.xpath.XPathExpressionException;
      import javax.xml.xpath.XPathFactoryConfigurationException;
      import javax.xml.xpath.XPathFunctionException;

      public class test {

           public static void main(String argv[]) {
               test t = new test();
               t.run01();
               t.run02();
               t.run03();
               t.run04();
           }

           public void run01() {
               try {
                   XPathException xpathException = new XPathException((String)null);
                   System.out.println("run01 failed.");
               } catch (NullPointerException e) {
                   System.out.println("run01 OK");
               }
           }

           public void run02() {
               try {
                   XPathExpressionException xpathException =
                       new XPathExpressionException((String)null);
                   System.out.println("run02 failed.");
               } catch (NullPointerException e) {
                   System.out.println("run02 OK");
               }
           }

           public void run03() {
               try {
                   XPathFactoryConfigurationException xpathException =
                       new XPathFactoryConfigurationException((String)null);
                   System.out.println("run03 failed.");
               } catch (NullPointerException e) {
                   System.out.println("run03 OK");
               }
           }

           public void run04() {
               try {
                   XPathFunctionException xpathException =
                       new XPathFunctionException((String)null);
                   System.out.println("run04 failed.");
               } catch (NullPointerException e) {
                   System.out.println("run04 OK");
               }
           }
      }
      --------------------------------------------------------------------------
      % java -showversion test
      java version "1.5.0-beta2"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-beta2-b41)
      Java HotSpot(TM) Client VM (build 1.5.0-beta2-b41, mixed mode)

      run01 failed.
      run02 failed.
      run03 failed.
      run04 failed.
      --------------------------------------------------------------------------

      ======================================================================

      Name: eaR10174 Date: 03/11/2004


      The tests do not fail on jdk1.5 builds prior jdk1.5.0-beta2-b41 build.

      ======================================================================

            rmandavasunw Ramesh Mandava (Inactive)
            evgsunw Evg Evg (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: