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

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

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P4
    • Resolution: Fixed
    • Affects Version/s: 1.2.0
    • Fix Version/s: 1.3.0
    • Component/s: tools
    • Labels:
    • Subcomponent:
      jar
    • Resolved In Build:
      kestrel
    • CPU:
      sparc
    • OS:
      solaris_2.6
    • Verification:
      Verified

      Description



      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

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

        Attachments

          Activity

            People

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

              Dates

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: