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

getAttributeDescription accepts illegal attribute name

    Details

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

      Description



      Name: dkR10031 Date: 04/10/2001


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

      "Throws: ...
               IllegalArgumentException - if attrName is null or is not a legal
               attribute name for this element."

      However, the implementation (JDK 1.4.0beta, build b59) of the method does
      not throw IllegalArgumentException when given non-existent attribute name.

      This bug causes failure of new JCK test:
      api/javax_imageio/metadata/IIOMetadataFormatImpl/index.html#getAttributeDescription

      To reproduce the bug run the following test:

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

      class test04 {

          public static void main(String argv[]) {
              String result;
              
              MyFormatImpl fmt = new MyFormatImpl("root", 1, 10);
              fmt.addAttribute("root", "attr", fmt.DATATYPE_INTEGER, true, 2, 5);

              try {
                  result = fmt.getAttributeDescription("root", "non-existent", null);
                  System.out.println("failed: no IllegalArgumentException");
              } catch(IllegalArgumentException e) {
                  System.out.println("passed");
              }
          }
      }


      class MyFormatImpl extends IIOMetadataFormatImpl {

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

          public void addAttribute(String elementName, String attrName, int dataType,
                                   boolean required, int listMinLength, int listMaxLength) {
              super.addAttribute(elementName, attrName, dataType, required, listMinLength,
      listMaxLength);
          }

          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-b59)
      Java HotSpot(TM) Client VM (build 1.4.0-beta-b59, mixed mode)

      $ javac test04.java

      $ java test04
      failed: no IllegalArgumentException

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

        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: