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

java.util.jar.Attributes.Name(String name) accepts empty names

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 1.3.0
    • 1.2.0
    • tools
    • jar
    • kestrel
    • sparc
    • solaris_2.6
    • Verified



      Name: ksC84122 Date: 12/28/98


      java.util.jar.Attributes.Name(String name) accepts empty String as
      a parameter and creates a new object in JDK-1.2fcs.
      However the JavaDoc for Attributes.Name(String name)says that
      constructor throws "IllegalArgumentException - if the attribute name was invalid".

      The constructor should recognize empty name as invalid attribute name and throw
      IllegalArgumentException per Attribute.Name definition in JavaDoc:
      "The Attributes.Name class represents an attribute name stored in this Map. Attribute names are
      case-insensitive and restricted to the ASCII characters in the set [0-9a-zA-Z_-]."
       
      Empty attribute name makes no sense and should not be allowed.

      An example to reproduce this:
      ===== Test20.java ========
      import java.util.jar.Attributes;
      import java.util.jar.Attributes.Name;

      public class Test20 {

          public static void main (String argv[]) {
              
              try {
                  new Attributes.Name("");
              } catch (IllegalArgumentException iae) {
                  System.out.println("Passed");
                  return;
              }
              System.out.println("Failed: IllegalArgumentException expected");
              return;
          }
      }

      ========= Sample run (JDK-1.2fcs) ==========
      #>java Test20
      Failed: IllegalArgumentException expected

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

            zlisunw Zhenghua Li (Inactive)
            ksoshals Kirill Soshalskiy (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: