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

TIFFField#createFromMetadataNode javadoc should provide information about sibling/child nodes that should be part of parameter node

    XMLWordPrintable

Details

    Description

      Note: This bug relates to the https://bugs.openjdk.java.net/browse/JDK-8149560
      Aforementioned bug states that spec mentioned a wrong "tagNumber" attribute name for setting tag number.
      I created a new issue so that information is not cluttered in one place and is not confusing for dev to evaluate.

      This bug states that even when a valid attribute name "number" is used to set a tag number as per tiff native format ,the tested method fails again with NPE because data derived from the node is null.

      Following is the analysis,

      As per native tiff format structure :

      A TIFFField consist of attributes and child nodes .

      1.Attributes are "number" and "name" (whose value is tag number and mnemonic names)
      2. child nodes can be any of the following
              (TIFFBytes | TIFFAsciis |
              TIFFShorts | TIFFSShorts | TIFFLongs | TIFFSLongs |
              TIFFRationals | TIFFSRationals |
              TIFFFloats | TIFFDoubles | TIFFUndefined)
      each of above child node in turn has more nodes as per the native tiff format structure ultimately leading to the value of the tag.

      So in order to construct a valid node ,
      We need to set correct attributes to the parent node as per above structure
      We need create valid child nodes and append them to the parent node as per above structure.

      This information is critical not only for constructing a valid Node that is a parameter to the TIFFField#createFromMetadataNode method but also for implicitly creating a non-null data by the tested method that would eventually be supplied to TIFFField constructor.

      So i believe the spec should mention or at least link the native tiff format structure and state that node should adhere to native tiff structure .

      Otherwise the behavior is not predictable to the existing spec/javadoc. This is because a simple node created and set with a tag number attribute is not enough for method to pass/ create a TIFFField.

      The below snippet fails with NPE because the derived data is null even though the attribute name is correct,
      IIOMetadataNode node = new IIOMetadataNode("TIFFField");
      node.setAttribute("number", String.valueOf(BaselineTIFFTagSet.TAG_IMAGE_LENGTH));
      TIFFField tiffField = TIFFField.createFromMetadataNode(BaselineTIFFTagSet.getInstance(), node);
      I attached a standalone test case describing the above scenario for your evaluation.

      Attachments

        Activity

          People

            bpb Brian Burkhalter
            bnallakaluva Bharath Nallakaluva (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: