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

AttributeSetUtilities.unmodifiableView() does not throw NPE

XMLWordPrintable

    • 2d
    • generic
    • generic



      Name: vtR10009 Date: 06/22/2001


        This bug is created specially for JCK Merlin-beta, because this version of
      JCK is based on jdk1.4.0beta-b65 and the bug is found in this version of jdk.
      The bug has not been found in the last jdk version (jdk1.4.0beta-b69).

        The spec for the AttributeSetUtilities.unmodifiableView() reads:
      Throws:
                NullPointerException - Thrown if attributeSet is null.

      API implementation (build 1.4.0-beta-b65) doesn't throw this exception.

      This bug causes failures of JCK-merlin-beta tests:
      api/javax_print/attribute/AttributeSetUtilities/index.html#unmodifiableViewTests

      However last API implementation (build 1.4.0-beta-b69) passes these tests
      and bug was filled only for test exclusion from JCK-merlin-beta workspace.

      To reproduce the bug run the following test:
      ------------------------------- test.java --------------------------------
      import javax.print.attribute.AttributeSet;
      import javax.print.attribute.DocAttributeSet;
      import javax.print.attribute.PrintJobAttributeSet;
      import javax.print.attribute.PrintRequestAttributeSet;
      import javax.print.attribute.PrintServiceAttributeSet;
      import javax.print.attribute.AttributeSetUtilities;

      public class test {

          public static void main(String args[]) {

              boolean failed = false;
              AttributeSet unModSet;

              try {
                  unModSet =
      AttributeSetUtilities.unmodifiableView((AttributeSet)null);
                  System.out.println("NullPointerException was not thrown! "
                          + "Argument type: AttributeSet.");
                  failed = true;
              } catch (NullPointerException ex) {}
              try {
                  unModSet =
      AttributeSetUtilities.unmodifiableView((DocAttributeSet)null);
                  System.out.println("NullPointerException was not thrown! "
                          + "Argument type: DocAttributeSet.");
                  failed = true;
              } catch (NullPointerException ex) {}
              try {
                  unModSet =
      AttributeSetUtilities.unmodifiableView((PrintJobAttributeSet )null);
                  System.out.println("NullPointerException was not thrown! "
                          + "Argument type: PrintJobAttributeSet.");
                  failed = true;
              } catch (NullPointerException ex) {}
              try {
                  unModSet =
      AttributeSetUtilities.unmodifiableView((PrintRequestAttributeSet )null);
                  System.out.println("NullPointerException was not thrown! "
                          + "Argument type: PrintRequestAttributeSet.");
                  failed = true;
              } catch (NullPointerException ex) {}
              try {
                  unModSet =
      AttributeSetUtilities.unmodifiableView((PrintServiceAttributeSet )null);
                  System.out.println("NullPointerException was not thrown! "
                          + "Argument type: PrintServiceAttributeSet.");
                  failed = true;
              } catch (NullPointerException ex) {}
              
              if (!failed) {
                  System.out.println("Ok.");
              }
          }
      }
      ---------------------------Logs--------------------------------------
      > $jdk_b65/bin/javac test.java
      > $jdk_b65/bin/java test
      NullPointerException was not thrown! Argument type: AttributeSet.
      NullPointerException was not thrown! Argument type: DocAttributeSet.
      NullPointerException was not thrown! Argument type: PrintJobAttributeSet.
      NullPointerException was not thrown! Argument type: PrintRequestAttributeSet.
      NullPointerException was not thrown! Argument type: PrintServiceAttributeSet.
      > $jdk_b65/bin/java -version
      java version "1.4.0-beta"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-beta-b65)
      Java HotSpot(TM) Client VM (build 1.4.0-beta-b65, mixed mode)
      ---------------------------------------------------------------------
      ======================================================================

            jgodinez Jennifer Godinez (Inactive)
            vitcsunw Vitc Vitc (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: