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

getChildNames returns empty array instead of null

    XMLWordPrintable

    Details

    • Subcomponent:
    • Resolved In Build:
      beta
    • CPU:
      generic
    • OS:
      generic

      Description



      Name: dkR10031 Date: 03/25/2001


      Specification of the method
      javax.imageio.metadata.IIOMetadataFormatImpl.getChildNames says:

      "If the element cannot have children, null is returned."

      However, the implementation (JDK 1.4.0beta, build b56) of the method returns
      String array of length 0 instead of null when the element is created with
      a child policy CHILD_POLICY_EMPTY.


      This bug causes failure of new JCK test:
      api/javax_imageio/metadata/IIOMetadataFormatImpl#getChildNames

      To reproduce the bug run the following test:

      ------------ test02.java ------------------------
      import javax.imageio.metadata.IIOMetadataFormatImpl;
      import javax.imageio.ImageTypeSpecifier;

      public class test02 {

          public static void main(String argv[]) {

              MyFormatImpl fmt = new MyFormatImpl("root", 1, 10);
              fmt.addElement("cc", "root", fmt.CHILD_POLICY_EMPTY);

              String[] result = fmt.getChildNames("cc");

              if (result != null) {
                  System.out.println("Faild, result is not null: " + result);
              } else {
                  System.out.println("Passed");
              }
          }
      }


      class MyFormatImpl extends IIOMetadataFormatImpl {

          MyFormatImpl(String root, int minChildren, int maxChildren) {
              super(root, minChildren, maxChildren);
          }

          public void addElement(String elementName, String parentName, int childPolicy) {
              super.addElement(elementName, parentName, childPolicy);
          }

          public boolean canNodeAppear(String elementName, ImageTypeSpecifier imageType) {
              return true;
          }
      }
      ------------ Logs -----------------------------
      $ java -version
      java version "1.4.0-beta"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-beta-b56)
      Java HotSpot(TM) Client VM (build 1.4-beta-B56, mixed mode)

      $ javac test02.java

      $ java test02
      Faild, result is not null: [Ljava.lang.String;@14df86

      -----------------------------------------------
      ======================================================================

        Attachments

          Activity

            People

            Assignee:
            dricesunw Daniel Rice (Inactive)
            Reporter:
            dimasunw Dima Dima (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: