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

IIOMetadata.getMetadataFormat() throws unexpected ArrayIndexOutOfBoundsException

XMLWordPrintable

    • beta2
    • generic
    • generic



      Name: mlR10151 Date: 05/08/2001



      The description for the javax.imageio.metadata.IIOMetadata class reads:

      protected IIOMetadata(boolean standardMetadataFormatSupported,
                            String nativeMetadataFormatName,
                            String nativeMetadataFormatClassName,
                            String[] extraMetadataFormatNames,
                            String[] extraMetadataFormatClassNames):

      No words here about the situation if extraMetadataFormatNames.length > extraMetadataFormatClassNames.length.


      public IIOMetadataFormat getMetadataFormat(String formatName):

      No words about ArrayIndexOutOfBoundsException


      But getMetadataFormat throws ArrayIndexOutOfBoundsException in the example below:
      ========================== a.java =============================
      import javax.imageio.metadata.IIOMetadata;
      import org.w3c.dom.Node;

      public class a extends IIOMetadata {
          static String[] sarr1 = {"name1"};
          static String[] sarr2 = {};

          public static void main (String argv[]) throws Exception {
              new a();
          }

          public a() throws Exception {
              super(true, null, null, sarr1, sarr2);
              getMetadataFormat("name1");
          }

          public Node getAsTree(String formatName) {
              return null;
          }

          public boolean isReadOnly() {
              return true;
          }

          public void mergeTree(String formatName, Node root) {}

          public void reset() {}
      }
      ==========================log========================
      % java -version
      java version "1.4.0-beta"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-beta-b63)
      Java HotSpot(TM) Client VM (build 1.4.0-beta-b63, mixed mode)
      % java a
      Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException
              at javax.imageio.metadata.IIOMetadata.getMetadataFormat(IIOMetadata.java:327)
              at a.<init>(a.java:14)
              at a.main(a.java:9)


      This bug causes failure of the new JCK test
      api/javax_imageio/metadata/IIOMetadata/index.html#Ctor

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

            dricesunw Daniel Rice (Inactive)
            mlsunw Ml Ml (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: